Wednesday, 26 November 2014

CDT student project

Traffic light control

Tuesday, 25 November 2014

cs102 project

Project specifications

PWM motor driver

A simple pwm motor driver. This circuit generates buzzing sound when duty cycle isn't enough to turn the motor.

Wednesday, 19 November 2014

Assembly code for generating Fibonacci series


shortest code by JEERAMETH KLOMSING

Cat     Add 7
        Sta 7
        Add 99 
        Sta 99
        Bra Cat
        Dat 1

code by Som-O

      LDA  A
      ADD  A
      STA  B
      ADD  A
      STA  A
      ADD  B
      BRA  4
A     DAT  1
B     DAT  1
Clear memory
by Wasit
begin   lda x
        add one
        sta x
x       dat 305
        bra begin

one     dat 1

Tuesday, 11 November 2014

Pi microscope

1. Removing the lens by using two pins to turn the lense cover in anti-clockwise direction
2. removing the eyepiece of the microscope and replaced by the Pi camera
3. Here I used an old calibration sample. The distance between two lines is 0.2mm (200 micron)
4. The the tiny number on sample is scaled up and inverted on screen
5. When I used 4x objective lense
6. and 10x
7. Finally the 40x objective lens. At this magnification the image was quite blur and it showed significant color aberration.
8. by adjusting location of condensing lens below the sample has improved the quality.

In the image7, the space between two black lines was scaled up to almost completely filled the width of window (2592 x 1944). Roughly about 12.5 pixel per micron. An this will be helpful in my project, which I need to look cells, which has size around 10 to 50 micron.

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'>

Wednesday, 23 July 2014

To resize images

I used ffmpeg to scale the width to 480 pixels.

mkdir out
FOR %%A IN (*.jpg) DO (
    c:\tools\ffmpeg\bin\ffmpeg -i "%%A" -vf "scale=-1:480" "out/%%A.jpg"

Wednesday, 7 May 2014

Setting up a single node IPython Notebook

Install IPython

  After installing IPython by sudo apt-get install ipython-notebook, we can follow the instruction here to setup a public notebook. The steps are below:

note: this works for my old desktop
$ sudo apt-get install python-pip
$ sudo pip install ipython[all] --upgrade

1. create a certificate
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

2. generate a hashed password in IPython environment
In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:xxx:yyy'

3. create a notebook profile
ipython profile create wasit

4. edit /home/ubuntu/.ipython/profile_wasit/ by the following code:
c = get_config()
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.certfile = u'/home/ubuntu/.ipython/profile_wasit/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:xxx:yyy'
c.NotebookApp.port = 8888
c.NotebookApp.enable_mathjax = True

5. then we can start the notebook by going to particular directory and run the script
$ipython notebook --profile=wasit
$ipthon notebook --certfile=mycert.pem

However, the session will be terminate and we no longer run the job. In order to redirect the terminal output and keep the job run after terminating ssh, we should put the command in the 5th step in and run this
$ nohup ./ </dev/null &