Five Best Android Launchers

Posted by Unknown Rabu, 20 Juni 2012 0 komentar
http://www.lifehacker.com.au/2012/06/five-best-android-launchers


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.
Five Best Android Launchers

ADWLauncher EX

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.
Five Best Android Launchers

Nova Launcher

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.
Five Best Android Launchers

Go Launcher EX

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.
Five Best Android Launchers

Apex Launcher

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.
Five Best Android Launchers

Launcher Pro

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.

Baca Selengkapnya ....

Streaming Your Desktop With Audio And Webcam Overlay In A Browser Using ffmpeg, crtmpserver And Flowplayer

Posted by Unknown Selasa, 19 Juni 2012 0 komentar
http://www.howtoforge.com/streaming-your-desktop-with-audio-and-webcam-overlay-in-a-browser-using-ffmpeg-crtmpserver-and-flowplayer


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
ffmpeg -f alsa -i pulse -f x11grab -s 1680x1050 -r 30 -i :0.0+0,0 -vf "movie=/dev/video0:f=video4linux2, scale=240:-1, fps, setpts=PTS-STARTPTS [movie]; [in][movie] overlay=main_w-overlay_w-2:main_h-overlay_h-2 [out]" -vcodec libx264 -crf 20 -preset veryfast -minrate 150k -maxrate 500k -s 960x540 -acodec libfaac -ar 44100 -ab 96000 -threads 0 -f flv - | tee name.flv | ffmpeg -i - -codec copy -f flv -metadata streamName=livestream tcp://x.x.y.y:1234
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.
-vf "movie=/dev/video0:f=video4linux2, scale=240:-1, fps, setpts=PTS-STARTPTS [movie]; [in][movie] overlay=main_w-overlay_w-2:main_h-overlay_h-2 [out]"
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.
-vcodec libx264 -crf 20 -preset veryfast -minrate 150k -maxrate 500k -s 960x540
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 qtfaststart
python 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.
{
ip="0.0.0.0",
port=1234,
protocol="inboundLiveFlv",
waitForMetadata=true,
},
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!

Baca Selengkapnya ....

Embedded Linux Development in 6 Easy Steps

Posted by Unknown Minggu, 17 Juni 2012 0 komentar
https://www.linux.com/learn/tutorials/588534:embedded-linux-development-in-6-easy-steps


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.
Yocto LogoThe 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.
  1. 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).
  2. Download the Yocto Project tools by grabbing the gzip-ed tar file for the latest release, Poky 7.0 "Denzil", from the Yocto Project website download page, or from the command line as shown:
    wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.2/poky-denzil-7.0.tar.bz2; tar xvjf poky-denzil-7.0.tar.bz2
    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.
  3. 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.
  4. 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.
    BB_NUMBER_THREADS = "threads"
    PARALLEL_MAKE = "-j threads"
    MACHINE ?= "qemux86"
    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.
  5. 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
  6. 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.

Baca Selengkapnya ....

Reset Windows password with Linux in under 5 minutes

Posted by Unknown Kamis, 14 Juni 2012 0 komentar
http://www.slashgeek.net/2012/06/09/reset-windows-password-with-linux-in-under-5-minutes


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:

Change or reset windows admin password by running chntpw: sudo chntpw SAM
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.

Baca Selengkapnya ....

CentOS / RHEL CacheFS: Speed Up Network File System (NFS) File Access

Posted by Unknown Senin, 11 Juni 2012 0 komentar
http://www.cyberciti.biz/faq/centos-redhat-install-configure-cachefilesd-for-nfs


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.

Step #1: Install cachefilesd

