Wednesday, March 15, 2017

Load a vimrc from the web

You spend a lot of time configuring your vimrc, and now that you are sitting working in other computer and you can stand working without your predetermined vim configuration!.

But you can start vim with a specific configuration file. In this example,
we consider a vimrc file hosted on the web (github).

The command is:
$ vim -Nu <(curl url -k)

For example:
$ vim -Nu <(curl https://raw.githubusercontent.com/astudillor/vimrc/master/vimrc_nopluggins -k)

Source:

Wednesday, July 13, 2016

Installing Google Test

Google test is a framework for unit testing in c++.
For more information watch this video

$ git clone https://github.com/google/googletest.git
$ cd googletest
$ cmake -DBUILD_SHARED_LIBS=ON .
$ make
$ sudo cp -a include/gtest /usr/include
$ sudo cp -a libgtest_main.so libgtest.so /usr/lib/
$ sudo ldconfig -v

And now compile any program that uses Google test with '-lgtest' flag.

Source: http://stackoverflow.com/questions/13513905/how-to-setup-googletest-as-a-shared-library-on-linux

Friday, June 24, 2016

Create a file with random numbers

Sometimes we need to create a file that contains several random numbers. Using bash programming we can do that very quickly. Example,

mycomputer ~% for i in {1..1000}; do echo $RANDOM; done >> nums.txt

This command executes a for loop 1000 times, prints the random variable $RANDOM and redirect the output to the file nums.txt

Print a random integer in the bash console

If you need a random positive integer, you can print the variable $RANDOM. For example:

mycomputer ~% echo $RANDOM
120865

Saturday, April 25, 2015

Replace a string in several files

[CONTEXT]
You need to replace a string in several files

[HOW]
There several options to do this, 
  • sed:         Syntax:    $ sed -i "s/old_string/new_string/g" files
                    Example  $ sed -i "s/foo/bar/g" *.txt 
  • perl:       Syntax:    $ perl -i -p -e "s/old_string/new_string/g;" files  
                        


[SOURCE]
sed man page 
http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/ 


Monday, August 25, 2014

Managing your latex bib files in linux II

[CONTEXT]
You want a program to manage your Latex bibliography file.
[HOW]
Jabref  is a really good program to organize and modify your bib files in Latex using a very friendly GUI. Also this program can generate  automatically the key for the bib entries and you can include the link to your pdf files.

To install it, we can use the package in Debian's repository
# aptitude install jabref

[SOURCE]
http://jabref.sourceforge.net/

Synchronize a folder outside the default Dropbox's directory

[CONTEXT]
You want to synchronize a folder with Dropbox, without move that folder to
the default  Dropbox's directory
[HOW]
Create a symbolic link from the folder that you want to synchronize to the Dropbox directory, for example

$ ln -s /path/to/folder/to/sync ~/Dropbox

The permissions of the files or folders should be (at least) owner:r/w, group r/w, and others: r
-rw-rw-r-- 


[SOURCE]
http://www.dropboxwiki.com/tips-and-tricks/sync-other-folders