Saturday, April 2, 2011

bash as a functional language.

Following the previous posting on similarity between the functional staple map(), and xargs, I was looking more deeply if we can consider bash programming a functional language. In the xarsg example I used before, I used the sh -c trick, which can be said is analogous to eval function in any functional language. Exactly the same can be achieved using the back-tick syntax, give a string as an input, and get the result of evaluation.

So now we have eval, and therefore closures and 'sorta' anonymous functions which can be passed around as strings and evaluated using eval. the pipes tie this all together, allowing to pipe the results from one function to another.

What else do we need to call a language functional? thinking...

Tuesday, March 29, 2011

bash-fu:xargs

The basic techniques of bash-fu are famous now.find, grep, sed, awk, some for loops and everything is at your fingertips. The second level of bash dao is using xargs: the gem of unix tools.

xargs is to bash what map is to functional programming, and it does to input exactly what map does: apply a function to each element in input. However, the problem with xargs is that it accepts only one argument at a time, so what if we want to emulate a double loop? sh comes to help:

xargs -L 1 -I {} sh -c "`foobar| xargs -L 1 -Ix x "

or something like that :D

Thursday, May 13, 2010

numero i dont remember

So, couple of hints on Autodock and Gromacs.

A problem that was haunting me was a constant error "NOTE: all energies are equal in population". the solution is - use Autodock 4.2.

Second problem was the "Warning: attempt to divide by zero" It appears that autodock does not digest the alternative atom coordinates in the PDB's. to solve that delete either of the alt locations and run a small script to fix atom seq id's. Or just take a different PDB file.

Running gromacs is pretty straightforward. the only note is that genion sometimes does a crappy job when you want to replace some specific molecules with ions (selected from index group) so you need to write a small script that will fix the atom and residue ids.

so long.

Wednesday, February 10, 2010

tre: And an idea that I had today.

Preamble: Academia.edu sends you a notification when somebody comes to your profile through a search engine. This somehow keeps a track of how often do people search for you.

The idea: create a web site, put some javascript in the title, push the website up in google so that javascript executes whenever somebody finds the web page on Google. The executed code could notify you whenever somebody searches for you and the results are displayed.

Limitataions: I am sure that google sanitizes the data in the web page titles.

Tuesday, February 9, 2010

duo

There was something in here.

uno

As the name of the blog states, in this blog I will try to keep track of the most important ideas and thoughts that my deeply caffeinated brain produces daily. The format of this blog will be much different from the one I keep on livejournal which is my base for pseudo-political prank posts.
So expect to see a lot of crazy ideas, occasional reflection on the life in San Francisco, and maybe some pics.