Pages

Tuesday, November 11, 2014

Convert Timet to UTC

This piece of code gets the current time in UTC


SimpleDateFormat f = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
f.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(f.format(new Date()));




Thursday, October 17, 2013

Chance of winning powerball

 
Chance of winning powerball

Government statistics show there are about 1.7 automobile caused fatalities for every 100,000,000 vehicle-miles. If you drive one mile to the store to buy your lottery ticket and then return home, you have driven two miles. Thus the probability that you will join this statistical group is 2 x 1.7 / 100,000,000 = 0.000000034. This can also be stated as “One in 29,411,765-”.

Thus, if you drive to the store to buy your Powerball ticket, your chance of being killed (or killing someone else) is about 6 times greater than the chance that you will win the Powerball Jackpot.

Credits: taken from http://www.durangobill.com/PowerballOdds.html.


Sunday, July 28, 2013

Image binary to base 64

Found a nice link you can use to convert an image to base64 String.

http://base64.wutils.com/encoding-online/

Sunday, June 16, 2013

Design : The Golden Ratio

If you are designing anything, try using Golden Ratio (The divine proportion)  -

http://en.wikipedia.org/wiki/Golden_ratio

Heres a golden ratio calculator I found -
http://www.kostelijk.nl/thegoldenratiocalculator/index.php#formplace

Friday, April 19, 2013

Difference between Git pull & Fetch

I was wondering whats the difference between GIT fetch & Pull.

 Here you go -

  • When you use pull, Git tries to automatically do your work for you. It is context sensitive, so Git will merge any pulled commits into the branch you are currently working in. pull automatically merges the commits without letting you review them first. If you don’t closely manage your branches you may run into frequent conflicts.
  • When you fetch, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repository. However, it does not merge them with your current branch. This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use merge

Saturday, February 2, 2013

Google App Engine Roll back

find appcfg.sh

For me it was at


/Users/chapooty/Eclipse Juno/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.4/appengine-java-sdk-1.7.4/bin


then do

./appcfg.sh rollback /Users/chapooty/Documents/workspace//war


This will roll back the incomplete Google App Engine transaction & clean up errors.

Sunday, January 20, 2013

Delete Files Recursively in Java


Ive been looking for this code for sometime.

Deletes all files in a directory recursively.

void delete(File f) throws IOException {
  if (f.isDirectory()) {
File[] file =  f.listFiles();
if(file != null)
    for (File c : file)
      delete(c);
  }
  if (!f.delete())
  {
  Log.e(TAG, "Failed to delete file: " + f);
  }
  else
  {
  Log.i(TAG, "Deleted file: " + f);
  deleted++;
  }
 
}

If you want to delete Sd Card in Android,

File extStore = Environment.getExternalStorageDirectory();
call delete(extStore)

EnjoY!