Skip to main content


Showing posts from 2012

Logout using terminal / command line

If you ever find it difficult to find the logout button(sometimes happens - out of screen), run this command /usr/bin/gnome-session-save --logout or /usr/bin/gnome-session-save --force-logout

Create your own custom ROM for any Android device (from XDA)

Don't want to spend time reading? Have a look at the videos here You can find a detailed guide, which keeps on updating in this thread . This guide is for the one who have little experience with Android. Also covers some good advanced topics.

Meld: Comparison Tool

Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems. Meld helps you review code changes and understand patches. It might even help you to figure out what is going on in that merge you keep avoiding. Features Two- and three-way comparison between files and directories Comparisons update as you type Visualisations make it easier to compare your files Actions on diff chunks make for easier merges Supports Git, Bazaar, Mercurial, Subversion, etc. File comparison Edit files in-place, and your comparison updates on-the-fly Perform two- and three-way diffs and merges Easily navigate between differences and conflicts Visualise global and local differences with insertions, changes and conflicts marked Use the built-in regex text filtering to ignore uninter

OS X 10.8 Mountain Lion bootable USB (without MAC)

Download the raw file from here . How to use: 1 - Copy the .raw file to an USB stick using  SUSE Studio Image Writer . If you have error during copy, eject and re-connect the pen drive. When Windows asks if you want to format it, cancel and run Image Writer again. If the problem persists, disable your anti-virus software, it may be blocking raw write to the drive. Another Image Writer for Windows, if SUSE doesn't work 2 - Boot the USB drive and install. If you need, type  boot options , for example: -v (verbose boot) [default] -x (safe) -s (single user) GraphicsEnabler=yes (enable graphics card drivers) [default] USBBusFix=yes (fix problems with USB devices) npci=0x2000 (use if boot stops at "PCI configuration begin") cpus=1 If you need, use  TransMac  to remove kexts which are causing problems (System/Library/Extensions) and use the flag -f (ignore caches) at boot, or remove /System/Library/Ca

Boot Options

The boot: prompt waits for you to type advanced startup options. If you don't type anything, the computer continues starting up normally. It uses the kernel and configuration files on the startup device, which it also uses as the root device. Advanced startup options use the following syntax: [device]<kernel> [arguments] Example arguments include device: rd=<BSD device name>       (e.g. rd=disk0s2) rd=*<IODeviceTree path>    (e.g. rd=*/PCI0@0/CHN0@0/@0:1) kernel: kernel name                (e.g. "mach_kernel" - must be in "/" ) flags: -v (verbose)                -s (single user mode) -x (safe mode)              -f (ignore caches) -F (ignore "Kernel Flags" specified in boot configuration file) "Graphics Mode"="WIDTHxHEIGHTxDEPTH" (e.g. "1024x768x32") kernel flags                       (e.g. debug=0x144) io=0xffffffff                      (defined in IOKit/IOKitDebug.h) Example:

Multi-Booting Windows 7, Windows 8, Mac OS X Lion and Ubuntu

