Prash's Blog

Set up subversion on windows machine April 27, 2012

Filed under: Uncategorized — prazjain @ 10:53 pm
Tags: , , , ,

Today I setup Subversion on my home machine, after postponing it for ages.

Server : VisualSVN : Standard Edition Free

Client : TortoiseSVN

Client for Visual Studio : AnkhSVN

Installation of all of them was a breeze.

When setting up the server:

  • Set installation Dir like J:\documents\svnserver\
  • Set repository dir like J:\documents\svnserver\repositories
  • Use VisualSVN Manager to create a dir in repositories like First, this will also ask you to setup a user. For now setup a user : Test, password : Test
  • Create a project structure in repository directory First like MyFirstProject. This dir will then have 3 basic dir inside i.e. branch, tag, trunk.
  • Now navigate to repository directory on server, you will see a directory by name “First”.
  • Now create a directory “MyFirstProject” in “First” directory.
  • Navigate to the directory MyFirstProject in local file system, and add one file or number of files. Right click on MyFirstProject and go to TortoiseSVN import.


  • Choose trunk directory in svnserver and enter login details when asked, this will add these files to svn trunk for this project.


  • Navigate to any directory on local file system, right click and go to tortoiseSVN -> Repo Browser -> Enter the repo url -> right click on the directory you want to get, and choose checkout.




  • This will get all the code / files from that svn directory into your folder and you can now start working through svn and checkin-checkout files.

MySql Workbench Safe Update Mode : Updating table

Filed under: Uncategorized — prazjain @ 3:37 pm

MySql Workbench opens up in Safe update mode, that does not allow any updates to the tables.

To update tables, set this variable and you are good to go:



Removing HtmlUnit logs April 25, 2012

Filed under: Android — prazjain @ 6:46 pm
Tags: ,

HtmlUnit outputs a lot of logs on the console, and when my app was running for a few days straight, the log file size got huge and most of it was htmlunit log. I got rid of all the INFO logs, and all the WARNING logs were due to javascript error in the websites, so I set it to SEVERE.

In tomcat home directory, find logs/ file and add the following bits

org.apache.http.level = INFO
com.gargoylesoftware.htmlunit.level = SEVERE
com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.level = OFF = OFF = OFF
com.gargoylesoftware.htmlunit.html.HtmlScript.level = OFF


How to setup android emulator display for a phone

Filed under: Android — prazjain @ 11:41 am
Tags: , ,

I was facing a similar problem some time back, when I was writing an android app, and wanted to test it in the emulator with the display settings of the phone.

This is how I set up android emulator for samsung galaxy s2.

  • In Eclipse, go to Windows to start AVD Manager.
  • Select the AVD that you have created already, and click on edit.

  • Set resolution to 480 * 800. Click Edit AVD.

  • Click on Start. Select Scale display to real size. Set screen size to 4.3. For monitor dip, click on the “?”, enter your monitor’s Screen size and select its current resolution. Click ok. Click Launch.


Node.js error Error: Cannot find module XYZ April 24, 2012

Filed under: Nodejs — prazjain @ 9:45 am
Tags: ,

Generally you will see an error like this when a npm node package is not installed properly or not installed in proper location.
Error :

throw e; // process.nextTick error, or 'error' event on first tick
Error: Cannot find module 'XYZ'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)

In my case i have seen this happening when I have installed a node module using -g switch, so to fix this I would uninstall the module again and install it without -g switch as shown below :

npm install XYZ


Nodejs application to insert data into couchdb April 23, 2012

Filed under: Nodejs — prazjain @ 11:56 am
Tags: , , , ,

In this example, we will make a node application to add some data into couchdb.

  • First lets start couchdb by running this bat file on your machine : “C:\Program Files (x86)\Apache Software Foundation\CouchDB\bin\couchdb.bat” (I have Win 7, your path maybe different), if you have configured couchdb to not run as a service on your machine.
  • Create a database “geoexample” in couchdb through Futon here :
  • Lets get some geo data to insert in couchdb. Flickr is a good source for geotagged photos, so lets use that.┬áTo use flickr photos, first you need to signin into flickr (signup if you are not registered already). Once you are logged into flickr go to -> You -> Your Apps, then click on Get Another Key : Apply for non-commercial key, then Flickr will ask you the name and details of your application, go on add anything you like. When you submit you will get your api key, which we will use to import data from flickr.
  • Copy paste the url below into browser after replacing [YOUR-KEY] with your flickr api key :[YOUR-KEY]&text=holi&has_geo=true&extras=geo&per_page=1000&format=json&nojsoncallback=1

This will give you a JSON response, save it as “data.json”.

  • Create a directory geoex for our node app
mkdir geoex
cd geoex
  • Copy data.json into our geoex directory.
  • Install cradle module using npm, cradle is used to interact with CouchDB
npm install cradle

(I tried installing cradle with -g switch but I got the error as below when running the application, so i will not recommend using -g switch)

        throw e; // process.nextTick error, or 'error' event on first tick
    Error: Cannot find module 'cradle'
  • Create importflickr.js in geoex with code as below :
function importdata()
	var cradle = require("cradle"),
		sys = require("sys"),
		fs = require("fs");

	var connection = new (cradle.Connection)("localhost",5984);
	var db = connection.database('geoexample');

	data = fs.readFileSync("data.json","utf-8");

	flickr = JSON.parse(data);

	for(p in
		photo =[p];

		photo.geometry = {"type":"Point", "coordinates" : [photo.longitude, photo.latitude] };

		// save url to flickr image
		photo.image_url_small = "http://farm"""+photo.server+"/""_"+photo.secret+"_s.jpg";,photo,function(er,ok)
				if (er) {sys.puts("error: " + er); return; }
exports.importdata = importdata;

  • Create index.js with following code
var http = require("http");
var url = require("url");
var importd = require("./importflickr");

function onRequest(request, response)
	var pathname = url.parse(request.url).pathname;
	console.log("Request for " + pathname + " received.");
		response.write("Imported the data from flickr into couchdb");
console.log("Server has started.");

  • This shall be all that is required, run your app
node index.js

How to set Android App orientation on startup April 21, 2012

Filed under: Android — prazjain @ 5:50 pm

While coding one of the android app, i overwrote OnConfigurationChanged method to change the app orientation when user changes orientation. But there was a problem if the user starts the app in landscape mode, my app would by default still load in portrait mode. So add this little bit of code to check the orientation when you start your app and set the it accordingly.

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) 
        Configuration conf = this.getResources().getConfiguration();
    	if (conf.orientation== Configuration.ORIENTATION_LANDSCAPE)
    	else if (conf.orientation== Configuration.ORIENTATION_PORTRAIT)