Wednesday, June 20, 2012

Whether you’re tired of your stock home screen or just want to try
something new, there’s bound to be an Android launcher that’s just right
for you. This week we’re going to check out our top five Android
launchers for customisation, speed, design and features. Photo by Pen Waggener.

ADWLauncher EX ($3.15), the paid version of ADW.Launcher,
is a highly flexible, customisable launcher that supports Android 1.6
and higher. ADW offers hundreds of themes to choose from, customisable
home screen layouts, multiple dock styles that fit up to five different
shortcuts, customisable icon sets, switchable animations, a hidden
dockbar with unlimited scrolling and more. It’s incredibly tweakable for
the advanced, fast and user-friendly for beginners, and it supports a
huge number of devices.

Nova
Launcher is free but only supports Ice Cream Sandwich devices. It gives
you the flexibility to install ADW icon themes if you want to use them,
additional themes to change the layout and look of your launcher, a
scrollable dock with up to three pages of seven icons each, scroll
effects and launch animations that you can toggle on or off, 1×1 widgets
in your dockbar and more. If you have $4 to spend, Nova Launcher Prime unlocks unread count badges, the ability to hide apps, two-finger gestures and dockbar folders.

Go
Launcher EX’s claim to fame is how customisable it is. There are
thousands of themes and icon packs you can download to customise Go
Launcher EX, heaps of widgets, lock screen tweaks and more. Rounded
corners, folder groups, good-looking animations, and an emphasis on
customisable layouts make this launcher popular, and it doesn’t hurt
that it supports Android phones running 2.0 or higher. Combine this with
the fact that the developers are constantly updating the launcher
(which is actually a drawback for many users) and rolling out additional
themes and Go-flavoured apps and widgets that fit right in, and you
have a wealth of tools to transform your Android experience. Plus, it’s
completely free.

Apex
Launcher is free, but it’s another one in the roundup that only
supports Ice Cream Sandwich devices. It’s fast and customisable, offers
up to nine homescreens, seven dockbars with five icons each, replacement
icons for stock Android apps, and lots of beautiful transition and
scroll effects. Best of all, if there’s any element of Apex Launcher
that you don’t like, you can easily hide it. You can lock your home
screen so nothing changes, back it up in case you you want to revert a
change you’ve made, and tweak the app drawer’s appearance. $3.89 will
buy you Apex Launcher Pro,
which adds multifinger gestures to the ones already in the launcher,
support for themes from other launchers (ADW, Go Launcher and Launcher
Pro), 1×1 widgets in the dock and unread count badges.

Launcher
Pro is the non-stock launcher that new users often try first. It
supports Android devices running 2.0 and higher, and while it’s not as
frequently maintained as the others, it still offers buttery-smooth
transitions, customisable layouts, dock scrolling and live home screen
previews. Launcher Pro supports replacement icon packs, infinite
scrolling and more. It has been a long time since its last update, but
if you’re looking for a good, fast Launcher to get started with,
Launcher Pro is a good pick.

Honourable mentions this week go out to Zeam Launcher for its minimalistic and uncluttered approach, and Stock ICS Launcher
for being a huge improvement over launchers of yesteryear. Sadly, since
most Android users don’t have ICS yet, the latter is not an option
until you upgrade your device or your manufacturer decides to throw you a
bone. Also worth mentioning is Holo Launcher, which does a great job of bringing the ICS launcher experience to non-ICS devices.
Have
something to say about our favourites? Is there another launcher you
think should be included in this list? Share your thoughts in the
comments below.

This tutorial is based on Ubuntu Lucid, but will work on later
releases as well with small changes. I will show how I stream my desktop
with audio from pulse and webcam from video4linux2. I will also show
how to configure crtmpserver and flowplayer so you can watch the live
stream from a web browser.
In this scenario I use separate host for the tools. Flowplayer is
installed on a server running Apache, crtmp server is on a separate
server and ffmpeg is installed on the streaming desktop.

2 Tools used

ffmpeg:
This is the audio and video encoder. I will use this to capture the
desktop with x11grab, audio from pulse and webcam from video4linux2. The
codecs used in this tutorial is libx264 for video and libfaac for
audio. The formal is flv and the output is a tcp unicast to the rtmp
server.
ffmpeg has great documentation, which can be found here.crtmpserver:
crtmpserver will use the flvplayback function to feed flowplayer the livestream. Documentation can be found here.flowplayer:
This is an open source flash player. We will use this to play the
rtmp live stream in a browser. An alternative is JW Player, but I stuck
with Flowplayer because of the great documentation found here.

3 Installation

ffmpeg:
You could either install ffmpeg from repository or compile it from
source. I highly recommend compiling it from source as the package in
ubuntu repository does not include all the features. In fact I believe
you wont be able to use this guide if you use the one from repository.
I will not include the installation guide here because there is a very
nice guide on ffmpegs website. Remember to follow the guide for the
distro you are using. I'm linking the Ubuntu 10.04 guide here.crtmpserver:
Again this is already documented so I will not include the installation guide here. Follow the instructions described here.flowplayer:
This is not really installed. You can choose to link to the player
from flowplayer's website, or download it to you webserver and link to
the path you place it. I recommend you download the player. For this
guide you will need the flowplayer, the api, the rtmp plugin and jquery.
For the player and the api look here. The rtmp plugin is found here, for Jquery look here.