Use the yum command to install cachefilesd - cacheFiles userspace management daemon:
# yum -y install cachefilesd
Sample outputs:
Loaded plugins: product-id, protectbase, rhnplugin, subscription-manager
Updating certificate-based repositories.
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package cachefilesd.x86_64 0:0.10.2-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================
Package Arch Version Repository Size
====================================================================================================
Installing:
cachefilesd x86_64 0.10.2-1.el6 rhel-x86_64-server-6 35 k
Transaction Summary
====================================================================================================
Install 1 Package(s)
Total download size: 35 k
Installed size: 0
Downloading Packages:
cachefilesd-0.10.2-1.el6.x86_64.rpm | 35 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : cachefilesd-0.10.2-1.el6.x86_64 1/1
Installed products updated.
Installed:
cachefilesd.x86_64 0:0.10.2-1.el6
Complete!

Step #2: Configure cachefilesd

You need to edit /etc/cachefilesd.conf, enter:
# vi /etc/cachefilesd.conf
Sample configuration file:
dir /ssd/fscache
tag mycache
brun 10%
bcull 7%
bstop 3%
frun 10%
fcull 7%
fstop 3%
# Assuming you're using SELinux with the default security policy included in
# this package
secctx system_u:system_r:cachefiles_kernel_t:s0
Where,
  • 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 #3: How do I start / stop / restart cachefilesd?

Simply type the following commands:
 
## start it ##
/sbin/service cachefilesd start
# or #
/etc/init.d/cachefilesd start
 
## stop it ##
/sbin/service cachefilesd stop
 
## restart it ##
/sbin/service cachefilesd restart
# or #
/etc/init.d/cachefilesd restart
 
## get status ##
/sbin/service cachefilesd status
 

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

Step #5: How do I verify that nfs client is working with CacheFS?

Cd to /ssd/fscache (or default /var/cache/fscache) directory and type the following command:
# cd /ssd/fscache
# ls -Z

Sample outputs:
drwx------. root root system_u:object_r:cachefiles_var_t:s0 cache
drwx------. root root system_u:object_r:cachefiles_var_t:s0 graveyard
When the cache is set up correctly, you will see two directories as above. You can type the following command to list files and cache size:
# find
# du -sh

Sample outputs:
142M

How do I see FS-Cache statistics?

Simply type the following command:
# cat /proc/fs/fscache/stats
Sample outputs:
FS-Cache statistics
Cookies: idx=30 dat=7895 spc=0
Objects: alc=7164 nal=0 avl=7164 ded=4261
ChkAux : non=0 ok=3727 upd=0 obs=3
Pages : mrk=59000 unc=37195
Acquire: n=7925 nul=0 noc=0 ok=7925 nbf=0 oom=0
Lookups: n=7164 neg=3429 pos=3735 crt=3429 tmo=0
Updates: n=0 nul=0 run=0
Relinqs: n=5022 nul=0 wcr=0 rtr=22
AttrChg: n=0 ok=0 nbf=0 oom=0 run=0
Allocs : n=0 ok=0 wt=0 nbf=0 int=0
Allocs : ops=0 owt=0 abt=0
Retrvls: n=7307 ok=3324 wt=1540 nod=3243 nbf=740 int=0 oom=0
Retrvls: ops=6567 owt=1672 abt=0
Stores : n=32683 ok=32683 agn=0 nbf=0 oom=0
Stores : ops=5842 run=38525 pgs=32683 rxd=32683 olm=0
VmScan : nos=181 gon=0 bsy=0 can=0
Ops : pend=1695 run=12409 enq=38525 can=0 rej=0
Ops : dfr=21 rel=12409 gc=21
CacheOp: alo=0 luo=0 luc=0 gro=0
CacheOp: upo=0 dro=0 pto=0 atc=0 syn=0
CacheOp: rap=0 ras=0 alp=0 als=0 wrp=0 ucp=0 dsp=0
You can see the caching state of individual mountpoints can be examined through other /proc files.
# cat /proc/fs/nfsfs/servers
Sample outputs:
NV SERVER   PORT USE HOSTNAME
v4 0a0a1d44 801 1 nas042
# cat /proc/fs/nfsfs/volumes
Sample outputs:
NV SERVER   PORT DEV     FSID              FSC
v4 0a0a1d44 801 0:20 147f55ffe88547d2 yes
Note down the output of the "FSC" column. It always says "yes" when the system has been asked to cache a particular NFS, and "no" when it hasn't.

