Wednesday, 15 October 2014


After writing and loading JSON files several times to record and read a object of tree structure, I found it quite difficult to minimize the size of the JSON files because some floating point number in the object is printed to character and take up more memory space.  Google for few seconds, I found a solution to save files more efficiently. Surprisingly it is easy solution from Pickle is going to save my file and my sleeping time as well. Here is the solution.

To record the object to file:

import pickle
pickleFile = open('root.pickle', 'wb')
pickle.dump(root, pickleFile, pickle.HIGHEST_PROTOCOL)

To read the file to the object:

pickleFile = open('root.pickle', 'rb')
root = pickle.load(pickleFile)



Thursday, 9 October 2014

Top programming languages

What is the best programming language? A IEEE spectrum article on top list programming gave a good conclusion. Java seems to be the top and widely used. C/C++ has long history and become standard for low level application for embedded systems. Python is at the 4th for the web application. I personally like Python because it easy to maintain and fast coding!

top 10 progamming langauage Top 10 Programming Languages to Learn

I also did a diagram according to technology of some popular websites by simply extract the words in columns and put them in D3 wordcloud

“Front-end”, “Back-end”, Database, JavaScript, C, C++, Go, Java, Python, BigTable, JavaScript, Hack, PHP, C++, Java, Python, Erlang,  D, Xhp, MySQL, HBase, Flash, JavaScript, C, C++, Python, Java, MySQL, BigTable, JavaScript, JavaScript,  PHP, MySQL, PostgreSQL, JavaScript, ASP.NET, “Microsoft_SQL_Server”, JavaScript, ASP.NET, “Microsoft_SQL_Server”, JavaScript, PHP, MySQL, MariaDB, JavaScript, Python, BigTable, JavaScript, ASP.NET, “Microsoft_SQL_Server”, JavaScript, C++, Java, Scala, Ruby, Rails, MySQL, JavaScript, PHP, MySQL, JavaScript, Java, C++, Perl, JavaScript, Java, JavaScript, “Oracle_Database”, JavaScript, Java, JavaScript, Scala, JavaScript, C# , ASP.NET, MVC, “Microsoft_SQL_Server” 

Friday, 3 October 2014

test ipython.parallel

from IPython import parallel
c = parallel.Client(packer='pickle')
c.block = True

dview = c.direct_view()
dview.block = True

dview.execute('import numpy as np')

###using execute

###using run
f.write('import numpy as np\nb=np.zeros(shape=(1,4),dtype=np.int32)')
print type(dview.gather('b')[0,0])

###using dictionary
print type(dview.gather('c')[0,0])

[0, 1, 2]
<DirectView all>
[[4 0]
 [4 1]
 [3 2]]
[[0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]]
<type 'numpy.int32'>
[[1 1 1]
 [1 1 1]
 [1 1 1]
 [1 1 1]
 [1 1 1]
 [1 1 1]]
<type 'numpy.int8'>