4 Configuration

ffmpeg:
I wish to explain how each of the options I use work so that you get a
better understanding to how ffmpeg works, and also make it easier for
you to adapt it to your own need. I will first show the entire command,
then go into the options in more details

As you can see it looks quite daunting at first glance, but don't
worry, I will explain what everything does to the best of my extent, and
also provide links with further documentation.
The ffmpeg syntax goes like this:

ffmpeg "input-option" "input" "output options" "output"

Lets start with the first input pulse and its option:

-f alsa -i pulse

For more information on using alsa with ffmpeg look here.
Here we use alsa as the the format, and pulse as input. This will
grab audio from whatever source is active at the moment. If you install
Pulse Volume Controller, you can easily change the source by clicking
the recording tab and select what source you want to use.
So far so easy. The next input we have is our desktop:

-f x11grab -s 1680x1050 -r 30 -i :0.0+0,0

For more information on x11grab look here.
We select x11grab as the format with "-f x11grab". Then we decide how
large a portion of the display to grab with "-s 1680x1050". Third we
tell ffmpeg to force 30 frames per second with "-r 30", and lastly we
select the input, which is the 0.0 display starting at position 0,0 (top
left corner)
Next we will place the webcam as an overlay on top of the desktop. To
do this we use the feature avfilter. This is a very powerfull tool and i
will not go to much into detail on it. You can find all the
documentation you need here.

The options for -vf is enclosed in double quotes. First we set a name
for the input to be used, in this case "movie". This is just a name,
and you can choose whatever you want. The name is then defined with an
input, in our case the webcam.

"movie=/dev/video0:f=video4linux2

Next option is used to scale the input down to a certain size. I use
-1 to keep the original aspect ratio of the input, and set the width to
240 pixels.

scale=240:-1

I use the option fps to force a constant bitrate. I did this because I
had issued with the webcam lagging behind the desktop causing it to be
out of sync. It might not be necessary, but I have it there to be safe.
The last option is used to set the presentation timestamp on the input, starting with 0.

setpts=PTS-STARTPTS

This concludes the input options, and we close it of with [movie]; followed by [in][movie]
Here we place the actual overlay settings.

overlay=main_w-overlay_w-2:main_h-overlay_h-2 [out]"

This places the input as an overlay 2 pixels from the bottom right, and 2 pixels from bottom. We close it off with [out]
For more information on how the overlay works, look here.
We are done with all the input stuff, lets look at how we encode it.
I use libx264 for the video codec and libfaac for the audio codec.

As mentioned libx264 is my video codec of choice. "-crf 20" is the ratecontrol method, attemping to give a constant quality.
"-preset veryfast" is a one set of configuration, if you want to know more about it take a look here.
"-s 960x540" will set the output resolution. Increasing it will give
better quality, but also increase the bitrate and use more CPU to
encode.
I try to limit the bitrate between 150kb/s and 500kb/s. It will
still go over the maxrate if it needs it, but it will prevent huge
spikes

-acodec libfaac -ar 44100 -ab 96000

For audio I set the frequency to 44100 and the bitrate to 96k. This
gives me good enough quality and require less bandwidth and cpu.

"-threads 0" is an option to make use of all your CPUs. I believe its on by default, but it doesnt hurt to have it there
Now you could choose your output format and output and be done.
Unfortunetly for me I had to make a dirty workaround to be able to
record the session at the same time I'm streaming. The reason I can't
just use a second output is that it will not include the avfilter since
this applied only to the first output, and needs to be added to the
second output as well. This won't work because /dev/video0 is being used
by the first output (Device busy)
Therfore instead of outputting it as I normally would I output it to
standard out, use tee to grab everything and place it on a file, then
start a second ffmpeg session that use standard out as input, copies the
encoding and outputs it to the rtmp server.
If you don't need to record at the same time, just finish the command like this:

-f flv -metadata streamName=livestream tcp://x.x.y.y:1234

I use flv as the output format, since we will be using flvplayback on
the rtmp server. "-metadata streamName=livestream" sets the name for
the livestream. If we don't give it a name here, crtmpserver will choose
a random name, making it hard for us to specify the stream in
flowplayer.
Replace x.x.y.y with your crtmpserver ip adress and port number. I use 1234, you can use whatever you want really.
If you do indeed need to record, and don't find a more elegant
solution (please let me know if you do!) you need to be aware that when
you close ffmpeg, it will make the name.flv file unseekable. No worries
though, its an easy fix. Here's how I do it:

ffmpeg -i name.flv -codec copy -f mp4 name.mp4

