Skip to main content

Posts

Showing posts from July, 2013

Plot csv data using D3.js

I tried my first D3.js data visualization using csv data source My 'graph' would plot circles, where the x position of the circle would represent the value of the second column (file size) in my csv. The larger files would be plotted to the right. I posted my example d3csv.html at  https://github.com/binodpanta/webvisualizer I should be able to do some more interesting things with this, such as realtime monitor files. Enjoy!

Using Sublime Text build system to open your files in your favorite Mac app

A quick hack on Sublime text when working on Macs is to get the editor to invoke the 'open' command so that you can hit command+B to 'open' the file in your favorite app. My favorite use for it is when editing html files, i want it to open in my favorite browser. On a Mac, 'open' is the equivalent of the default file association in Windows, such as when you click on a text file, you can have it open in your favorite editor. In sublime, go to Tools > Build System Select New build system In the file that opens type this in into the pre-filled section and save the file with a name you want, such as 'open.sublime-build': { "cmd": ["open", "$file"] } Then go back to the file you were editing, Tools > Build System. Now select your newly saved build system. Now every time you hit command + B you get the file to open on Chrome (which is what my Mac is setup by default to open html files with)! Obvi

Using "watch" to monitor a command's output in Linux

I recently learned about the 'screen' command on Linux from one of my friends (and now I am hooked). Now I have learned to use another Linux command 'watch' to constantly run a command and watch its output. I was running into an issue when I ran a test session I would keep getting an error about disk space being filled up. So I thought to monitor disk usage as I ran my stuff. First, I setup two screens on my remote terminal (putty in my case) and ran screen ctrl+A S to create a split screen ctrl+A tab to move to the second view ctrl+A c to create a new window now that i have two screens On screen 1, run 'watch -n 2 df /tmp' to run the df command every two seconds against /tmp, and now i have a view that updates every 2 seconds in my screen1 On screen2 (switch using Ctrl+A tab), i run my command There you go, I have not yet found my source of trouble, but the technique still proved its worth since I could see the disk space update as I ran my com

My first encounter with Lambda functions in Python

Lambda functions in Python Here is a very simple  lambda function , this example is one of creating a polynomial function with given coefficients, and storing that as a lambda function in a variable 'f' that can now be used as a function, cool! # This returns a function that represents a polynomial # Input is a dictionary with a,b,c being required keys def polyf(**coeffs): """Returns a lambda function""" return lambda x: coeffs['a']*x*x + coeffs['b']*x+coeffs['c'] # now returns a lambda function that will evaluate 2nd order polynomial with coeffs a, b, c when called f = polyf(a=1,b=2,c=3) print "Help doc for this function = ", polyf.__doc__ # Try using that lambda function now, Done! print f(0.1) print f(0)