How do I test CacheFS?

Copy files from NFS server to local hard drive:
 
time cp /path/to/nfs/mnt/point/bigfile.gz /tmp
 
#### this should speed up as bigfile.gz is in cache now #####
time cp /path/to/nfs/mnt/point/bigfile.gz /dev/null
 
In this example copy data.tar.bz2 (78MB) from nfs to /tmp (init cache):
$ time cp data.tar.bz2 /tmp
Sample outputs:
real 0m7.023s
user 0m0.000s
sys 0m0.185s
Copy data.tar.bz2 to /dev/null from NFS again (i.e. get it from cache):
$ time cp data.tar.bz2 /dev/null
Sample outputs:
real 0m0.027s
user 0m0.000s
sys 0m0.026s

See also:

  1. FS-Cache: A Network Filesystem Caching Facility by David Howells (PDF)
  2. man pages - mount, cachefilesd(8), cachefilesd.conf(5)


This FAQ entry is 14 of 14 in the "Linux / UNIX NFS File Server Tutorial" series. Keep reading the rest of the series:

Baca Selengkapnya ....

8 Linux Commands: To Find Out Wireless Network Speed, Signal Strength And Other Information

Posted by Unknown Kamis, 07 Juni 2012 0 komentar
http://www.cyberciti.biz/tips/linux-find-out-wireless-network-speed-signal-strength.html


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.

#1: Find out your wireless card chipset information

Type the following command to list installed wireless card, enter:
$ lspci
$ lspci | grep -i wireless
$ lspci | egrep -i --color 'wifi|wlan|wireless'

Sample outputs:
0c:00.0 Network controller: Intel Corporation Ultimate N WiFi Link 5300
Please note down the 0c:00.0.

#2: Find out wireless card driver information

Type the following command to get information about wireless card driver, enter:
$ lspci -vv -s 0c:00.0
Sample outputs:
0c:00.0 Network controller: Intel Corporation Ultimate N WiFi Link 5300
Subsystem: Intel Corporation Device 1121
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- SERR-
Kernel driver in use: iwlwifi

#3: Disabling wireless networking ( Wi-Fi )

You may want to disable Wi-Fi on all laptops as it poses a serious security risk to sensitive or classified systems and networks. You can easily disable Wi-Fi under Linux using the techniques described in this tutorial.

#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:
iwconfig Interface-Name-Here
iwconfig wlan0
Sample outputs:
wlan0     IEEE 802.11abgn  ESSID:"nixcraft5g"
Mode:Managed Frequency:5.18 GHz Access Point: 74:44:44:44:57:FC
Bit Rate=6 Mb/s Tx-Power=15 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=41/70 Signal level=-69 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:28 Missed beacon:0
In the above output iwconfig command shows lots of information:
  1. The name of the MAC protocol used
  2. ESSID (Network Name)
  3. The NWID
  4. The frequency (or channel)
  5. The sensitivity
  6. The mode of operation
  7. Access Point address
  8. The bit-rate
  9. The RTS threshold
  10. The fragmentation threshold
  11. The encryption key
  12. The power management settings

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.
 
cat /proc/net/wireless
 
Better use the watch (gnuwatch, bsdwatch) command to run cat command repeatedly, displaying wireless signal on screen:
 
watch -n 1 cat /proc/net/wireless
 
Sample outputs:
Linux watch wireless signal
Fig.01: Linux watch wireless signal with /proc file system

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


Gnome Network Manger
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
wavemon - a wireless network monitor application
Fig.03: wavemon - a wireless network monitor application for Linux

#8: Other options

