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

Monday, December 2, 2013

Check infromation of CPU, memory and Hard Drive information

[CONTEXT]
In order to check the information of your CPU, memory and Disk usage.
[HOW]
To check your CPU information, just execute

$ cat /proc/cpuinfo
or
$ lscpu

To check your Memory information, just execute

$ cat /proc/meminfo

To check your Disk Usage information, just execute

$ df -h


[SOURCE]

man proc
man df

Friday, October 11, 2013

Removing annoying console beeps

In order, to remove the beep sound of your linux console just type the following command, in your console (in the directory /home/$your_user)

$echo 'set bell-style none' >> ~/.inputrc

Monday, August 12, 2013

Managing your e-books

[CONTEXT]
You have a collection of e-books and you want organize them, make conversion between file types, read them, or even synchronize them with your e-reader.
[HOW]
Calibre is a Software to manage you e-book collection. You can use it as a reader, converter, news reader, among other features.
To install it, we can use the package in Debian's repository
# aptitude install calibre
[SOURCE]
http://calibre-ebook.com/

Managing your latex bib files in linux

[CONTEXT]
You want a program to manage your Latex bibliography file.
[HOW]
Kbibtex  is a really good program to organize and modify your bib files in Latex using a very friendly GUI.


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

[SOURCE]
http://home.gna.org/kbibtex/

Wednesday, August 7, 2013

Digital TV and Radio in Linux

[CONTEXT]
You are looking for a program to play webTV and WebRadio on Linux
[HOW]
One of the options to watch webTV and listen WebRadio is Freetuxtv.
You can also record the channels in different formats.
To install it, we can use the package in Debian's repository
# aptitude install freetuxtv
[LINKS]
http://code.google.com/p/freetuxtv/
http://database.freetuxtv.net/site/index

Sunday, July 28, 2013

How to synchronize Multiple Dropbox Accounts in your computer

[CONTEXT]
You have multiple accounts in dropbox. (Assume that you have alredy install dropbox on your computer).

[WHEN]  
You want to synchronize all your dropbox account files in your computer at the same time.

[HOW]
  • Create the alternative folders for your additional account, for example
         $ mkdir ~/.dropbox-mte
           $ mkdir ~/dropbox-mte
  • Run from a terminal the following command
        $ HOME=$HOME/.dropbox-mte /usr/bin/dropbox start -i
  • Configure your account and make as default directory ~/dropbox-mte
  • Create a file to launch the new instance of the dropbox deamon for example,

            DropboxAltStarter.sh
           #!/bin/bash
           HOME=$HOME/.dropbox-mte /usr/bin/dropbox start
  
  • Executable permissions 
           $chmod 755 ~/DropboxAltStarter.sh
  • Include DropboxAltStarter.sh in your starter.
"Go to System -> Preferences -> Startup Applications. Click Add and          include the following:
Name: 2nd instance of Dropbox
Command: /home/Username/DropboxAltStarter.sh
Click Ok."

  
[SOURCE]
http://www.maketecheasier.com/run-multiple-dropbox-accounts-in-mac-and-linux/2010/05/24

Monday, June 17, 2013

Fixing the warning: W: Possible missing firmware /lib/firmware/rtl_nic/....

When I had upgraded some programs, I got the following warning:

W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-2.fw for module r8169

To fix it you only have to install the firmware-realtek

# aptitude install firmware-realtek

Source
http://forums.debian.net/viewtopic.php?f=7&t=82716 

Sunday, April 21, 2013

Play encrypted DVD

[CONTEXT]
Playing encrypted DVD, sometimes you can recieved a error message like
 libdvdread: Encrypted DVD support unavailable.

[WHEN] 
You want to play encrypted DVDs with Linux.

[HOW]
As root
Edit your /etc/apt/source.list, adding this line

 deb http://www.deb-multimedia.org wheezy main non-free

The first package to install is deb-multimedia-keyring.