This places everything in a new container, and when we are about it
why not place it in something better than flv! It's now seekable, but
unfortunately flowplayer will not be able to play the file before it is
fully buffered. This is because the mp4 format places the moov atom at
the end of the file
You can fix this using qt-fast start.
For this you need to have python installed.
Download qt-faststart with git:

git clone https://github.com/danielgtaylor/qtfaststart.git

To install use the setup.py script:

cd qtfaststartpython setup.py install

You can now use qtfaststart to move the moov atom to the beginning of the file like this:

qtfaststart input.mp4 output.mp4

This configuration is aiming at making a decent quality at low bit
rate. For presentations and slide-shows, the bitrate is about 200 kb/s
and the quality is very acceptable. When playing videos the bitrate goes
up to 1 mb/s. You can off course change these settings to fit your
needs
This concludes the ffmpeg configuration.crtmpserver:
When compiled navigate to /crtmpserver/builder/cmake/crtmpserver.
You need to edit crtmpserver.lua.
Find the part "description="FLV Playback Sample", under it is the acceptors you need to edit.

Insert this in the acceptor field, or edit the one already there. The
important thing here it to specify the same port you are using in
ffmpeg.
When done you can start the crtmpserver. Do this from the cmake folder.

cd .../crtmpserver/crtmpserver ./crtmpserver/crtmpserver.lua

If you get errors something is most likely wrong with the configuration file. If not you will be placed in the console.
More information here.
That concludes the crtmpserver configuration.flowplayer:
This can also be tricky, but luckily there are good documentation on the flowplayer site.
I'll only explain how to embed the player and use the rtmp plugin.
First off you need to add the path to flowplayer in the head:

I place the path to Jquery in the body:

I have a class called player with some fancy option to make it look a bit cooler.

I'm not going into detail of the class i'm using, you can make your
own class if you want to. The flowplayer needs to be inside a class
because it uses the width and heigth, without it you wont see it.
Now for the actual flowplayer configuration. The script must not be
within a div that has html inside it, so to be safe just place it in the
body.

Some important things here.