Getting Started Things you need: - Lion USB prepared with UniBeast (see - Win7 install media (preferably USB stick with Win7 SP1) - Win8 install media (USB stick) - Ubuntu 12.04LTS (USB stick) (see - A blank HDD or SSD ready as install target Section A (plan your partition scheme) When setting up a multi-boot system involving Windows it is important to realize you will need to create what is known as a hybrid MBR/GPT partition scheme.  It is necessary to place all partitions intended to be accessed by Windows such that they are in sync’d MBR table.  This means they should be placed first.  For this guide, I will be setting up the following partitions on a 320GB hard drive: EFI: 200MB, created by Mac OS X Disk Utility when partitioning Win7: ~60GB, NTFS Win8: ~60GB, NTFS Transfer: ~60GB, exFAT (could use FAT32 as well) Lion:~60GB, Mac OS X Extended (journaled) Linux-Swap: 8GB (my computer has 8GB memory) Linux: a bit less than 60GB (amount

JavaScript - Singleton Pattern

The singleton design pattern is probably the simplest and most common pattern in JavaScript. So why should you use the singleton pattern? Encapsulation of members & functions Creates its own Namespace A singleton is a single instance object Encourages code reuse Improves readability because you can logically organise your code The point of a singleton is to only have one instance. A shopping cart is a good example of something that you may want only a single instance of at one time. The simplest form of Singleton is an object literal. This loose form of Singleton cannot be instantiated. All of the members are now accessible through the Singleton variable, accessible through dot notation. var myCart = {     self: this ,     totalCost: 0,     totalQty: 0,     cart: {},     getCart: function (){ },     updateCart: function (){ } }; alert( "Total cost: $" + myCart.totalCost ); By using closures, we can create Private and Publi

HTML5 localStorage

Persistent Client-Side Key-Value Pairs The localStorage object has four primary method: localStorage. clear () localStorage. getItem ( key ) localStorage. removeItem ( key ) localStorage. setItem ( key, value ) When dealing with the localStorage object, it is important to remember that, like cookies, you are dealing with string values. Both the key and the value arguments must be strings. And, while the browser might not throw an error if you pass-in non-string values, you'll quickly find that it is simply calling the toString() method implicitly. Run the following sample code and check the console: <html> <head> <script type="text/javascript"> console.log("tim in localStorage —",("tim" in localStorage)); console.log("localStorage.getItem( tim ) —",localStorage.getItem( "tim" )); localStorage.setItem( "tim", "nice" ); localStorage[ "bad" ] = "awesome"

Download entire website from terminal using wget

This will help you to download entire website along with the links to other pages.i.e, you can almost browse the website offline. First install wget(if not present). Then run this from terminal. wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL –mirror : turn on options suitable for mirroring. -p : download all files that are necessary to properly display a given HTML page. –convert-links : after the download, convert the links in document for local viewing. -P ./LOCAL-DIR : save all the files and directories to the specified directory.

How to format USB or external drive in Ubuntu

If you could find the device on the Launcher, just right-click and select "format". Otherwise, see this.... You can use the disk utility(installed by default) to format the drive. There is an option 'format volume' select that option.

Taking Screenshots in Mac OS X

Command-Shift-3: Take a screenshot of the screen, and save it as a file on the desktop Command-Shift-4, then select an area: Take a screenshot of an area and save it as a file on the desktop Command-Shift-4, then space, then click a window: Take a screenshot of a window and save it as a file on the desktop Command-Control-Shift-3: Take a screenshot of the screen, and save it to the clipboard Command-Control-Shift-4, then select an area: Take a screenshot of an area and save it to the clipboard Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window and save it to the clipboard In Leopard and later, the following keys can be held down while selecting an area (via Command-Shift-4 or Command-Control-Shift-4): Space, to lock the size of the selected region and instead move it when the mouse moves Shift, to resize only one edge of the selected region Option, to resize the selected region with its center as the anchor point

Submitting Your App to AppStore

Submitting your app to the App Store is a multistep process involving several tools. First, create a distribution provisioning profile using iOS Provisioning Portal. Then create an archive, validate it, and submit it to the App Store using Xcode. When your app is approved, set the date the app will be available to customers using iTunes Connect. Finally, don’t forget to respond to user issues after you ship your first version. Before You Begin Before starting, you should have a distribution certificate and the status of your iTunes Connect app record should be “Waiting for Upload” or later, as described in  “Creating Your App Record in iTunes Connect.” Now, create a distribution provisioning profile using the iOS Provisioning Portal. Create a Distribution Provisioning Profile When the app is ready for publication, you create a distribution provisioning profile by selecting App Store as the method of distribution. The steps are similar to creating an ad hoc provisioning profil

Creating Your App Record in iTunes Connect

When an app is sold in the App Store, the store displays a lot of information about the app, including its name, a description, an icon, screenshots, and contact information for your company. To provide that information, you log in to iTunes Connect, create a record for the app, and complete some forms. In this chapter you learn how to go through this process. Note:  Normally, you create your iTunes Connect app record late in the development process because there’s a time limit from when you create the record to when you must submit your app. However, some Apple technologies, including Game Center and In-App Purchase, require that an iTunes Connect record to be created earlier. For example, with In-App Purchase, you need to create the app record so that you can add the details of the items you want to sell. This content needs to be created before the development process is complete so that you can use it to test the code you added to implement In-App Purchase. Before You Begin

Creating Distribution certificate

Before an app can be distributed, your team must have a valid distribution certificate linked to a distribution provisioning profile. Only team admins can create or install a distribution certificate. Each team can have only one active distribution certificate. The team admin can either use Xcode to create a distribution certificate or manually request and download one from iOS Provisioning Portal. A team’s distribution certificate allows a developer to build an app for distribution. If your team wants to use another Mac to create a distribution build, you need to transfer a copy of the distribution certificate as described in,  “Safeguarding and Transferring Your Signing and Provisioning Assets”  in  Tools Workflow Guide for iOS . Using Xcode to Create a Distribution Certificate You should use Xcode to create your distribution certificate. Xcode creates, downloads, and installs a development certificate, distribution certificate, and the iOS Team Provisioning Profile for you.

Change Keyring password

If you change your login password you might find that you get prompted for your "default keyring" password, this can be annoying, and sadly it isn't obvious how to change this to be the same as your new login password (or another password if you are being ultra secure!). Go to Passwords and Keys Click on the  Passwords  tab Right click over  Passwords: login Select  Change Password If you change your password to the same as your login password you won't get prompted for your default keyring password when you log in. Or else you can delete it

Building Your Application for Release using Eclipse ADT

After you finish configuring your application you can build it into a release-ready .apk fle that is signed and optimized. The JDK includes the tools for signing the .apk file (Keytool and Jarsigner); the Android SDK includes the tools for compiling and optimizing the .apk file. If you are using Eclipse with the ADT plugin or you are using the Ant build script from the command line, you can automate the entire build process. In preparation for signing your application, you must first ensure that you have a suitable private key with which to sign. Following Keytool command generates a private key: $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 Running the example command above, Keytool prompts you to provide passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called  my-release-key.keystore . The keystore and key are protected

Words formed by selecting one letter from each set (set combinations)

//Input 1,2   3,4,5  6  -1  each set is entered line-by-line //-1 is the end of input //output will be 136,146,156,236,246,256 import*; import java.util.*; import java.lang.String; import java.util.StringTokenizer; public class Possibilities {     public static void main(String[] args) throws IOException {         String s;         ArrayList<String> a1 = new ArrayList<String>();         BufferedReader br = new BufferedReader(new InputStreamReader(;         s = br.readLine();         if (!s.equals("-1"))             a1 = generatePossibilities(s);         System.out.println(a1);     }     public static ArrayList<String> generatePossibilities(String s)             throws IOException     {         ArrayList<String> a1 = new ArrayList<String>();         ArrayList<String> a2 = new ArrayList<String>();         ArrayList<String> a3 = new ArrayList<String>();         Buffered

Phonegap plugin for Ads on iPhone

I suppose you know how to create a Phonegap project and also how to add a plugin into the project. First download the required code from here . Add the "Ads" folder to your plugins list. To do this, right-click on the Plugins folder in Xcode and select to “Add Files to…” the folder. Navigate to the Ads folder, and select the folder. Check “Copy items into. . .” and “Create groups for. . .” A ChildBrowser folder is added to the Plugins folder. Copy the content of "js" folder to desired location. Then update the plist to use the plugin In Supporting Files > PhoneGap.plist, add under Plugins (click the down arrow to the left of Plugins, then click on the + symbol to open a new row): Key: SAiOSAdPlugin Type: String (default) Value: SAiOSAdPlugin See the "index.html" for initialization of the code. Now, to display the Ad, call "showTheAd(true)" and whenever you want to hide the Ad call "showTheAd(false)"

Google Plus +1 and share

This a html code that can be added to website to share some content on  GooglePlus You can use any image(but select a related one). By clicking on the image, content will be posted on the users G+ account. Consider the following samople code <a href="<LINK TO BE SHARED>" <img src="ANY IMAGE" /></a> Also the proper description will be posted, along with the link.

Shortest Job First Scheduling using HEAP

// Input is from the file "input.txt" in the form (a1,t1),(a2,t2),(a3,t3)  (arrival time, time to complete ie, burst time) import*; import java.util.*; public class SJFHeap {     static class point {         double time;         double run;         int no;         double total;         point(int i, double a, double b) {             no = i;             time = a;             run = b;             total = 0;         }     }     static class MHeap {         private point[] Heap;         private int maxsize;         private int size;         public MHeap(int max) {             maxsize = max;             Heap = new point[maxsize];             size = 0;         }         private int leftchild(int pos) {             return 2 * pos;         }         private int rightchild(int pos) {             return 2 * pos + 1;         }         private int parent(int pos) {             return pos / 2;         }         private boolean