2011 in review
The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.
Here’s an excerpt:
Madison Square Garden can seat 20,000 people for a concert. This blog was viewed about 62,000 times in 2011. If it were a concert at Madison Square Garden, it would take about 3 sold-out performances for that many people to see it.
[vim] Automatically jump to the last visited line when a file is reopened
Put the following in your .vimrc file to automatically jump to the last visited line when a file is reopened using vim:
" This allows Vim to jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"")
Alternatively, you could just reopen the file normally and then hit " '0 " (that is, single quote followed by the number zero) to get the same result.
Source: Stack Overflow
[security] Encrypt a PDF file in the command line
There are a few command line tools to encrypt/ password-protect a file, for example OpenSSL, GnuPG. However, if you want to send someone an encrypted PDF who does not have access to these CLI tools, then that’s not cool for the recipient at all! Pdftk is another open-source command line tool that can encrypt a PDF file which can be decrypted using either Pdftk in the commandline or entering the password in a GUI pop-up box when the recipient tries to open the PDF file using a PDF viewer (for example, Adobe Reader).
Examples (taken from PDF Labs):
1. Encrypt a PDF using 128-Bit Strength (the Default) and Withhold All Permissions (the Default)
$ pdftk mydoc.pdf output mydoc.128.pdf owner_pw foopass
2. Same as Above, Except a Password is Required to Open the PDF
$ pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz
3. Same as Above, Except Printing is Allowed (after the PDF is Open)
$ pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz allow printing
4. Decrypt a PDF
$ pdftk secured.pdf input_pw foopass output unsecured.pdf
NOTE: Setting an owner password prevents the document from being modified unless the password is provided. In the same way, setting a user password prevents the user to view the file.
[shell] Repoint an existing symbolic link (symlink) to a different target
$ ln -nsf <TARGET> <LINK>
Credit: Commandline-fu.
[perl] Access shell environmental variables in your Perl script
The environmental variables are stored in %ENV hash (“associative array”). Now if you want to access a shell variable, say $HOME, in your Perl script, then you need to refer to it as $ENV{'HOME'}:
#!/usr/bin/perl
$my_home_dir = "$ENV{'HOME'}" ;
$my_shell = "$ENV{'SHELL'}" ;
$my_editor = "$ENV{'EDITOR'}" ;
Don’t forget the curly braces and the single quotes!
Reference: Devdaily blog.


leave a comment