Wednesday, January 30, 2013

Facebook Graph Search - some interesting queries

today I got approved by Facebook to use their graph search.

I played with it a bit and found it very useful in exploring the unknown/unexplored.

here are few of them:

1. Friends of friends who like to dance



2. Friends of my friends who live in San Francisco, California and work at Google



3.  This time, I'm looking for anyone who love playing cricket but is from my city. (I'm big fan of cricket so need to find more players)

"People who like Cricket and live in San Jose, California"



4. looking for job and willing to apply to company 'A'? you need to explore 1st, 2nd degree of connections to work in that company

"Friends of my friends who work at Google "



5. Facebook doesn't understand what is what - they seems to be missing natural language processing and I hope they know it and are working to improve it.

 



 

Graph Search if used cleverly, it could provide lots of insite into what we need.

 

that's all folks!

 

 

Amazing Page Architecture - Measuring the thickness of the web pages

disclaimer: i'm not css/html expert.

I believe that browsers render web pages in x,y co-ordinates (width, height) however they also keep the z-index. The z-index is somewhat controlled by css code. The performance of the page rendering is also controlled by how deep the content is i.e. depth of the displayable html element. Performance degrades as we move the elements deep inside the container elements. e.g.

<div><div><div><h3>hello world!</h3></div></div></div>

Some javascript operations (which operates on DOM structure internally, e.g. getelementbyid), also get affected by how deep the target element lies as it needs to traverse through the DOM tree.

Figuring out the depth of the element in the static html is easy however when it comes to browser, it all depends on how we generate final html code, using javascript,css as Dynamic Html. In this case the final view of the html codebase can be viewed only by the browser's internal memory.

I tried to play with the browser ('Firefox') tool and found very interesting web page architectures (because they look like amazing colorful physical designs) of google and HN home pages.

feel free to explore the gallery below:

[gallery link="file"]

Friday, January 18, 2013

Getting started with Cassandra on Windows

Running Cassandra on Windows: step by step presentation

...follow below steps to successfully setup and run sample test case...

1. Download Cassandra from http://cassandra.apache.org/download/​

2. unzip under C:\cassandra\apache-cassandra-0.7.8

3. set CASSANDRA_HOME=C:\cassandra\apache-cassandra-0.7.8 and make sure JAVA_HOME​ is already set.

4. modify config/cassandra.yaml

  and change all the directories to windows. e.g.
--------------------------------------------------------------------------------

data_file_directories:

- C:/tools/apache-cassandra-0.7.8/data/data
commitlog_directory: C:/tools/apache-cassandra-0.7.8/data/commitlog

saved_caches_directory: C:/tools/apache-cassandra-0.7.8/data/saved_caches

--------------------------------------------------------------------------------


now create below folders under C:/tools/apache-cassandra-0.7.8/data/:

 

callouts, bootstrap, staging, saved_caches, commitlog, data

-these folders are used for diferent purposes.

5. run cassandra.bat  - it runs cassandra server

6. run cassandra-cli.bat -it runs client console

execute below in client console:
__________________________________________

get sample user details from config/password.properties

e.g.   jsmith=havebadpass

connect using connect 127.0.0.1/9160

or

connect 127.0.0.1/9160  jsmith 'havebadpass';

or

c:\cassandra\apache-cassandra-0.7.8\bin>cassandra-cli.bat  --host localhost

----------------------------------------------------------------------------------------

 

Starting Cassandra Client

Welcome to cassandra CLI.

Type 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit.

[default@unknown] 

===========Connect to Cassandra server===============

[default@unknown] connect 127.0.0.1/9160  jsmith 'havebadpass';

Connected to: "Test Cluster" on 127.0.0.1/9160

[jsmith@unknown] connect 127.0.0.1/9160;

Connected to: "Test Cluster" on 127.0.0.1/9160

===========Create KeySpace===============

[jsmith@unknown] create keyspace Twissandra;

b97c69f2-bc7c-11e0-84c7-e700f669bcfc

Waiting for schema agreement...

... schemas agree across the cluster

===========Set KeySpace===============

[jsmith@unknown] use Twissandra;

Authenticated to keyspace: Twissandra

