Wednesday, December 14, 2011

How to determine which RPM a file belongs to in Redhat?

To figure out which RPM a file belongs to in Redhat derived distros, use the following command:

rpm -qf /path/filename

Wednesday, November 30, 2011

Skiplists are awesome

Thanks to MIT Open Courseware, Prof Erik Demaine of MIT talks about the awesomeness of skiplists.

Monday, November 14, 2011

Skip List written in Python


I've started a project that implements skiplists in Python. It is an early version and there are a lot of things that need to be added (better tests, Python module mumbo jumbo like iterators,...)

If you try it out and have some ideas about what I should add, please comment below.

Tuesday, October 25, 2011

How to send a signal to a process in Unix

To send a signal to a process you use the kill
system call. Note that you use this system call even if you're not sending
the SIGKILL signal.

Here's an example:

        kill( chpid, SIGTERM );

Tuesday, July 26, 2011

Convert PDF to image using command line

To convert a PDF file to a series of images, you will need Imagemagick installed on your system. If you run Linux or Mac OS X, it is probably already installed. For Windows, iOS and other OSes, you can download a binary release here. If that fails, you can download the source and try compiling Imagemagick yourself.

To convert the PDF file to a series of image, you use the convert utility as follows:
convert -quality 100 -density 600x600 orig.pdf output%d.jpg

To convert to any other format simply replace the 'jpg' extension with the desired output format.

Sunday, July 3, 2011

Google Chrome not working with Facebook


I switched from Firefox to Chrome some time back and have loved the speed and functionality of Chrome. Recently though, Facebook hasn't been working well with Chrome.

I found a simple solution to my problem which is sort of the equivalent of "Have you tried turning it off and on again?"

Click on the wrench found in the upper right corner of the browser and select Options. Click on Under The Hood and then click on Clear Browsing Data.

This did the trick and Facebook is now functional again.

Leave a comment if you found a different way to solve problems bewteen Google Chrome and Facebook.

Saturday, June 4, 2011

How to speed up videos

Have you ever had to watch a talk or lecture video and wished that you could somehow speed it up, yet still get the gist of the whole thing? Or maybe there's this movie that you have to watch for class? Or maybe you're like me and you want to watch a bad movie but somehow lessen the time investment.

The answer is the open source, free media player VLC. Under the Playback menu, you can click on Faster (fine) to increase the speed by 10%. Here in the screen shot I increased the speed by 50% over the original speed to watch Dragon Wars. You can also use a keyboard shortcut using the right bracket ].

Friday, May 20, 2011

How to select pages from a PDF file/ split a PDF file using pdftk



Say I want to save only the first 31 pages to the new pdf:

pdftk A=orig.pdf  cat A1-31 output new001.pdf

Monday, May 16, 2011

How to copy/delete word under cursor in Vim


Assuming that the cursor is at the first character of the word simply do this in command mode:


yw


y is for yank and w is for word.

Other ways of doing the same thing which are not as efficient:


vey


the v starts visual select mode. e tells vim to move to end of word. y yanks or copies the word. to delete replace y with x.

if the cursor is somewhere in the middle of the word, add a b before the command as in:

byw



or


bvey

Software engineering models on Wikipedia

Starting some research on software engineering and did a bit of digging around on wikipedia:

Saturday, May 14, 2011

RUBYLIB and installing ruby to a custom directory

I needed to install ruby on my uni's lab machine without admin privileges.

To install ruby, I downloaded the version of ruby i needed from http://ftp.ruby-lang.org/pub/ruby/1.8/. And then do the following:


./configure --prefix=/path/to/dir
make
make install


Obviously, you should have read/write privileges to the directory /path/to/dir. Most of the time, it will probably be your home directory.

After much searching and tweaking later on, I also found that you have to set the RUBYLIB environment variable.

Assuming you're using Linux and bash, you do the following:


export RUBYLIB=/path/to/dir


What if you have a different installation of ruby, say the standard one on the same machine? Good question. I don't know the answer. :) If you do, please leave it in the comments.

Wednesday, May 11, 2011

How to rotate pages in a PDF document

I recently scanned quite a number of documents only to discover that every other page was rotated 180 degrees. (Let's just say that I learned my lesson and will be doing a test run before committing time to a task like that. :)

So I searched for a way to be able to selectively rotate pages in a PDF document. As always, I like command line tools that are open source.

Enter pdftk - The PDF toolkit.

To solve my particular problem, the command is:



pdftk input.pdf cat 1 2S 3 4S output output.pdf


Here's a brief explanation:

cat - assembles the pages mentioned
1 2S 3 4S - these are the pages needed. I couldn't find an easy way to say rotate only the even pages but still print out the odd pages, so I had to enumerate the pages
output - specifies the output filename

Monday, May 9, 2011

Floating point on bc, command line calculator

bc is a great commandline calculator on Linux and *nix like OSes. But the default setting on the Linux machine here at Tufts gives:

7/16 = 0

Obviously, this is not what I was looking for. After a little googling, I found the following.

Quoting from the bc online manual:

"There are two attributes of numbers, the length and the scale. The length is the total number of significant decimal digits in a number and the scale is the total number of decimal digits after the decimal point. For example, .000001 has a length of 6 and scale of 6, while 1935.000 has a length of 7 and a scale of 3."

To set the scale (say 4 digits), just type:

scale = 4

Friday, April 29, 2011

face guards by Andrew Winslow, Diane Souvaine and me

Abstract:

A classic problem in computational geometry is the art gallery problem: given an enclosure, how should guards be placed to ensure every location in the enclosure is seen by some guard. In this paper we consider guarding the interior of a simple polyhedron using face guards: guards that roam over an entire interior face of the polyhedron.
Bounds for the number of face guards g that are necessary and sufficient to guard any polyhedron with f faces are given.
We show that for orthogonal polyhedra,





while for general polyhedra





Example of the orthogonal polyhedron:






PDF version of the submitted paper.

Wednesday, April 27, 2011

Chomsky Normal Form for a simple CFG



In case anyone from Comp 170 is interested, here's the Chomsky normal form for the language discussed in class. Note that some definitions of CNF say that you can not put the start symbol S on the right hand side.

Tuesday, April 19, 2011

Creating povray files from Python

A nice recipe from Activestate found here.
Someone added some functionality (added Object) with the description and code found here.

Thursday, April 14, 2011

Service Oriented Architecture links

A collection of links for SOA (mostly from Tisch Library at Tufts:


  1. SOA on wikipedia

  2. Service oriented architecture for dummies

  3. Service oriented architecture field guide for executives

vim - how to resize windows from the command line




















:res[ize] -N decrease height of current window by N
:res[ize] +N increase height of current window by N
:vertical res[ize] -Ndecrease width of current window by N
:vertical res[ize] -Nincrease width of current window by N