# apt-get install deb-multimedia-keyring
Install the library  libdvdcss2
# apt-get install libdvdcss2

After this steps, your dvd's player will be able to play DVD

[SOURCE]
http://www.cyberciti.biz/faq/debian-linux-squeeze-installing-libdvdcss2-command/ 
http://www.deb-multimedia.org/ 

[OTHERS ALTERNATIVES]
http://theos.in/desktop-linux/linux-playing-encrypted-dvd/
http://www.cyberciti.biz/faq/howto-ubuntu-linux-playback-dvd/

Mount a remote file system using ssh

[CONTEXT]
Access a remote file system  
[WHEN] 
You want to transfer files from/to a server which you have a ssh access
[HOW]   
As root:
install fuse
#apt-get install fuse-utils sshfs ssh
and load its kernel module
#modprobe fuse
add your regular user to fuse's group
#adduser [your-user] fuse
(reboot the machine)
Now using your regular user:
Mount your remote directory:
$ sshfs [user@]host:[dir] mountpoint [options]
e.g.
$sshfs remote-user@remote.server:/remote/directory /home/user/remote/
(If you only put  ':' is going to be your default directory)
Then, you can manipulate your remote folder as a regular local folder.
Unmount your remote directory
$fusermount -u mountpoint
e.g.
$fusermount -u  /home/user/remote/


[SOURCE]
http://www.debianadmin.com/mount-a-remote-file-system-through-ssh-using-sshfs.html 

Tuesday, February 12, 2013

Give bash prompt an interactive value with a script

[CONTEXT]
Bash script to automatically give an interactive value to prompt.

[WHEN]
For instance, you need to execute a sudo command on user logon, and you need to do it through a script.

[HOW]
Edit a bash script with the following content:

#!/bin/sh

( echo 'P4ssw0rd
' ) | su - root -c "/sbin/rcnetwork restart"

Where:
P4ssw0rd is the password for root user
"/sbin/rcnetwork restart" is the command to execute as root user

Take special attention on the new line after the password on the bash script, and also on the single quotes.


[NOTE]
This is only for reference, you never should write out the root password on a plain text file.

Installing Latex packages in your home directory

  
[CONTEXT]
Without root access, we cannot put the packages or Latex's style files into the directory /usr/share/texmf/


[WHEN]
We want to install Latex package or style files for all our Latex documents but we are working in computers that we do not have root access.



[HOW] 
Create a private tex hierarchy

$mkdir  $HOME/texmf/tex/latex

Put in this directory all your class, style, and package Latex files.
For custom bibtex style files, create the directory texmf/bibtex/bst

$mkdir $HOME/texmf/bibtex/bst

and put your bst files into it.


After any modification of the $HOME/texmf directory, run the command:
$texhash

Source: http://www.math.uiuc.edu/~hildebr/tex/tips-customstyles.html

Monday, February 11, 2013

Installing the Nvidia Kernel module

As root type
# apt-get install module-assistant nvidia-kernel-common
# m-a auto-install nvidia-kernel${VERSION}-source
# apt-get install nvidia-glx${VERSION} 
and reboot
 
Source: http://wiki.debian.org/NvidiaGraphicsDrivers

Sunday, February 10, 2013

Download videos from YouTube.com

youtube-dl is a script to download videos from youtube
To install this script, type as root
#wget http://youtube-dl.org/downloads/2013.08.09/youtube-dl -O /usr/local/bin/youtube-dl
#chmod a+x /usr/local/bin/youtube-dl
and to update it

#youtube-dl --update

To download videos, just type youtube-dl and link direction, for example

$youtube-dl http://www.youtube.com/watch?v=hUYzQaCCt2o

Also you can use this script to extract the audio of theses vidios, for example

$youtube-dl --extract-audio --audio-format=mp3 -t http://www.youtube.com/watch?v=hUYzQaCCt2o

Source: http://rg3.github.com/youtube-dl/