Saturday, November 10, 2012

Thursday, November 8, 2012

B Tree Algorithms


Binary Tree a binary tree is a tree data structure in which each node has at most two child nodes

Binary Search Tree is a sorted node-based binary tree data structure which has the following properties

B-Tree The B-tree is a generalization of a binary search tree in that a node can have more than two children

B+ Tree The primary value of a B+ tree is in storing data for efficient retrieval in a block-oriented storage context—in particular, filesystems. This is primarily because unlike binary search trees, B+ trees have very high fanout (typically on the order of 100 or more), which reduces the number of I/O operations required to find an element in the tree.

B+ Tree are used by many file systems as well as DB's for internal storage.

Tuesday, November 6, 2012

Protocols of the Semantic Web

  1. Microformats
  2. Open Graph Protocol
    1. meta property="og:title" content="Take a Bite!" meta property="og:type" content="university" meta property="og:url" content="take-a-bite.org/" meta property="og:image" content="cookie.png" meta property="og:site_name" content="Take a Bite!" meta property="og:description" content="Today, most webpages use cookies to keep track of and identify its user. We want to change this. Help us by taking a bite. " meta property="fb:admins" content="677736282,659997616"

Monday, November 5, 2012

HTML5, JS mobile frameworks

There is a couple of choices out there when it comes to HTML5, Javascript mobile frameworks.

We have phone gap, and the-m-project which is based on phone gap. Both of these package up your web application into a in effect a wrapper for each of the mobile platforms, android, ios, ...

The appcelerator is completely different it actually builds native code from you javascript. This in my mind could be likened to something similar to GWT which converts java -> javascript.

Another good comparison.
http://www.infoq.com/research/cross-platform-mobile-tools?utm_source=infoqEmail&utm_medium=WeeklyNL_ResearchContent&utm_campaign=110612news
Seems phonegap is the most stable.

http://phonegap.com/

http://www.the-m-project.org/

http://www.appcelerator.com/

http://www.universalmind.com/mindshare/entry/mobile-html5-phonegap-vs-appcelerator-titanium

Intel Haswell

New power saving innovations on Haswell

The New Sleep States: S0ix

Panel Self Refresh Technology

Google Maps API Issues

Over the weekend I attended the DCWEEK Hackathon and while there developed an application that made heavy use of google maps. I ran into some issues when integrated jquery mobile and google maps, I found the following article after the fact that details alot of the problems I had.

The problems boil down to NOT having the div visible that the map will display into when google maps is initialized.

Solutions:


  1. Off-left technique
    1. .ui-tabs .ui-tabs-hide {
          position: absolute;
          left: -10000px;
      }
  2. Resize the map when idle
    1. The below can also be combined with a setTimeout, which I had to use to get it to work when deployed to a phone browser. HACK I know
    2. google.maps.event.addListenerOnce(map, 'idle', function() {
          google.maps.event.trigger(map, 'resize');
          map.setCenter(point); // be sure to reset the map center as well
      });
  3. Asynchronously Loading the API

http://stackoverflow.com/questions/1428178/problems-with-google-maps-api-v3-jquery-ui-tabs

Varnish Cache

Varnish Cache which allows you to cache dynamic and static content. It has a pretty easy configuration language allowing you to configure how to cache things such as user specific content as well as general dynamic content. Pretty sweet stuff if you need to scale out your site quickly.

https://www.varnish-cache.org/

http://devblog.factual.com/practical-guide-to-varnish

Mongodb Aggregation Examples

Provides the ability to write queries similar to using group by in SQL without using map-reduce.

http://docs.mongodb.org/manual/tutorial/aggregation-examples/

Friday, November 2, 2012

Microbenchmarking on the JVM and Long vs Int

While watching a video on lock free hashtables I noticed that you can use & instead of % and gain a performance bump. So I did some benchmarks. Turns out that with modern hardware (I am using a core i5) that the difference between & and modulo wasn't that big. What I found interesting though was when I tried to up the number of loop iterations I had to switch to a long which made a large difference. Seems that even on a 64bit architecture with a 64bit JVM a loop with a long as the iteration variable was significantly slower. Any ideas?


class blah {
    public static void main(String[] args) {
        System.out.println("Starting timing of modulo version. \n");
        long startTime = System.nanoTime();
      modulofunc();
      long endTime = System.nanoTime();

      long duration = endTime - startTime;
      System.out.println("Modulo version took " + duration + ". \n");
      
      System.out.println("Starting timing of and version. \n");
        startTime = System.nanoTime();
      andfunc();
      endTime = System.nanoTime();

      duration = endTime - startTime;
      System.out.println("And version took " + duration + ". \n");
      
      System.out.println("Starting timing of int version. \n");
        startTime = System.nanoTime();
      intfunc();
      endTime = System.nanoTime();

      duration = endTime - startTime;
      System.out.println("Int version took " + duration + ". \n");
      
      System.out.println("Starting timing of long version. \n");
        startTime = System.nanoTime();
      longfunc();
      endTime = System.nanoTime();

      duration = endTime - startTime;
      System.out.println("Long version took " + duration + ". \n");
    }

 static void modulofunc() {
   int s = 32;
   int e;
   for( int i = 0; i < 1_000_000_000; i++) {
     e = s % 7;
   }
 }
 
 static void andfunc() {
   int s = 32;
   int e;
   for( int i = 0; i < 1_000_000_000; i++) {
     e = s & 7;
   }
 }
 
 static void intfunc() {
   int s = 32;
   int e;
   for( int i = 0; i < 1_000_000_000; i++) {
     e = s & 7;
   }
 }
 
 static void longfunc() {
   int s = 32;
   int e;
   for( long i = 0; i < 1_000_000_000L; i++) {
     e = s & 7;
   }
 }
}

Lock-free replacement for java.util.Hashtable

Watched the below google tech talk of a lock free hashtable that uses compare-and-swap CAS instructions to achieve consistency when accessed by multiple threads. It is also a probing algorithm when it comes to collision resolution. What is interesting is how well it scales up when multiple threads are trying to write to it.

Google tech talk http://www.youtube.com/watch?v=HJ-719EGIts

http://sourceforge.net/projects/high-scale-lib/