You can use the following tools too:
  1. Wicd which stands for Wireless Interface Connection Daemon, is an open source software utility to manage both wireless and wired networks for Linux.
  2. 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:
    Waiting for Wireless Events from interfaces...
    07:11:57.124553 wlan0 Set Mode:Managed
    07:11:57.124621 wlan0 Set ESSID:off/any
    07:12:00.391527 wlan0 Scan request completed
    07:12:10.428741 wlan0 Scan request completed
    07:12:10.432618 wlan0 Set Mode:Managed
    07:12:10.432642 wlan0 Set ESSID:off/any
    07:12:10.432651 wlan0 Set Frequency:5.18 GHz (Channel 36)
    07:12:10.432722 wlan0 Set ESSID:"nixcraft5g"
    07:12:10.647943 wlan0 Association Response IEs:01088C129824B048606C2D1A7E081BFFFFFF00010000000000C20101000000000000000000003D16240D0000000000000000000000000000000000000000DD0
    07:12:10.648019 wlan0 New Access Point/Cell address:74:44:44:44:57:FC
    07:12:22.310182 wlan0 Scan request completed
  3. iwgetid command report ESSID, NWID or AP/Cell Address of wireless network. iwgetid is easier to integrate in various scripts. A sample output from iwgetid command:
    wlan0     ESSID:"nixcraft5g"
  4. iwlist command Get more detailed wireless information from a wireless interface. A typical usage is as follows:
    Usage: iwlist [interface] scanning [essid NNN] [last]
    [interface] frequency
    [interface] channel
    [interface] bitrate
    [interface] rate
    [interface] encryption
    [interface] keys
    [interface] power
    [interface] txpower
    [interface] retry
    [interface] ap
    [interface] accesspoints
    [interface] peers
    [interface] event
    [interface] auth
    [interface] wpakeys
    [interface] genie
    [interface] modulation

See also:

  • man pages iwlist, iw, iwconfig, iwgetid, iwevent, iwlist
  • Linux wireless wiki
Have a favorite wireless tool for Linux? Let's hear about it in the comments.

Baca Selengkapnya ....

How to Install Diablo 3 on Linux

Posted by Unknown 0 komentar
http://news.softpedia.com/news/How-to-Install-Diablo-3-on-Linux-273950.shtml

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!

To install Diablo 3 on your Linux system, follow the next step-by-step (with screenshots) tutorial.

Step 1 – Install PlayOnLinux

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...

Review image

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!

Review image

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.

Review image

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

Review image

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

Review image

We've used the downloadable setup file (see Step 2 above for details). Click Next...

Review image

Let the application download and install everything it needs for the Diablo 3 game. Click Next...

Review image

After it finishes installing the requirements, you will notice a small "Diablo III Setup" dialog pop-up, updating the setup files...

Review image

In a few seconds the small "Diablo III Setup" dialog will disappear and the Diablo 3 installer will appear. Click the big "Install" button...

Review image

Wait for the installation for finish. It will take a about 15-20 minutes.

Review image

Once the installation is over, you can click the big "Play" button to play the Diablo 3 game.

Review image

That's it! A shortcut icon of Diablo 3 will appear on your desktop and you can always start the game by double clicking it. Happy dungeon crawling!

Review image

If you encounter any issues with the tutorial, do not hesitate to use our commenting system below.

Baca Selengkapnya ....

Become a Vi Master by Learning These 30+ Key Bindings

Posted by Unknown Rabu, 06 Juni 2012 0 komentar
http://www.howtogeek.com/115051/become-a-vi-master-by-learning-these-30-key-bindings


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.

Baca Selengkapnya ....

Five Best Android ROMs

Posted by Unknown 0 komentar
http://www.lifehacker.com.au/2012/06/five-best-android-roms



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

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.

Android Open Kang Project (AOKP)

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

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.

Slim ICS

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

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.

Baca Selengkapnya ....

