Saturday, January 21, 2012

Caps lock indicator in Linux / Gnome2

If we want to add a caps lock indicator in the Gnome2 panel (that one that shows the clock) there is one easy alternative. We can install the package lock-keys-applet.

$ sudo apt-get install lock-keys-applet
$ killall gnome-panel


Once we have done this, we can add to the panel the new element doing right click in the panel, "Add to panel" and then choose the "Lock Keys" applet.

Source
http://ubuntuforums.org/showthread.php?t=1224918

Sunday, January 1, 2012

Subversion quick configuration

1.1 Create a folder to hold all repositories
$ mkdir ~/.svnroot

1.2 Create a repository
$ svnadmin create ~/.svnroot/project

2.1 Import the repository to work with it (only necessary to do it once)
$ svn checkout file:///home/pron/.svnroot/project

2.2 Create the main structure (only necessary to do it once)
$ cd project
$ mkdir trunk tags branches

3. Activate daemon to allow access to Subversion repositories using the svn network protocol
$ svnserve -d -r ~/.svnroot

4.1 Make a backup of a repository
$ svnadmin dump -q ~/.svnroot/project > project.dump

4.2 Restore a backup
$ svnadmin create project
svnadmin load project < project.dump

5.1 Creating a version
$ svn copy file:///home/pron/.svnroot/project/trunk \
> file:///home/pron/.svnroot/project/tags/v0.1 \
> -m "Creating v0.1 with the right command"

6.1 Recover the last version of a file that has been saved but no commited
$ rm file
$ svn up file


6.2 SVN Diff against changes in the remote repository 
$ svn diff -r HEAD

6.3 How to ignore a directory with SVN
$ svn propedit svn:ignore .

If you have multiple things to ignore, separate by newlines in the property value. In that case it's easier to edit the property value using an external editor:
$ svn propset svn:ignore dirname .

6.4 Getting SVN revision number into a program automatically
Add this code to your file (i.e. file.py)
VERSION='$Rev$'

After this, in the command line write this:
$ svn propset svn:keywords "Revision" file.py


Resources
http://svnbook.red-bean.com/en/1.1/ch04s06.html
http://stackoverflow.com/questions/116074/how-to-ignore-a-directory-with-svn http://stackoverflow.com/questions/1449935/getting-svn-revision-number-into-a-program-automatically

Unixtime quick usage - Seconds to date

1.1 Get unixtime in the console
$ date +%s


1.2 Get unixtime in python
>>> import time
>>> int(time.time())


2 Unixtime to date in the console
$ date -d "UTC 1970-01-01 1294779314 secs"

or
$ date -ud @1294779314


Resources
http://en.wikipedia.org/wiki/Date_(Unix)
http://www.linuxhowtos.org/Tips%20and%20Tricks/converting_unixtimestamp.htm

GPG quick usage

1. Encrypt a file with public key
$ gpg --encrypt --recipient 'Your Name' foo.txt


2.1 Decrypt a file with private key (using the password in the commandline)
$ gpg --output foo.txt --passphrase "$_PASS" --decrypt foo.txt.gpg


2.2 Decrypt a file with private key (not using the password in the commandline)
$ gpg --output foo.txt --decrypt foo.txt.gpg


Resources
http://www.madboa.com/geek/gpg-quickstart/
http://aperiodic.net/phil/pgp/tutorial.html

Add a existing user to existing group (usermod)

If we want to add the existing user pron to the existing group vboxusers, we can execute this command:

$ usermod -Ga vboxusers pron


Is neccessary to put -a, otherwise other groups will be erased. To see changes type:

$ id


Resources
http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/