Archives
- January 2020
- October 2018
- September 2018
- August 2018
- June 2018
- April 2018
- February 2018
- January 2018
- July 2017
- June 2017
- March 2017
- October 2016
- July 2016
- September 2015
- August 2015
- February 2015
- October 2014
- September 2014
- August 2014
- June 2014
- May 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- August 2013
- July 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
Meta
Categories
- add
- admob
- algorithm
- android
- app
- App Idea
- beagleboard xm
- BigQuery
- broken
- C++
- cakephp
- case-sensitive
- clone
- codeigniter
- coding
- composer
- coursera
- cross compile
- crosstool
- dbus
- default value
- dependency injection
- diff
- eclipse
- emulator
- error
- file
- forbidden
- fragment
- gdb
- git
- gitolite
- google maps
- inorder
- install
- interview
- java
- jQuery
- link
- linux
- marakana
- mongodb
- NFS
- not working
- php
- preferences
- preorder
- process
- pulseaudio
- push
- qnx
- qt
- rails
- refactored
- reference
- relink
- remote
- ruby
- ruby on rails
- ruby on rails tutorial
- server
- service
- singleton
- svn
- TDD
- topcoder
- tortoisesvn
- troubleshooting
- ubuntu
- UI properties
- undefined
- user
- v3
- virtualbox
- zend
Top Clicks
- None
Category Archives: Java
Json: sending/receiving Binary Data
You cannot just send raw binary data in JSON. You need to do a conversion first. The general way to encode binary data to a String is to use an implementation of Base64 encoding. Encode: String Base64.encodeToString(byteArray, Base64.DEFAULT); Decode: byte … Continue reading
Death of Singleton? Rise of Dependency Injection?
Was researching on the Singleton pattern and most articles on stack overflow were negative on the Singleton. link. What I got out of the discussions is that it’s really bad for developers who do TDD (test driven development). In the … Continue reading
Eclipse Shortcut: Open any file quickly without browsing for it (Ctrl + Shift + R)
I was watching Google IO videos and wondering how they could search and open file without using the package explorer. Turns out they were using this shortcut to find and open files. It’s really handy when you know the name … Continue reading
Posted in Coding, Eclipse IDE, Java
1 Comment
Addition, Subtraction, Multiplication using bit operators
The key for addition is to think about how numbers the carry works. You want to get the sum without worrying about caring, and then sum first (XOR), and then worry about the carry bit (AND << 1). // Iterative … Continue reading
Java: Comparator
Writing a Comparator for Integer for use with Arrays.sort: Arrays.sort(Integer[], new Comparator<Integer>() { public int compare(Integer a, Integer b) { if (function(a) != function(b)) return function(a)-function(b); } } Normal compare return values: if (a < b) return -1; if (a … Continue reading
Posted in Coding, Java
Leave a comment
Java: Quick Way to initialize arrays
Instead of: for (i = 0; i < array.length; i++) array[i] = <initValue> One can just do: Arrays.fill(array,<initValue>); Works for String[] at least.
Posted in Coding, Java, TopCoder
Leave a comment
Java: ArrayList.toArray() usage shortcut
Saw this pretty neat shortcut to get a List<T>[] to T[]. Usage: List<String> res = new ArrayList<String>(); String[] result = res.toArray(new String[res.size()]); I had originially seen this: String[] result = res.toArray(new String[0]); But supposedly using res.size() is better. StackOverflow
Posted in Coding, Java
Leave a comment
Regular Expressions
“1+1=2” How do I use Java’s String.split so + and = will be matched on? Regular Expression : \\+|= Forgot about the existence of the OR |. public static final String EQUATION_TEST = “1+1=2”; String[] str = EQUATION_TEST.split(“\\+|=”); System.out.println(“EQUATION_TEST.split=”+str.length);// Should … Continue reading
Java: JDBC Basics
Running through this tutorail: http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html Used JDBC before at Northrop figuring it out with working knowledge but never really went through a tutorial for it. Nice thing about the tutorial is that it populates a DB with data for you … Continue reading