Skip to main content

Posts

Showing posts from March, 2012

Building xCode project and generating IPA file using Ant

Following is the procedure to generate IPA file. Under “project settings” change “derived data location” to “project-relative”, and make it "DerivedData/dist/". If you want any other location, change the same in the code. This will be the location where ".app" file and all other project info is stored. Set the values to the fields in CAPITAL LETTERS, and save the file as build.xml ----------------------------------------------- <project default="buildAndPackage" basedir="." name="APP-FOLDER"> <property name="local.projectPath" location="WHERE THE PROJECT IS LOCATED" /> <property name="local.ipaPath" location="WHERE TO SAVE THE IPA FILE" /> <property name="app.id" value="APP-ID" /> <property name="scheme" value="APP-SCHEME(MOSTLY APP-ID)" /> <property name="version" value="VERSION-NO" />

Integrating AdMob Ads in a PhoneGap Project (iOS)

Open the phonegap project to which AdMob is to be added. Import  GoogleAdMobAdsSDK which can be found here . Add  MessageUI.framework  to the project. To do this " click on project name , go to summary tab, scroll down to the framework section and click +. Then select MessageUI.framework ". In AppDelegate.h import "GADBannerView.h" and add "GADBannerView *bannerView_;" , so that it looks like@interface AppDelegate : PhoneGapDelegate { NSString* invokeString; GADBannerView *bannerView_; }  In AppDelegate.m –  #define MY_BANNER_UNIT_ID @”Your AdMob Publisher ID” Add the following code at the beginning of webViewDidFinishLoad:    bannerView_ = [[GADBannerView alloc]init]; [bannerView_ setDelegate:self]; [bannerView_ setFrame:CGRectMake(0, 45, 320, 95)];//Position of Ad banner bannerView_.adUnitID = MY_BANNER_UNIT_ID; bannerView_.rootViewController = self.viewController; [self.viewController.view addSubview:bannerView_]; [bannerView_ loadRequest:[

Auto-mount exFAT devices in Ubuntu

exFAT is natively supported by OSX and Windows (even XP!) the only thing was to make it work with Ubuntu. So here we go: Execute these commands one by one sudo add-apt-repository ppa:relan/exfat sudo apt-get update sudo apt-get install fuse-exfat Now we are able to manualy mount exFAT-formatted drives. To automate it we have to install couple more things: sudo apt-get install build-essential sudo apt-get install ncurses-dev sudo apt-get install util-linux Everything should be working nicely now Troubleshooting : If repository cannot be added: sudo -E add-apt-repository ppa:relan/exfat If install failed, because of fuse-utils: sudo apt-get install exfat-fuse exfat-utils

Anagram search from a file

// All the words are in the file Dictionary.txt import java.io.*; import java.util.*; public class Anag {     static String[] words;     public static void main(String args[]) throws IOException     {         Hashtable<String, List> ht;         try {             FileInputStream fstream = new FileInputStream("Dictionary.txt");             DataInputStream in = new DataInputStream(fstream);             BufferedReader br = new BufferedReader(new InputStreamReader(in));             List<String> lines = new ArrayList<String>();             String ele;             while ((ele = br.readLine()) != null)                 lines.add(ele);             words = lines.toArray(new String[lines.size()]);             in.close();         } catch (Exception e) {             System.err.println("Error: " + e.getMessage());         }         ht = getAnagrams();         BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));   

ChildBrowser Android

First you need to get ready with the phonegap running properly. It's here . First download the source from here Now follow these procedure:  1. To install the plugin, move  www/childbrowser.js  to your project's www folder and include a reference to it in your html file after phonegap<version>.js. <script type="text/javascript" charset="utf-8" src="phonegap<version>.js"></script> <script type="text/javascript" charset="utf-8" src="childbrowser.js"></script> 2. Copy the image files folder www/childbrowser to your project's www folder.Here you can edit the code or add any other files, but keep the folder named "ChildBrowser" as it is. Because, it is being referenced from others locations. 3. Create a directory within your project called " src/com/phonegap/plugins/childBrowser " and copy " src/com/phonegap/plugins/childBrowser/ChildBrowser.java &q

ChildBrowser iOS xCode

Today I tried to simplify the ChildBrowser execution in xCode, which I follwed earlier. To my surprise, I don't need to do anything rather than simply ignoring some steps. Here is the procedure: Download the ChildBrowser plugins here . Start xCode and create a phonegap-based application. 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: ChildBrowserCommand Type: String (default) Value: ChildBrowserCommand  You need to associate your external URLs on this page, too. In Supporting Files > PhoneGap.plist, add them under ExternalHosts, like: Key: Item 0 Type: String (default) Value:  * or whatever URL you are using in the code(* is enough) Right-click on the Plugins folder in Xcode and select to “Add Files to…” the folder. Navigate to the phonegap-plugins > iPhone > Childbrowser folder, and select the ChildBrowser folder. Check “Copy items into.

Josephus Problem using Queue

//Josephus.java //Out of  n members, every m'th person will be eliminated import java.io.*; //Stack--------------- class Node<T> {     T value;     Node<T> link; } class Stack<T> {     Node<T> top;     public Stack() {         top = null;     }     public void push(T item) {         Node<T> n = new Node<T>();         n.value = item;         n.link = top;         top = n;     }     public T pop() {         T item;         item = top.value;         Node<T> n = top;         n = null;         top = top.link;         return item;     }     public void display() {         Node<T> n = top;         System.out.print("(top)");         while (n != null) {             System.out.print(" ->" + n.value);             n = n.link;         }         System.out.println();     } } // Queue--------------------------- class Queue<T> {     Node<T> front, rear;     Stack<T>

Queue using Stack

import java.io.*; //Node--------------- class Node<T> {     T value;     Node<T> link; } // Stack--------------- class Stack<T> {     Node<T> top;     public Stack() {         top = null;     }     public void push(T item) {         Node<T> n = new Node<T>();         n.value = item;         n.link = top;         top = n;     }     public T pop() {         T item;         item = top.value;         Node<T> n = top;         n = null;         top = top.link;         return item;     }     public void display() {         Node<T> n = top;         System.out.print("(top)");         while (n != null) {             System.out.print(" ->" + n.value);             n = n.link;         }         System.out.println();     } } // Queue--------------------------- class Queue<T> {     Node<T> front, rear;     Stack<T> s1 = new Stack<T>();     Stack<T> s2 = new

Generic Stack

import java.io.*; class Node<T> {     T value;     Node<T> link; } class Stack<T> {     Node<T> top;     public Stack() {         top = null;     }     public void push(T item) {         Node<T> n = new Node<T>();         n.value = item;         n.link = top;         top = n;     }     public T pop() {         T item;         item = top.value;         Node<T> n = top;         n = null;         top = top.link;         return item;     }     public void display() {         Node<T> n = top;         System.out.print("(top)");         while (n != null) {             System.out.print(" ->" + n.value);             n = n.link;         }         System.out.println();     } }