Sunday, July 15, 2012

New and Exciting web browser: Qupzilla

The world of web browsers is a split between the core used to render web pages. Webkit is used by Midori and all Google Chrome / Chromium variants. The other option, Gecko, is used by Firefox. Webkit offers some functionality over Gecko, including plugins and faster rendering of pages. A new web browser has recently come into existence that is fully cross-platform compatible and uses webkit called Qupzilla. Despite the weird sounding name, this web browser could give some of the larger browser a run for their money if it gets some of its kinks worked out. Here is the breakdown:
 Every operating system that has a Qt port and webkit can run Qupzilla. Windows, OS X, and any major Unix are all eligible. That is better support than Google Chrome and it's only a year old. Other than the great support it has other advantages:

Built-in addons
The web browser has multiple addons installed by default. Greasemonkey, a personal information handler, a speed dial (pictured, and adblock are all installed from the get-go.

Theming and Configuration
Themes are installable like in other browsers. The browser comes  with a few themes installed by default. They try to mimic the appearance of a theme for a certain operating system. The Linux theme integrates with you Qt theme specified in qt4-qt4config (run with qtconfig).

 Configuring Qupzilla is similar to configuring Firefox. Going to edit>preferences brings up a terse set of menus for configuring your web browser. A bunch of goodies are packed into here, including network proxy configurations, notifications, the password manager, and the download manager. A dialog for notifications is also including, and I was impressed at how well it integrated with free-desktop compliant notifications as well as OSD just like a more mature project like clementine does.


Compatibility
Qupzilla can import bookmarks from most major browsers. For playing video and game content, HTML 5 and Flash both work perfectly.

Browsing experience
Webkit loads pages very fast. I am on a slow connection and I was able to take note of the speeds that were achieved with webkit. Because of Qupzilla's use of Webkit and how it works with the operating system the memory usage should be FAR lower per-tab than any other major web browser. There are also other features in the browsing experience that make it unique. The IP address of a loaded page and the progress of loading is shown in the status bar. The search bar AND omnibar can both use different search engines depending on a set preference dialog or a key-letter like "g" for google or "d" for duckduckgo. Flash playing support is installed by default.
Like Firefox, Qupzilla has a download manager. A feature that I found to be very interesting was the ability to pass off an external program and parameters as the download manager.

Development Process
Major web browsers always feel the same anymore. Qupzilla is not to that point of maturity yet. Every update (which are somewhat frequent) brings some new and exciting feature along with it. The project is open-source and listed on github. The developers and anybody interesting in helping the project (as well as just normal users) should join #qupzilla on the freenode IRC network. I've talked a bit to the developers, and they are all very nice people that tend to listen to suggestions.

Of course, like any project it has its disadvantages too. Here is a rundown of those:


Addon support
The web browser has an extension system, but almost nobody is developing extensions that work with Qupzilla. The addons including by default are ported by the developers and may not be fully functioning. In fact, my beloved spell check doesn't work. This was the only real dealbreaker for me. Userscripts do work but they may not work exactly right.

Stability
The project is relatively new and bugs are being worked out. I haven't had a crash from it yet, but at one point it wiped all of my speed dial entries.

Conclusion
Qupzilla certainly is not the best web browser in the world in its current state. The major gripe with its users is addon support, and I couldn't agree more with how much this helps a browser out. I've contacted the developers, urging them to improve the plugin framework by looking at Firefox and Eclipse's approach. If addon support improved and better UI customization came to be, I would definitely use this as my default browser.

Wednesday, July 11, 2012

What is the Ouya, and why is it a good idea?

The ouya is a new prototype for a $99 Android box that can be connected directly to a television. It surged in popularity today, gaining millions of dollars on Kickstarter where the project gets its funds. It also has deals with major gaming companies as well as Mojang to port games to it if it is successful in next year's launch. Everyone is so excited about this, so what is it?

Ouya is, as stated, a console that runs Android 4.0, the Open Handset Alliance's mobile operating system. Some have criticized it for brining a mobile system into the stationary setting of a home, but those are the people that do not understand the true power of having an android powered gaming console; I will describe the benefits in the next section. The founders wanted to go against exactly the sentiment. The founder fears that games are moving away from the TV and that the experience is just not the same anymore for a possible gamer.

 A prototype is already complete with software, controllers, and all. Now the creators of the console are going to fund the production of the final version version. Take a look at the prototype software (from their kickstarter):




Neat. A game console running on Android. What are the benefits of such a device?
Well, good question. Android is open-source, meaning that programmers (for games and other apps) can find out how to best utilize the Android system in their software. Also, hobbyists from around the world can make improvements to the system, unlike the proprietary nature of almost all of the world's gaming consoles. Even the hardware specifications will be made open once the final version is released.

Another great advantage is the popularity of the Android SDK. Android has a lot going for it right now, especially with the popularity of tablets and smart phones nowadays.  This means that more developers will be willing to make games and other apps for the Ouya. Not only is it a popular platform, but it is also very easy to distribute applications. Unlike, for instance, the Xbox style of game distribution, an independent developer could publish an App onto Ouya free of charge (not counting the $25 Android market license). There is a 70 / 30 cuts between the developer and Ouya, just like on the Android market.

Yet another benefit for developers is the power of the SDK and Java, which apps are built in. The android SDK covers a lot of ground, so developers don't have to spend their time re-inventing the wheel. Developers can get right to the creative part of coding.

Another huge benefit is the hackability of the console. All Android devices can be "rooted", that is gaining superuser control over your device. By default the Ouya is not rooted, but if you do decide to go root it will not void your warranty. This is highly uncommon for a company to encourage tinkering with their system. In fact, for hardware hackers there is a USB port so custom peripherals can be developed for it. The software is just as hackable, since Android is completely Open-source.

With all these perks for developers, what do the users get?
The users get the result of a happy developer. More games will be developed for this platform than any other because of the openness of the android market and Android as a whole. Also, the user benefits from buying a $99 dollar Android box with a 4-core processor and wifi (plus that USB port mentioned above). Those are good specs for the money (although I feel that the 1GB of RAM is a bit low).

Here is a picture of the Ouya controller from their kickstarter page:


For applications that do not support the Ouya controller, they have included a touchpad. This makes all applications available for Android (at least the ones that don't use phone-specific services) immediately portable to the Ouya console. Even for games that do not require a touchpad, it could be added as a new feature of the controller. It is my estimate that applications developed specifically for Ouya will still utilize the touchpad. It's not just a safety measure.

I have donated to the project, and I am trying to aid by spreading word here. Personally I do not support it for a gaming platform, but for the spread of open-source software onto the console market that has been dominated by proprietary software just about since it came about.

Friday, July 6, 2012

Function Pointers in C (and C++) - What are they and How to use them

If you are using the C programming language, you have probably already worked with pointers extensively. Chances are that you have also worked with functions. So, when you put two and two together, you get a function pointer; that is a pointer to a function. Function pointers are a wonderful way to organize and use functions and can also save some space. Here are some examples of how they are used:

int func(int x){return 0;}//This will be used throughout the post.

Function pointers work just like any pointer, meaning they will hold the address of a function (for quite some time I ignorantly assumed that functions didn't have their own memory address). However, the type is a bit weird. The syntax is

primitive-type (*pointer_name) (parameters)


for our above example we would make a function pointer like this:


int (*funcPoint)(int x)=&func;

Function pointers can be returned as well as executed. Lets pretend that a function called getPoint returns a function to a pointer like this:

int (*getPoint(int x))(){return &func;}//1

To call the pointer this returns, the code would look like this:

funcPoint = getPoint();//2
funcPoint(4);//3

Let's explain what just happened in the few lines above:

1: We declared a function returning a pointer with one argument (x) that returns an int. The function itself has no parameters (thus the ()).

2: We assigned funcPoint (declared earlier) the address of the function returned by getPoint();

3: We called the function stored in funcPoint with an argument of 4.

Of course, function pointers are more powerful than just returning and calling from functions they have more uses.

1: When a function needs to get passed into another file without using an #include

2: When organization is key. For plugin systems (I made a small one called Crunch once) it is helpful to keep an array of function pointers to call. They are declared like this:

At the top of the file: typedef int (*func)(int);
Somewhere else:        func functions[10];
(Yes, you can also just do int (*func[10])(int); but I think it is a lot more organized to use typedef.)

Of course, members are added to the array as such: &function (NOTE THAT THERE ARE NO ()'s FOR PARAMETERS)

3: For something that resembled exception handling
You can fix issues by having a file named "helper.h" that returns a function based on some variables in "helpme.h". All you would need is a function that gets some information from helpme.h (possibly with a function pointer to a function returning an array pointer like this:
char** (*func(int))(){};
)
and a function in helper.h that returns a function to aid helpme.h in whatever it needs.

----
Pointers have an endless amount of possibilities. Anything with a type and a memory address can and will be assigned to a pointer. I consider function pointers the "final frontier" of pointery, since variables and functions make up the whole of a C program. And yes, this also applies to C++, but I didn't want to talk about C++ because it gets even more confusing with class members and what-not. It is still possible, though. To check out the full potential of function pointers go here: http://www.newty.de/fpt/fpt.html. That is the resource that I used to learn function pointers so I owe it a shout-out.

Also, I would like to take this time to plug my complete rewrite of nAI. It contains something called crunchLand.h that uses a lot of function pointers https://github.com/dymatic/C---Dumb-AI-with-extras/blob/master/HEADER/Crunch/crunchLand.h
That is crunchLand.h

Thursday, July 5, 2012

Set Keyboard Shortcuts in Gnome 3.*

After a lot of use of Awesome WM, I tried Gnome 3.4 for the first time since a much earlier version of Gnome. I noticed many improvements, especially extensions. However, coming from Awesome I wanted to make it fully usable from the keyboard. Going into the gnome control center did not work, and neither did modifying them from ccsm and using compiz as the window manager. After a bit of searching, I found the answer.

Why it doesn't work:
It turns out that Unity no longer uses the same method of keyboard shortcut definitions that Gnome does. That means that Gnome Control Center sets the shortcuts for Unity, but no longer for Gnome

How to make them work:

Use a program called "Dconf-Editor". Then, go to org > gnome > desktop> wm > keybindings. This is where you can edit the keybindings. The keybindings go inside of the [' s and end with a ']. For instance, closing a window with alt+f4 would look like this: ['<Alt>F4']. Notice that the F is capitalized here. If you use an F1-F12 command, the F is capitalized. More about the semantics in the next section.

Semantics
F1-F12: Capital 'F' followed by number.
Special keys: <Key>, like <Alt> and <Control>. <Control> is spelled out. <Ctrl> will not work.
shift keys: If you use shift in the key combination, the letter with it should be capital.
The Super (Windows logo) button on keyboards is called <Mod4>

Extra
I was worried that binding <Mod4> to anything would invoke the sea of windows. It does not as long as you do not use it by itself. However, whenever all of the windows on a workspace are closed the sea will activate itself.

Sunday, July 1, 2012

Access UI in Android Application Development

This summer I took a class in Android application development with Java. Coming into the experience I had an extensive knowledge with C++ and the Qt framework as well as Swing and Awt which are Java-specific. Qtcreator, a popular Qt IDE, used to make it very simple to access and change the ui using (ui->objname). With Android no such object was generated with the Eclipse IDE, which is the most popular tool for Android application development. I will assume that you are using Eclipse and ADT since that is the most popular choice for developing apps.

The Example
We have a grid layout with a Button called "Button1" in the middle of it. We are going to change the text from the Activity from which it is made.

The Implementation
Down to the business. We need to first access the button object using something called "findViewById()".

In Eclipse there is a variable named "R" that relates to the generated Dalvik Java. To alter the UI, we need to go through this "R" variable to get the ID of a object. The ID is the name given to the object in the layout xml file.

First off, make a Button that will be assigned to the button in the application. (Button b = new Button()). You need to import android.widget.Button to do this. Then, assign it to the button in the layout like this (inside onCreate is a good place to do this. After setContentView) (b= (Button)findViewById(R.id.Button1). This assigns b to the button with that ID from the XML. It is neandroid.wiget.buttoncessary to cast it to a Button since it is just finding the view by ID. Now you have access to all of the methods for that button. To change the text just use the "setText()" method. (b.setText("Button Text")).

Here is the condensed version of all of this as a note:

Sunday, June 24, 2012

12 - Hour clock in Awesome WM

Awesome Window Manager comes with a widget called "Text Clock" that displays the time in a text box in the upper right-hand corner of the screen. It is in 24-hour format instead of 12, which can cause some confusion for users used to the standard 12-hour time.  Your options are to live with it, or change it. If you want a Day,date, hours:minute:second: am/pm format, look at the end of this post.

Option one- Living with it
I found a neat trick to convert 24-hour time into 12-hour time. Take 13:00, for instance. Subtract 2 from the second number and get the second number of 12-hour time. (3-2=1, so it is 1:00). At 23:00 you get "1" again, meaning that it is 11 O' clock. This method uses too many brain cycles, so I decided to get lazy and just change the source of the script.

Option two - Taking Action
Use this command: sudo gedit /usr/share/awesome/lib/awful/widget/textclock.lua
where gedit is any text editor. This is the source code for the clock widget. Make a backup of the real one. I was a ninny and didn't do this. The two important lines are lines 22 and 23: format and timeout. Format uses the strftime function to display the time. Some important things to note: %H is 24-hour hours and %l is 12-hour time with a whitespace instead of a 0 in the first digit in 1-digit times. (For instance 9:42 would by 9:42, not 09:42). All you need to change is %H to %l.


Now, you are faced with a decision. By default this resets itself every 60 seconds. If you use %S (seconds), you need to change this setting to "1". (5 is also commonly used, but it's a pain if you log in on a non-multiple of 5). This way the clock will reset every second.


The two lines for me look like this:

%p should be the only unfamiliar one. This means am or pm (great for any basement dweller with odd sleeping habits!).

You will not notice changes right away. Restart awesome. If you did something wrong the text clock may not be there. Just use your old source in place of the one you edited. This is the advantage of always keeping a backup.

Here is the FULL source of my script. This is what it outputs:


---------------------------------------------------------------------------
-- @author Julien Danjou &lt;julien@danjou.info&gt;
-- @copyright 2009 Julien Danjou
-- @release v3.4.11
---------------------------------------------------------------------------


local setmetatable = setmetatable
local os = os
local capi = { widget = widget,
               timer = timer }


--- Text clock widget.
module("awful.widget.textclock")


--- Create a textclock widget. It draws the time it is in a textbox.
-- @param args Standard arguments for textbox widget.
-- @param format The time format. Default is " %a %b %d, %H:%M ".
-- @param timeout How often update the time. Default is 60.
-- @return A textbox widget.
function new(args, format, timeout)
    local args = args or {}
    local format =  " %a %b %d, %l:%M:%S %p "
    local timeout = 1
    args.type = "textbox"
    local w = capi.widget(args)
    local timer = capi.timer { timeout = timeout }
    w.text = os.date(format)
    timer:add_signal("timeout", function() w.text = os.date(format) end)
    timer:start()
    return w
end


setmetatable(_M, { __call = function(_, ...) return new(...) end })


-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80


You can replace your script with this and it will give you the output I showed you above.

Sunday, June 17, 2012

Living in the Command Line

Some people, usually extreme power users, server owners, and hobbyists choose to use the command line as their primary means of communicating with their computer. Richard Stallman has said that he finds that graphics "distract" him. The command line's learning curve is high since you must know about the command you are issuing, and because a lot of applications are now being developed with their front AND backends using GTK or QT. This article will teach you how to block everything else out, and use the command line for daily life.

Tty's
Tty's are separate logins. You may not know it, but you have 7 open right now if you are using a Linux box. To enter a tty, do this: alt+ctrl+a number 1-6. When you do alt+ctrl+7 from any tty, you will re-enter graphics. Some prefer to use a tty instead of a terminal. Each has a login prompt, where you enter your user name. Then, your password. Don't be surprised if your num lock key is turned off or if you do not see the characters of a pssword being typed. It does this for your safety.

Now that you are in a tty, there are a few things to learn about everyday usage.

Editing Text
To edit text from the command line, you can use GNU Emacs or VIM if either are installed. Otherwise, you will have to use vi, which is usually installed by default on any distribution. Each of the programs have different commands that they use. This can also be used to edit music, movies, and pictures.

Browsing the internet
yes, you can browse the internet from the command line! Download nad install something called links2, which is a textual web browser. From the command line, use the commnad links www.website.com. In links2, you can hit "g" on a non-input area to go to a different website. Sites like Google will work correctly. However, some that use Flash and some that use Javascript will not. Of course, no pictures will be available in this way.

Watching Movies
Wait, you can watch movies from the command line? Yes! You can watch movies in the command line. Download and install mplayer2 (sudo apt-get install mplayer2), then use (mplayer /home/user/movie). This will use the ncurses library to make colored letters to let you watch your video. On X, you can use this and it will create a window to show it in.

Send Email
http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/
This works for some people, but my ISP doesn't allow this to happen. Instead, I have to use smtp, which is a bit harder.
http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/
That explains this in-depth.

Move files
cd changes your directory. ls lists directories. mv moves a file. You can also rename files with mv. To make files, use mkdir. To remove them, use rm.

Kill Processes
Sometimes a process will run long in a tty. When this happens, log into another tty and issue ps -aux
This will list processes and ID's. Then, you can use (kill (ID NUMBER)) (Example: kill 23)

KILL, KILL, KILL
This is a very popular way to remove everything on your computer. Do NOT fall for this anywhere where it may tell you.
sudo rm -rf /
Do not use this command unless you absolutely want to


Tips
man describes a program.
The tab key will autocomplete a statement. I cannot put enough emphasize on how useful this is.

http://www.ubuntugeek.com/useful-and-fun-things-to-do-with-the-ubuntu-terminal.html
This website houses a bunch of cool information.