===========Create Column Family 'user'===============

[default@Twissandra] create column family User with comparator = UTF8Type;

c273cb23-bc7c-11e0-84c7-e700f669bcfc

Waiting for schema agreement...

... schemas agree across the cluster

===========Insert Sample User 'jsmith'===============

[default@Twissandra] set User['jsmith']['first'] = 'John';

Value inserted.

===========Fetch Sample User 'jsmith'===============

[default@Twissandra]  get User['jsmith'];

=> (column=first, value=4a6f686e, timestamp=1312230501056000)

Returned 1 results.

[default@Twissandra]

----------------------------------------------------------------------------------------​

__________________________________________

 

More details on executing sample queries can be found at:http://wiki.apache.org/cassandra/CassandraCli

Or you could refer my previous post @ useful-bookmarks-on-cassandra

 

Tuesday, January 15, 2013

Why Java will be dominating language in 2013

Here are the few developments which might outshine other languages:

1. Java SE 8


Java 8 is expected in September 2013 and will include at a minimum the features that were planned for Java 7 but later deferred.

  • Language-level support for lambda expressions (officially, lambda expressions; unofficially, closures) under Project Lambda.There was an ongoing debate in the Java community on whether to add support for lambda expressions. Sun later declared that lambda expressions would be included in Java and asked for community input to refine the feature.

  • Parts of project Coin that are not included in Java 7

  • JSR 310: Date and Time API

  • Tight integration with JavaFX


2. Powerful JVM languages


Year 2012 was the start of JVM languages where Scala picked up pretty well. There are positive development on Akka, Play 2.0, Groovy, Closure, JRuby and Kotlin. It all depends on the developers and how the consolidation and adoption of these languages will look like in 2013.

3. Integration of JavaScript in Java language


OpenJDK will be integrating JavaScript in Java SDK and will make it part of Java 8. There are chances that Node.js will get entry into this development.

4. Improved performance with GPU


OpenJDK has initiative/project (Sumatra) which tries to improve the performance by utilizing GPU.

5. Java in the cloud


With the advent of frameworks like IaaS and PaaS, there is possibility of introducing jcloud in Java SE8. There might be more 3rd party cloud providers in supporting the java in the cloud.

 

 

Useful bookmarks on Cassandra

Cassandra Links...


Sunday, January 13, 2013

How to take screenshot on Mac Book Air / Pro laptops

Here are the 3 different ways (by Anson Alexandar) to take screenshot on Mac laptops.

1. Whole Screen, press "Command + Shift + 3": it takes screenshot of whole screen

2. A region on the screen, press "Command + Shift + 4": changes mouse pointer which helps to select a specific region of the screen and takes snapshot when mouse click is released

3. A window, press "Command + Shift + 4 + Space Bar": changes mouse pointer to camera icon. now click on any window and it takes snapshot of that window

 

Note that these screenshots will get saved on desktop.

getting started with GIT - an introduction


Git is an open source distributed version control system.



The screen shots were taken from youtube presentation by Scott Chacon.



Traditional version control systems used to have a single storage where all the developers used to connect and operate. This lead to a single point of failure.



In git, there is no single server which maintains the history. All parties/developers's machine become node in the distributed system and they can work in isolated fashion as well. Basically the system behaves as loosely coupled.



Below is the comparison between traditional VCS and Git. Git stores the file contents along with the checksum which relieves it from managing the change log and plenty of indirected connections between file versions.


Git stores all the checksum as directed graph which helps it easily identify what and how to merge code.



Below are the basic commands for doing any file modifications:



when we do 'git checkout' it creates index database and then creates a local directory where stores all the contents. Running 'git add' puts the file contents along with the checksum in the Index database. The final 'git commit' does a commit from Index database to local repository. Note that 'commit' doesn't look at the local files, it only looks at Index database for final commit to repository. What it means is after doing 'add', we can delete the local file however 'commit' will still continue without loosing the change.



Merging: git does merging by looking at the changes between current branch 'master' and the branch to be merged 'branchA'. It basically walks through the directed graph and tries to find the common ancestor. If found then it does a fast-forward merge which means it moves the head pointer to 'branchA'.


Simple merge (fast forward). merge of branch iss53:






Simple delete: if Head can reach the branch directly then it deletes else skips. so it has a safety mechanism.


git branch -d iss53



i18n can't be reached from head so using below command forcefully deletes it. Hard delete.


git branch -D i18n



steps of code push.


scott pushes the change



git does a fast-forward merge in origin master repo because it sees a common ancestor between origin master and scott's master.



Now Nick tries to push but that will fail as origin master in Nic's local repo and in origin remote repo are pointing to different commit versions.


so Nick does a 'git fetch' first.



then he does merge. because (pull = fetch + merge).



now things look good and origin master points to right commit version. and hence the collaborated delivery completed gracefully,



How to create Aliases?



Git subsets




answer is: git log i18n ^master



What is the change in iss53 which is not in i18n?



answer is the highlighted commit histories:





...Quizes...


Git Incoming? its the change which is in origin/master and not in local master. solution: fetch will pull in the change.


here is how to check what changes we are missing in local:


git log origin/master ^master


Git outgoing? its the change which is in local master and still not got pushed to origin/master. solution: git push will deliver the change


here is how to check what changes we still did not merge to origin/master from local:


git log master ^origin/master

Friday, January 11, 2013

Which is bigger e^pi or pi^e? - a mathematical approach

Here are the mathematical definitions of e and π (pi):

e = 1 + \frac{1}{1} + \frac{1}{1\cdot 2} + \frac{1}{1\cdot 2\cdot 3} + \frac{1}{1\cdot 2\cdot 3\cdot 4}+\cdots
π = Pi = 22/7  (22/7 is approximate value of pi more accurate value is 355/113)

Now we will take mathematical approach in solving the equality problem.

Lets Assume pi^e > e^pi

now taking natural log (Log of base e) on both sides.

Log (pi^e) > Log (e^pi)

eLog(pi) > piLog(e)

eLog(pi) > pi          ---> Log e is 1 because its Log of base e. (LOGe(e) = 1)

Log(pi) > pi/e

since we know that Pi > 1 and hence Log(pi) >1,

then above becomes
1 > pi/e
e > pi        - which is false  (pi = 3.14, e = 2.72)

Therefore our assumption (pi^e > e^pi) is not correct

hence pi^e  is less than e^pi.

Thursday, January 10, 2013

Add Application to Windows context menu

Adding an Application to the Right Click on Every Folder

Here is how to add any application to the Context Menu when you right click on any Folder. This way you do not have to always go to the Start Menu. When you right click on any folder, you can have access to that application, the same as using Sent To.

1. Open RegEdit
2. Go to HKEY_CLASSES_ROOT\Folder\shell
3. Add a new Key to the "Shell" Key and name it anything you like.
4. Give it a default value that will appear when you right click a folder, i.e. NewKey (use an "&" without the quotes, in front of any character and it will allow you to use the keyboard)
5. Click on the Key HKEY_CLASSES_ROOT\Folder\shell\NewKey
6. Add a New Key named Command
7. Set the (Default) value of the application you want to run
8. For example: c:\program files\internet explorer\iexplore.exe (Include the full path and parameters if you need them)

right_click.png

 

Saturday, January 5, 2013

How a computer scientist failed in solving Fermat Theorem?

Fermat's last theorem was "states that no three positive integers a, b, and c can satisfy the equation a^n + b^n = c^n for any integer value of n greater than two".



here is the puzzle:

A computer scientist claims that he proved Fermat theorem is correct for the following 3 numbers:

x=2233445566, y=7788990011, z=9988776655

He declared that the below equation satisfies for N:
x^N + y^N = z^N

Later the scientist was proved wrong by a 10 year old kid. How come he do that even without the help of the computers?

Here is the solution:

x=2233445566, y=7788990011, z=9988776655

square the last digits of each numbers and notice that the last digit of the result remains same.
which proves that for any value of N, the last digits remains same.

6 * 6 = 36 , 1 * 1 = 1 , 5 * 5 = 25

hence x^N ends with 6,  y^N ends with 1,  z^N ends with 5

try out the equality with the last digits:  6 + 1 != 5

this proves that the values of x,y and z doesn't satisfy Fermat's theorem.