$f("stream", "flowplayer/flowplayer-3.2.11.swf", {

This defines the player, "stream" is the id we use to link it to a div class later on.
After this comes the configuration, there are four sections, but you only need clip and plugins.
In "play" I remove the buffer and play icon inside the player screen, as it's not really nessesary for a live stream.
In "clip" I set the url to livestream, this is the metadata we used
in ffmpeg. I tell Flowplayer its a live stream with "live: true,", make
the stream automatically start with "autoPlay: true,". The "provider:
'influxis'," is refered in the plugin section.
In "canvas" I set a background image so people will understand when the stream is offline
In "plugins" under the provider influxis i set the path to the rtmp
plugin with "url". The "netConnectionUrl" tells where our rtmp server
is. Remeber to include /flvplayback so that crtmpserver knows were to
look for the stream!
Now we can embed this in a div some place, or just in body like this:

Notice that I use the id="stream" here to link it up to the script we made earlier. It also uses the class player we made.
Now you should be able to start your ffmpeg command and watch the stream in your browser.

Conclusion

This tutorial became a bit longer that I expected, but I hope it
will help somebody out there. Please let me know if you find something I
did wrong, or if there are something that can be improved upon. Thanks
for reading!

Sunday, June 17, 2012

Last month I introduced the Yocto Project here on Linux.com with the catchy title Getting Started with Embedded Linux and the Yocto Project.
But despite the title, there was very little in that post that
described just how to get started. I'm here today to rectify that
situation.The best thing to do is to rely on the Yocto Project documentation, starting with the Yocto Project Quick Start Guide.
What follows below is a quick distillation of the information in the
Quick Start Guide, but it is highly recommended to read the whole
document before beginning. Of course, this is only the tip of the
iceberg for embedded Linux development.

Use a Linux desktop system as a host. The Yocto Project works best
with a major desktop distro like OpenSUSE, Fedora, CentOS, or Ubuntu,
but (theoretically) can be made to work with any Linux system. Make sure
to install all the necessary packages from the distro's repository -
see the Quick Start Guide for a list (scroll down to The Packages).

Alternatively, you can use the following command to get the same release using git:

git -b denzil git://git.yoctoproject.org/poky.git

In either case, you end up with the Yocto Project build tools, in the form of an instance of the Poky build system. Poky is a reference system for the Yocto Project - it is a working example of the Yocto Project in action.

Create a build directory and set up your working environment correctly with a single command:

source poky/oe-init-build-env build

This command sets environment variables, creates and populates a working directory called build as
a subdirectory of your current working directory, and makes this new
location your working directory. You are all set to build now... almost.

Set up the main build configuration file conf/local.conf for
your build. This is easier than it sounds. Simply edit that file and
look for the following configuration lines to change or uncomment. Set threads to
2x the number of cores in your host system - for a quad-core host, for
example, this number would be 8. This will greatly speed up your build
by taking advantage of all available processor cores.

The MACHINE setting specifies a familiar 32-bit Intel
architecture with a twist - it is set up automatically to use the QEMU
hardware emulator to run your new image without requiring any hardware.
Other supported values for this setting are shown in conf/local.conf, including qemuarm as well as a number of hardware architectures.

Build your distro. Note: this can take a while, as BitBake needs to
download all the packages it needs for this build, even though we are
just using the minimal system. Depending on the speed of your network
connection, this can take between 1.5 and 4 hours. Subsequent builds
only take about an hour.

bitbake core-image-minimal

Time to see the results! Boot your new image in a QEMU emulator. After the bootloader messages go past, log in using root, no password needed.

runqemu qemux86

And that's it! You have just built and run your embedded Linux
distribution. Next month we'll talk about variations on this process,
particularly using the Hob graphical interface. (For those who want to
read ahead, type hob in your build directory.) To see even more of this process in action, check out this video: Getting Started with the Yocto Project - New Developer Screencast Tutorial.

Thursday, June 14, 2012

This post is not about pointing out one OS’s security deficiency over
other or trying to make some fan boy points with Linux users. The simple fact is once you have physical access to a computer all bets are off.
This is true for all OS (to some extend) but some are easier to crack
than others. I won’t talk about how to protect yourself from this kind
of no-nonsense attack on this post, I will leave that for another day
but for now lets assume that you have a legitimate reason to reset yours
or your friends windows computer.

Prerequisite:

You need a linux live CD, preferably Ubuntu live CD. Doesn’t have to
be Ubuntu, it can be a custom linux live distro with the right packages
(the ones we need) installed. And you need to have the ability to boot
from CD. Which should be pretty straight forward.

Step 1:

Boot in to your live CD and install chntpw

Step 2:

Do cat /proc/mounts to get the label of your windows HD. In my case:

Or to put it more simply its: AC264F02264ECD50
cd to your media label: cd /media/AC264F02264ECD50
Now cd to to your system folder (windows 7): cd Windows/System32/config/

Step 3:

You will get a prompt and the options are self explanatory. For
instance to reset password enter “1” and then “y” to confirm. To change
password enter “2”, then your password, and “y” to confirm.
Done in 5 minutes (or so). This should work on all versions of windows since Windows2000.
You can also Reset Linux Root password in under 5 minutes and you don’t even need a livecd.

Monday, June 11, 2012

We are using NFS v4 server under RHEL
6.x+. How do I configure CacheFS for NFS under Red Hat Enterprise Linux
or CentOS to speed up file access and reduce load on our NFS server?

Linux
comes with CacheFS which is developed by David Howells. The Linux
CacheFS currently is designed to operate on Andrew File System and
Network File System. You need to install a package called cachefilesd
which is a CacheFiles userspace management daemon. The cachefilesd
daemon manages the caching files and directory that are used by network
filesystems such a AFS and NFS to do persistent caching to the local
disk.

dir /ssd/fscache - The
default directory is set to /var/cache/fscache. This directory act as
the root of the cache. In this example, my nfs client is mounted on
RAID-1 and cache is on single ssd disk at mounted at /ssd/. The cache is
good while reading files but I have way too many small files and it
causes the cache opposite. Particularly on slow harddrives. So I put
cache to another harddrive. If you can afford used ssd disks.

tag mycache
This command specifies a tag to FS-Cache to use in distinguishing
multiple caches. This is only required if more than one cache is
going to be used. The default is "CacheFiles".

secctx system_u:system_r:cachefiles_kernel_t:s0
- Specify an LSM security context as which the kernel will perform
operations to access the cache. The default is to use cachefilesd’s
security context. If you change the directory you need to use the these instructions to set new LSM security context.

brun 10%, bcull 7%, bstop 3%, frun 10%, fcull 7%, fstop 3%
- The cache may need culling occasionally to make space. This
involves discarding objects from the cache that have been used less
recently than anything else. Culling is based on the access time of
data objects. Empty directories are culled if not in use. See
cachefilesd.conf man page or this url for more information.

Step #4: How do I mount nfs client with CacheFS support?

You need to pass the fsc option to mount command as follows:

mount -t nfs -o fsc,optio2 nas01:/export/dir1/ /destination/mnt/point

In this example mount /var/www/html from nas042 on local /var/www/html using fsc (and other options) as follows:# mount -t nfs4 -o rsize=32768,wsize=32768,intr,hard,proto=tcp,sync,fsc nas042:/var/www/html /var/www/html

Thursday, June 7, 2012

Linux operating systems comes with
various set of tools allowing you to manipulate the Wireless Extensions
and monitor wireless networks. This is a list of tools used for wireless
network monitoring tools that can be used from your laptop or desktop
system to find out network speed, bit rate, signal quality/strength, and
much more.

#4: Configure a wireless network interface

iwconfig command is similar to ifconfig command,
but is dedicated to the Linux wireless interfaces. It is used to
manipulate the basic wireless parameters such as ssid, mode, channel,
bit rates, encryption key, power and much more. To display information
about wlan0 wireless interface, enter:

How do I find out link quality?

You
can get overall quality of the link. This may be based on the level of
contention or interference, the bit or frame error rate, how good the
received signal is, some timing synchronisation, or other hardware
metric.# iwconfig wlan0 | grep -i --color quality Sample outputs:

Link Quality=41/70 Signal level=-69 dBm

41/70 is is an aggregate value, and depends totally on the driver and hardware.

How do I find out signal level?

To
find out received signal strength (RSSI - how strong the received
signal is). This may be arbitrary units or dBm, iwconfig uses driver
meta information to interpret the raw value given by /proc/net/wireless
and display the proper unit or maximum value (using 8 bit arithmetic).
In Ad-Hoc mode, this may be undefined and you should use the iwspy
command.# iwconfig wlan0 | grep -i --color signal Sample outputs:

Link Quality=41/70 Signal level=-69 dBm

Some
parameters are only displayed in short/abbreviated form (such as
encryption). You need to use the iwlist command to get all the details.

#5: See link quality continuously on screen

You can use /proc/net/wireless file. The iwconfig will also display its content as described above.

Note: Again values will depend on the driver and the hardware
specifics, so you need to refer to your driver documentation for proper
interpretation of those values.

#6: Gnome NetworkManager

Fig:02: Gnome Network Manger

Gnome and many other Linux desktop operating system can use
NetworkManager to keep an active network connection available at all
times. he point of NetworkManager is to make networking configuration
and setup as painless and automatic as possible. This package contains a
systray applet for GNOME's notification area but it also works for
other desktop environments which provide a systray like KDE or XFCE. It
displays the available networks and allows to easily switch between
them. For encrypted networks it will prompt the user for the
key/passphrase and it can optionally store them in the gnome-keyring.
Please note that NetworkManager is configured through graphical interfaces, which are available for both GNOME and KDE.

#7: Say hello to wavemon

wavemon
is a ncurses-based monitoring application for wireless network devices.
It displays continuously updated information about signal levels as
well as wireless-specific and general network information. Currently,
wavemon can be used for monitoring devices supported by the wireless
extensions, included in kernels version 2.4 and higher. Just type the
following command to see the details:$ wavemon

Fig.03: wavemon - a wireless network monitor application for Linux

#8: Other options

You can use the following tools too:

Wicd
which stands for Wireless Interface Connection Daemon, is an open
source software utility to manage both wireless and wired networks for
Linux.

iwevent command displays Wireless Events
received through the RTNetlink socket. Each line displays the specific
Wireless Event which describes what has happened on the specified
wireless interface. Sample outputs from iwevents:

The following tutorial will teach Linux users how to install the Diablo 3 game on their open source operating system.

The third installment in the Diablo franchise, Diablo III, is a dark
horror/fantasy-themed role-playing game (RPG) developed and published by
Blizzard Entertainment.

The game features elements of the hack and slash, action RPG
and dungeon crawl genres. For more details about Diablo 3, you can check
out the official home page or the Wikipedia article.

Editor's note: For this guide, we have used the PlayOnLinux
application. We've tested the tutorial on the current 32-bit release of
the Ubuntu OS, 12.04 LTS (Precise Pangolin). Apparently, 64-bit users
will not be able to play the game, as there are some 32-bit OpenGL
libraries missing.

As a side note, make sure you meet the
minimum system requirements (especially the graphics card and CPU/RAM)
for playing Diablo III before going through the tutorial!

The PlayOnLinux developers provide binary packages and repositories for
many Linux operating systems, including Fedora, Debian, ArchLinux,
Frugalware and Ubuntu, as well as an universal binary package.

We can't write instructions for all these Linux distributions here, therefore if you use one of the aforementioned OSes, go HERE for detailed installation instructions.

Step 2 – Download Diablo 3

If you have bought the Diablo III DVD Edition, skip to the next step.
If you don't have the money to buy the DVD version and you only have a
Battle.net account with Diablo 3 registered to you, grab the installer
from HERE or from your Battle.net account.

Make sure you have Wine installed on your system. Save the exe file on
your desktop, right click on it and select the "Open With Wine Windows
Program Loader" option...

The Blizzard Downloader window will appear and the setup files will be
downloaded to a location of your choice. It's a big file, about 8 GB so
it will take a while, depending on your Internet connection speed. Also
make sure you have enough free space on the selected hard drive!

Step 3 – Install Diablo 3

Open PlayOnLinux and follow the first time instructions to setup the
application. Once these are finished, you'll see the PlayOnLinux
interface. Click the "Install" button and search Diablo on the new
opened window.

An installation window will appear. Click the "Next" button...

Select the installation method (the setup file – see Step 2 above, or the DVD disc you have bought). Click Next...

Wednesday, June 6, 2012

Vi is a powerful text editor included on most Linux systems. Many
people swear by vi and find it faster than any other editor once they’ve
learned its key bindings. You can even use vi key bindings in Bash.
We’ve already covered getting started with vi for beginners. If you haven’t used vi in a while, you might want to give that post a look to get a refresher on the basics.

Mode Switching

As a short recap, vi is a modal editor – there’s an insert mode and a
standard command mode. In insert mode, vi functions similar to a normal
text editor. In command mode, you take advantage of these key bindings.

i – Enter insert mode.

Escape – Leave insert mode. If you’re already in
command mode, Escape does nothing, so you can press Escape to ensure
you’re in command mode.

Moving the Cursor

Vi uses the hjkl keys to move the cursor in command
mode. Early computer systems didn’t always have arrow keys, so these
keys were used instead. One advantage of these keyboard shortcuts is
that you don’t have to move your fingers from the home row to use them.

h – Move cursor left.

j – Move cursor down.

k – Move cursor up.

l – Move cursor right.

You can also use search commands to quickly move the cursor.

/ – Type a / followed by some text you want to find
and press Enter to quickly move your cursor to the location of the text
in the file. For example, if you have the word iguana in your file,
type /iguana and press Enter to quickly move the cursor there.

? – Like /, but searches backwards.

f – Type an f followed by any character to quickly
move the cursor to the next occurrence of the character on the current
line. For example, if you have the line “Hello world” on a line and your
cursor is at the beginning of the line, type fo to move to the o in
Hello. Type fo again to move to the o in world.

F – Like f, but searches backwards.

% – Jump between the nearest (), [], or {} characters on the line.

Use these commands to quickly move to locations in the file:

H – Move cursor to highest (top) line in file.

M – Move cursor to middle line in file.

L – Move cursor to lowest (bottom) line in file.

#G – Type a number and then type G to go to that
line in the file. For example, type 4G and press Enter to move to the
fourth line in the file.

Moving between words:

w – Move forward a word.

#w – Move forward a number of words. For example, 2w moves forward two words.

b – Move back a word.

#b – Move back a number of words. For example, 3b moves back three words.

e – Move to end of the current word.

Copying & Pasting

Vi refers to the act of copying as “yanking.”

v – Press v and move the cursor to select a section of text.

y – Copy (yank) the selected text.

p – Paste at cursor.

x – Cuts the selected text. Cuts the character under the cursor if no text is selected

r – Type r and then type another character to replace the character under the cursor.

Combining Commands

Some commands – including the y and v commands above and the d (delete) command accept cursor motion commands.
For example, when you press d to delete some text, nothing will happen until you enter a cursor motion command. For example:

dw – Deletes the next word.

db – Deletes the previous word

de – Deletes to the end of the current word.

dL – Deletes all text below the cursor in the file.

d/unicorn – After pressing Enter, deletes all text between the cursor and the word “unicorn” in the current file.

dd – Deletes an entire line.

As you can see, the combination of combining a command with a cursor movement command is very powerful.

Repeat & Undo

Vi’s repeat command is very powerful, as it can repeat complex, combined commands.

u – Undo.

. – The . repeats the last full command. The
insert command also functions as a command here. For example, type
iunicorn and press Escape. You can then use the . key to insert the word
unicorn at the cursor.

Bonus: Using Vi Key Bindings in Bash

Once you’ve mastered the vi key bindings, you may want to use them
elsewhere on your system. No problem – you can set the Bash shell to use
vi-style key bindings.
Try this out in the current session by running the following command in a Bash terminal:

set -o vi

Bash will start in insert mode – press Escape to enter command mode and use these key bindings.
If you like this, you can add the command to your ~/.bashrc file and it will be automatically run each time you log in. Use the vi .bashrc command to open and edit the file in vi.
This isn’t a complete list of key bindings for vi, but it should help you flex your vi wings and learn to fly. This list of key bindings at Harvard’s website is more complete and has more information, although it’s less organized and harder to digest all at once.

Fedora 17
is a great GNU/Linux distribution, that initially needs some special
configuration to fully cover the everyday needs of a desktop user with
success. For legal and ideological reasons, people behind Fedora decide
that their creation should not support the out of the box playback of
mp3, movies etc. Moreover, Fedora doesn’t officially offer an easy to
use tool for the user to download the needed packages like other
distributions like Ubuntu and Linux Mint do. In this article we will see
how to download and install all the “extras”, easily and fast.

Applications and Codecs

What you will need first of all, is to
download an application called Autoplus. You won’t find it in the
official repositories, but you can download and install Autoplus by
using the following command:

This should install Autoplus in your system. If not, you can build it from source.

Now run Autoplus (Activities/Applications/System Tools) and you will see that everything you need is just two clicks away!

Autoplus offers to automatically
download and install the codecs needed to playback multimedia files like
mp3, plugins needed for optimum internet experience like Adobe Flash,
applications that are not present on the default repos like Google Earth
and even configure sudo usage for current user.

Graphics Driver

After you successfully installed
everything using Autoplus, you can proceed with installing the
proprietary closed source driver for your graphics card. Autoplus has
already added rpm-fusion repositories in your system, so to install the
graphics driver run Fedora’s “Add/Remove Software” and search for
“nvidia” if you use an Nvidia card, or Catalyst if you’re using an AMD
card. Choose the driver and press “apply”.

After the procedure finishes, you must open a terminal and run:

sudo nvidia-xconfig

Fonts

Now from the same application
(Add/Remove Software) search and install “gnome-tweak-tool”. You will
need this tool to configure the system font options. The default
Cantarell font is very improved, but still not as good as the Ubuntu
font. Download the Ubuntu font family,
and extract the zip on a folder you will create under your home
directory and name “.fonts”. Be aware that this folder will be hidden so
make sure you will setup nautilus to show hidden files (view/show
hidden files) before you create the folder.

Now open the “Advanced Settings”
application (that is the gnome-tweak-tool), and choose Ubuntu fonts,
slight Hinting and Rgba antialiasing

This should make your fonts look clearer and generally much better. Have a great time tweaking your new Fedora system!

PS: If you want to start theming your
desktop after all this, I suggest you install the gnome user themes
extension using yum and NOT the extensions website because in that case,
a python bug renders the Advanced System Settings unable to start.

Whether
you’re looking to upgrade an Android device forsaken by its
manufacturer or you just want more control over the phone or tablet you
own, a new ROM is often the way to go. Rooting your phone is the first
step, but a new ROM will give you a completely new mobile OS. This week
we’re going to look at five of the best Android ROMs. Photo by Peter Kirn.

It’s
important to note that not every ROM is available for every device, and
different ROMs are aimed at different audiences — some of them are
designed to upgrade the OS, and others are lean and mean installs to
speed up your phone. Whichever you choose, you’ll have to make sure your
device is supported by the developers behind the ROM before installing.

CyanogenMod
is arguably one of the most installed Android ROMs in the world. It
offers lots of great features, it’s available for more devices than most
other ROMs of its type, and it has a level of polish and support that
makes it easy to fall in love with.
There are builds of
CyanogenMod for Android phones and tablets, and slowly but surely the
developers behind CyanogenMod are rolling out Ice Cream Sandwich
versions for devices whose manufacturers have given up on upgrading the
device entirely. As well, CyanogenMod includes features you won’t find
in stock Android, like support for OpenVPN and downloadable themes, plus
more privacy tools. You can find a list of supported devices here.

The
Android Open Kang Project (AOKP) is a relative newcomer compared to
many of the other popular ROMs already available, but it’s rapidly
growing in popularity. It offers many of the features that CyanogenMod
does, and at first blush you may mistake one for the other. But as soon
as you start looking at the options and add-ons, you’ll see the
differences. AOKP has earned high marks for add-ons and tools that you
can’t get in CM, centralised control over ROM options and more overall
customisation options than CM. At the same time, its development
community is smaller, and it may not have the same polish and device
support that CyanogenMod has. Still, it’s super-fast, it’s stable and
definitely worth a look. You can find a list of all supported devices here.

MIUI struck us
with how beautiful the user interface was and how elegant it made
Android look and feel. It’s not the most feature-packed or hackable ROM,
but it’s definitely one of the most customisable and elegant, and it’s
seriously fast. MIUI started life as a modded version of Android
localised in China, but fans of the mod have since localised it for
dozens of languages and countries. It offers strong theme support,
beautiful stock apps, customisable lockscreens, support for GApps and
complete root access. You’re not going to get a wealth of niche features
here, but you will get a device that’s much easier and more fun to use
once you install MIUI. You can find a list of supported devices here.

If
you have a Galaxy Nexus, Nexus S, Samsung Galaxy S or Galaxy S II, Slim
ICS may be the ROM for you. Not only will Slim ICS bring your device up
to Ice Cream Sandwich, it’s also a super-thin, lightweight installation
that’s remarkably easy to install, even though it’s clearly aimed at
advanced users. Slim ICS already has GApps rolled in, so you don’t need
to install those later. Where other ROMs try to add lots of new features
and tweaking options, Slim ICS is designed to trim the fat down to the
bare essentials and give you a fast and clean ICS installation. It’s
only available for a handful of Samsung devices, and there’s pretty much
one developer and a few beta testers behind the scenes, so don’t expect
too many feature additions or new devices. However, it is updated
weekly and sports a good number of third-party mods.

Liquid
Smooth ROMS are available for multiple devices. While the project
started off with the Motorola Droid, Droid 2, Droid X, Droid Incredible
and HTC Thunderbolt, it’s also available for the Galaxy Nexus and a few
other devices, although you’ll have to poke around the forums a bit to
find them. The banner feature of Liquid is that it’s probably one of the
fastest ICS ROMs available — faster even than the stock install that
comes on the Galaxy Nexus. You don’t sacrifice features for the speed,
but the overall size of the ROM is still nice and small, leaving more
space for the apps and features you choose to use as opposed to ones
forced on you. GApps are baked right in, and the ROM offers theme
support so you can customise it to your liking. All in all, if you have a
supported device, it’s probably the leanest, meanest ICS ROM you can
download.
No honourable mentions this week, but there are well
over 60 different ROMs out there, so whatever ROM you settle on, make
sure it’s a good match for the features you’re looking for, the device
you own and the version of Android you want to run. These may be our top
five, but they may not be the best for your specific device, so do your
homework!
Have something to add? Did your favourite not get included? Share your thoughts in the comments below.

Abstract

Dojo mobile (dojox/mobile) is one of the most powerful JavaScript
frameworks that enable you to build cross mobiles web applications. It
does not only contain mobile components but also it mimics the interface
of the different mobile devices. Adding to this it responds to the
mobile orientations. In this article, I will illustrate how to use the
framework for building a weather application on the iPhone mobile.

Application Story

The application story is simple. In the weather mobile application,
the user can get the current weather forecasting of a specific location.
The user can do this by selecting one city from a list of available
cities in the drop down and then click the “Get Information” button to
get the weather information as shown in the screenshot below.

Building the weather application

In order to create the weather forecasting page, we need to know the main parts of the Dojo mobile page:

The Doc Type and META tags.

The mobile script and style includes.

The application pages.

The Doc Type and META Tags

The Doc type that is recommended to be used is the HTML5 doctype as shown below:

For the META tags, it is important to use the "viewport" META tag to setup cross-device layout as shown below:

The other important META tag is an iPhone specific one which is the
“apple-mobile-web-app-capable”. It is recommend to be set to “yes” to
make the web application runs in full-screen mode as shown below:

name="apple-mobile-web-app-capable"content="yes"/>

The script and style includes

Now, we come to the script and style includes. I’m using Dojo 1.7.1
for this application; in order to include the script and the style
files; this can be done as shown below:

I only included the iPhone CSS file, and the dojo.js file which is loaded asynchronously for including only the resources we need to keep the application optimized.
After including the script and the style, we need to use the require
statements for including the Dojo modules. I use the new Asynchronous
Modules (AMD) convention for making asynchronous loading of the modules
as shown below:

The "dojox/mobile/compat" module is required for allowing having cross mobiles CSS3 animations.

"dojo/domReady!" module is a replacement for the old dojo.ready API. The exclamation mark is required to tell Dojo not to execute the callback until the DOM is ready.

Finally in the callback, I’m using only the first parameter which is the parser object. The parser.parse statement is called for allowing the Dojo mobile parser to convert the HTML elements to Dojo mobile components.

The Application Pages

In our weather application, we have mainly two pages; the weather
forecasting page and the about page. In order to make the pages scroll
to the left and the right while navigation, we need to use the Dojo
mobile views. The Dojo mobile views are normal HTML elements with the
dojo type "dojox.mobile.View". To define the two views, we can do this as shown below:

id="weather"dojoType="dojox.mobile.View"selected="true">
...

id="about"dojoType="dojox.mobile.View">
...
The main view should be marked as selected by setting the selected attribute to "true".
In the weather forecasting page, there are three main elements:

Heading element.

Combo Box of the available cities.

The “Get Information” button.

In order to create the heading element, you can mark an HTML element h1 with the “dojox.mobile.Heading” dojo type as follows:

dojoType="dojox.mobile.Heading">Weather

dojoType="dojox.mobile.ToolBarButton"moveTo="about">About

I included a toolbar button for moving to the other view. The moveTo attribute can have the id of the view to switch to, in our case it is the about view id.
In order to create the combo box element, we need to use two tags, one for the data which is the dijit.form.DataList, and the other for the widget itself which is the dojox.mobile.ComboBox as follows:

The “location” combo box is referring to the “locationList” using the list attribute.
The “Get Information” button calls the getWeatherInformation function to get the weather information as follows:

The getWeatherInformation JavaScript function is calling a proxy Java Servlet that interacts with the Yahoo weather service API using dojo xhrGet.

The location value is read from the “location” combo box and the code
of the location is retrieved from a custom JavaScript Map that I
created for mapping the WOEID (Where on earth identification) to the
locations.
When the HTML response is returned from the server, it is displayed directly in the "weatherResult" span.
Finally in the weather forecasting view, I embed the combo box and the button in the "dojox.mobile.RoundRect" div as follows:

The other “about” view element is a simple one that contains description for the sample as follows:

id="about"dojoType="dojox.mobile.View">

dojoType="dojox.mobile.Heading"back="back"moveTo="weather">About

dojoType="dojox.mobile.RoundRect">This sample is developed by TechnicalAdvices.COM. It is powered by Dojo Mobile.

It contains a heading that includes a back button using the back attribute. The back attribute should be set to id of the view element that the application navigates to when the back button is clicked.
The next code listing shows the complete code of the weather forecasting page:

The Backend Java Servlet

Finally, the backend Java Servlet reads the WOEID parameter and opens
a URL connection to the yahoo API weather forecasting URL for getting
the weather forecasting of the location as shown in the code listing
below.

Conclusion

In this article, you learned how to build a mobile application using
the Dojo mobile APIs. You know how to use the framework views, headings,
and components for building the weather forecasting application.