Monday, April 8, 2013

How to open a new file in an already running emacs instance

I had been looking for this. I am jotting down probably the simplest way in case I forget in the future. First add this to your .emacs file

(server-start)

Add this alias to your ~/.bash_aliases

alias ecn='emacsclient --no-wait'

Now open a file in a running emacs instance like this.

ecn filename

Monday, March 4, 2013

Why do khanacademy videos load comparatively much faster?

So, I have noticed that khanacademy videos load much faster. The reason I have come to know from the following discussion is the predominant use of black in videos. So it can be compressed much more.

Q: In countries like mine we don't have many people who can afford high broadband speeds.It takes a lot of time for any kind of videos to buffer.But KHAN ACADEMY videos,they load in a flash!

A: I know the question (and the answer) is off topic but it makes a change for me to be able to answer something: It's because there is a predominance of one colour - black - and so the video can be compressed by the sender's system to a much greater extent. On a typical row of the video, instead of sending 800 black pixels and 1 green pixels - for example), the sender sends something like "0*800" and "256*1" and the receiver interprets that at the other end (I just put in 0 and 256 because those are the RGB codes for black and green).
Here is the permalink to the discussion. Permalink

Sunday, February 17, 2013

How to build llvm from source on ubuntu 12.04

So I needed to build the latest llvm i.e. version 3.2 from source today. In this post I will describe the steps for Ubuntu 12.04.

First download the llvm source package from this link. I downloaded the x86 version because I am running 32 bit version of Ubuntu(aka i386).
Link: 32 bit

You can download the x86_64 version if you are running 64 bit Ubuntu(aka amd64).
Link: 64 bit

Put the downloaded .tar.gz archive in a convenient location. I put mine on ~/opt. Then extract the archive via this command.

cd ~/opt
tar xvzf clang+llvm-3.2-x86-linux-ubuntu-12.04.tar.gz

Now you will have a directory named LLVM. Go to the llvm directory.

cd LLVM
cd llvm
Now here comes the tricky part. The first time I ran this command


./configure --enable-optimized

and was greeted with the following error at the end:

configure: error: Selected compiler could not find or parse C++ standard library headers.  Rerun > with CC=c-compiler CXX=c++-compiler ./configure ...
The main purpose of this post is so that others can get rid of this specific error. Run the following command to get rid of the above error. You should have clang installed on your computer for this to work.

sudo apt-get install clang
./configure --enable-optimized CC=/usr/bin/clang CXX=/usr/bin/clang++

We have run the configuration script. Next step is to run the make command to start the building process. I should warn you that this is going to take a lo..ng time to finish.

make
After make finishes building run this final command to install.

sudo make install
References:

Saturday, February 16, 2013

Quickly open current directory in nautilus from commandline

Say you are doing some work on commandline and you would like to open your current directory on nautilus to look around graphically. It can be quite useful sometimes. In this post I will tell you how. Add this line to the end of your .bash_aliases file.


alias n.='nautilus .'

Save it and run this command to update.


source ~/.bash_aliases

Now check if it works and let me know in the comments.

Friday, February 15, 2013

Your shared library and LD_LIBRARY_PATH

Libraries which are loaded dynamically at runtime are called shared object library in linux. They have .so extension. LD_LIBRARY_PATH is the path where your linux os looks for shared object library. Suppose you have your own libraries in the folder ~/mysharedlibs. In order to be able to use the libraries add this code to your .bashrc file.



if [ -d ~/mysharedlibs/ ];
then
    LD_LIBRARY_PATH=~/mysharedlibs/:$LD_LIBRARY_PATH
fi 

export LD_LIBRARY_PATH

References:

Test syntax highlighting

Testing prismjs syntax highlighting.


var foo = "bar", baz = 5;



# highligted with prismjs
print "Python works too"