Wednesday, March 26, 2014

NoClassDefFoundError

NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time.

Read more: http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-in.html#ixzz2x8LeYeww

Thursday, February 20, 2014

Wednesday, January 22, 2014

Extract value from string using regex in java

So suppose you want to extract values from a string based on a certain regex pattern. The thing that i didn't know was that I needed to use () around the data I wanted to capture.


Output
http://home.com
56

I dedicate this post to all laymen out there, who get confused with coding and stuff

Listen for text changes on EditText

Assume you want to enable a button only if some changes have been made to a form. You can do this by using android.text.TextWatcher
Simply create a new instance of TextWatcher and implement the required methods
There you have it. For more info checkout http://developer.android.com/reference/android/text/TextWatcher.html

Tuesday, January 21, 2014

The magic of grep and sed and xargs

You want to get all files that have a certain string

grep -rl "ToMatch" <folder>

You then want to replace that string with another string

grep -rl "ToMatch" | xargs sed -i s/ToMatch/Replaced/g

The xargs command passes the values from "grep -rl "ToMatch" <folder>" to the sed command as arguments

For more info on how to use xargs look at http://unixhelp.ed.ac.uk/CGI/man-cgi?xargs

Friday, January 17, 2014

Delete values from a map through a loop

So you woke up today and you want to delete values from a map, as you loop through the map (For whatever reason). So you right this is groovy

Code
Output
[a,b,c]
Wrong !!!!
You actually get a ConcurrentModificationException.... hahaha :D <- This is me laughing at you. So you need to