Fedora 17 – Install Codecs, Drivers and Fonts in under 5 minutes!

Posted by Unknown 0 komentar
http://www.unixmen.com/fedora-17-install-codecs-drivers-and-fonts-in-under-5-minutes


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:
su -c 'yum -y --nogpgcheck install http://dnmouse.org/autoplus-1.4-5.noarch.rpm'
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.
For questions please refer to our Q/A forum at : http://ask.unixmen.com 

Baca Selengkapnya ....

Developing Weather Application using Dojo Mobile

Posted by Unknown 0 komentar
http://www.technicaladvices.com/2012/05/31/developing-weather-application-using-dojo-mobile


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:
 name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
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:
 rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojox/mobile/themes/iphone/iphone.css" rel="stylesheet">

src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js" data-dojo-config="async: true">
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:
require(["dojox/mobile/parser", "dojo/_base/xhr", "dojox/mobile", "dojox/mobile/deviceTheme",
"dojox/mobile/TextBox", "dojox/mobile/Button", "dojox/mobile/compat",
"dijit/form/DataList", "dojox/mobile/ComboBox",
"dojo/domReady!"], function(parser) {

//...
parser
.parse();
});
The following modules are loaded:
  • The Dojo mobile parser "dojox/mobile/parser" for converting the HTML elements to Dojo mobile components.
  • The Dojo XHR module "dojo/_base/xhr" for allowing performing Ajax requests.
  • The Dojo mobile device theme "dojox/mobile/deviceTheme", for allowing detecting the mobile type and loading the proper theme correctly.
  • "dojox/mobile/TextBox", "dojox/mobile/Button", "dijit/form/DataList", "dojox/mobile/ComboBox", for loading the mentioned components.
  • 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:
 data-dojo-type="dijit.form.DataList" data-dojo-props="id:'locationList'" >
selected>Cairo, Egypt
Stockholm, Sweden
Vienna, Austria
Madrid, Spain
Paris, France
New York, USA
Lima, Peru


id="location" class="ninety" type="text" data-dojo-type="dojox.mobile.ComboBox" data-dojo-props="list:'locationList'" />
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:
 class="mblBlueButton full" dojoType="dojox.mobile.Button" onClick="getWeatherInformation();">Get Information
The getWeatherInformation JavaScript function is calling a proxy Java Servlet that interacts with the Yahoo weather service API using dojo xhrGet.
function getWeatherInformation() {
var selectedCode = cityMap[dijit.byId("location").value];

dojo
.xhrGet({
url
: "/mobileSamples/weatherProxyServlet?w=" + selectedCode,
handleAs
: "text",
load
: function(data) {
document
.getElementById("weatherResult").innerHTML = data;
}
});
}
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:
 dojoType="dojox.mobile.RoundRect" shadow="true">
for="txtLocation">Select location


data-dojo-type="dijit.form.DataList" data-dojo-props="id:'locationList'" >
selected>Cairo, Egypt
Stockholm, Sweden
Vienna, Austria
Madrid, Spain
Paris, France
New York, USA
Lima, Peru


id="location" class="ninety" type="text" data-dojo-type="dojox.mobile.ComboBox" data-dojo-props="list:'locationList'" />


class="mblBlueButton full" dojoType="dojox.mobile.Button" onClick="getWeatherInformation();">Get Information


id="weatherResult"/>
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:




name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
name="apple-mobile-web-app-capable" content="yes"/>
</span><span class="pln">Welcome to the weather application</span><span class="tag">

rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojox/mobile/themes/iphone/iphone.css" rel="stylesheet">
src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js" data-dojo-config="async: true">

type="text/javascript">
var cityMap = {};

require
(["dojox/mobile/parser", "dojo/_base/xhr", "dojox/mobile", "dojox/mobile/deviceTheme",
"dojox/mobile/TextBox", "dojox/mobile/Button", "dojox/mobile/compat",
"dijit/form/DataList", "dojox/mobile/ComboBox",
"dojo/domReady!"], function(parser) {

// initialize WOIDs ...
cityMap
["Cairo, Egypt"] = "1521894";
cityMap
["Stockholm, Sweden"] = "906057";
cityMap
["Vienna, Austria"] = "551801"
cityMap
["Madrid, Spain"] = "766273";
cityMap
["Paris, France"] = "615702";
cityMap
["New York, USA"] = "2459115";
cityMap
["Lima, Peru"] = "418440";

parser
.parse();
});

function getWeatherInformation() {
var selectedCode = cityMap[dijit.byId("location").value];

dojo
.xhrGet({
url
: "/mobileSamples/weatherProxyServlet?w=" + selectedCode,
handleAs
: "text",
load
: function(data) {
document
.getElementById("weatherResult").innerHTML = data;
}
});
}






id="weather" dojoType="dojox.mobile.View" selected="true">
dojoType="dojox.mobile.Heading">Weather
dojoType="dojox.mobile.ToolBarButton" moveTo="about">About


dojoType="dojox.mobile.RoundRect" shadow="true">
for="txtLocation">Select location


data-dojo-type="dijit.form.DataList" data-dojo-props="id:'locationList'" >
selected>Cairo, Egypt
Stockholm, Sweden
Vienna, Austria
Madrid, Spain
Paris, France
New York, USA
Lima, Peru


id="location" class="ninety" type="text" data-dojo-type="dojox.mobile.ComboBox" data-dojo-props="list:'locationList'" />


class="mblBlueButton full" dojoType="dojox.mobile.Button" onClick="getWeatherInformation();">Get Information


id="weatherResult"/>



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.



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.
package servlets;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;

/**
* WeatherProxyServlet is a proxy servlet that wraps Yahoo weather REST service.
* @author hazems
*
*/

public class WeatherProxyServlet extends HttpServlet {
private static final long serialVersionUID = 8732370454506907957L;

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

String WOEID = request.getParameter("w");
HttpURLConnection connection = null;

response
.setContentType("text/html");

PrintWriter writer = null;

try {
URL url
= new URL("http://weather.yahooapis.com/forecastrss?u=c&w=" + WOEID);

connection
= createHTTPConnection(url);

String output = getHTTPOutputResponse(connection);

SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new InputStreamReader(new ByteArrayInputStream(output.getBytes("UTF-8"))));

if (feed.getEntries() != null && feed.getEntries().size() > 0) {
SyndEntry entry = ((SyndEntry) feed.getEntries().get(0));

String title = entry.getTitle();
String description = entry.getDescription().getValue();

if (description.contains("Invalid")) {
throw new Exception(description);
}

writer
= response.getWriter();
writer
.print(title + "
"
+ description);
}
} catch (Exception exception) {
throw new ServletException(exception.getMessage());
} finally {
if (connection != null) {
connection
.disconnect();
}

if (writer != null) {
writer
.flush();
writer
.close();
}
}
}

private static HttpURLConnection createHTTPConnection(URL url) throws IOException, ProtocolException {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn
.setDoOutput(true);
conn
.setDoInput(true);
conn
.setRequestMethod("GET");
conn
.setRequestProperty("Accept", "text/html");
conn
.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

return conn;
}

private static String getHTTPOutputResponse(HttpURLConnection conn) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

String httpOutputResponse = "";
String outputLine;

while ((outputLine = br.readLine()) != null) {
httpOutputResponse
+= outputLine;
}

return httpOutputResponse;
}
}
You can try the application from your iPhone by going to the following URL:
http://www.mashups4jsf.com/mobileSamples/weather.jsp
You can download the complete Eclipse project from the following URL:
https://www.ibm.com/developerworks/mydeveloperworks/blogs/hazem/resource/29052012/mobileSamples.zip

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.

Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android blackberry.