selfjungle Just another WordPress weblog

18Nov/110

colorful man pages

Edit ~./Xdefaults:

*VT100*colorULMode: on
*VT100*colorUL: yellow
!*VT100*italicULMode: on
*VT100*underLine: off
! Uncomment this to use color for the bold attribute
*VT100*colorBDMode: on
*VT100*colorBD: cyan
Tagged as: No Comments
18Oct/110

merge two pdf documents

I had to sign a document, which was basically:

  1. Print the last, 5th page of the pdf.
  2. Sign the sheet.
  3. Scan it as a one-paged pdf.
  4. Change the 5th page from the pdf with the new one.

Again, the solution was pdfjam, which did the job of merging the first 4 page of the original document with the new pdf.

pdfjam original.pdf '1-4'  new.pdf '-' --outfile merged.pdf

I found nice pdfjam examples at the The Bit Brothers.

Tagged as: No Comments
19Jul/110

xterm colors

The blue is too dark for my eyes, specially then it's used by colorgcc to highlight line numbers.

...and I just can't get angry with a cheerful orange cursorColor 😀

~./Xdefaults:

xterm*foreground:       #ffffff
xterm*background:       #000000
xterm*cursorColor:      orange
xterm*color4:           #526fcf
Tagged as: No Comments
15Feb/110

pdfnup: print 2 pages in 1 sheet

When I want to print 2 pages in 1 sheet, the contents of the pages become too small: inside the margin of the sheet, the 2 pages keep their margins too.

There is a nice tool called pdfnup (part of pdfjam), which not only help us get rid of the margin problem, but we can trim, shift and do whatever we want with a pdf document to create a more readable new one.

When I print books, most of the time this line is enogh:

pdfnup --nup 2x1 --paper a4paper --noautoscale true --outfile output.pdf input.pdf

There was only one case when some fine calibration was needed:

pdfnup --nup 2x1 --paper a4paper --trim '4.5cm 3.5cm 4.5cm 3.5cm' --outfile output.pdf input.pdf
Tagged as: No Comments
13Feb/110

vim delete lines with regexp, replace string

uzbl is an awesame ultralightweight browser, however gmail has cookie issues. The only way I found to have a working uzbl+gmail is to remove every line from .local/share/uzbl/cookies.txt which contain Google/google when the cookie problem happens.

With vim it's possible to look for STRING case insensitively and delete lines:

:g/\cSTRING/d

Also replace STRING1 to STRING2 in one line or in all lines.

:s/STRING1/STRING2/g
:%s/STRING1/STRING2/g
Tagged as: No Comments
4Feb/110

gcc, colorgcc, lcov, valgrind

At home I usually don't create makefiles when my program is so small that it fits into one file.

However compilation errors are more readable with colorgcc, and having as much warnings/errors at compilation time as possible is even better.

.bashrc:

GCC_ARGS="-Wall -Werror -pedantic -Weffc++ -Wshadow -ggdb --coverage"
alias g++="/usr/lib/colorgcc/bin/g++ $GCC_ARGS"
alias gcc="/usr/lib/colorgcc/bin/gcc $GCC_ARGS"

The -ggdb puts debug symbols to the binary and --coverage will make the binary create .gcda and .gcno files at runtime.

To create a nice coverage-html lcov needs more steps (3) than I'm willing to type everytime so the following line in the .bashrc do the work. Note that the lcov_all is function, because argument passing is not possible with aliases.

alias lcov_reset="lcov --directory . -z ; rm -f ./lcov.info"
alias lcov_capture="lcov --directory . --capture -o lcov.info"
alias lcov_html="rm -rf ./cov ; mkdir cov ; genhtml -o ./cov lcov.info"
function lcov_all() { lcov_reset ; $1 ; lcov_capture ; lcov_html ; }

The best way to alter valgrind's behavior modifying the .valgrindrc:

--leak-check=full 
--show-reachable=yes 
--malloc-fill=0xaa 
--free-fill=0xbb

So when I program follow the following steps:

  1. Edit the source.
  2. g++ <sourcefile>
  3. run <binary>
  4. Check leaks: valgrind <binary>
  5. If coverage is needed, lcov_all <binary>
Tagged as: , No Comments
4Feb/110

create password with openssl

So trivial, yet it was unknown for me for such a long time long:

openssl rand -base64 12

cncji0R8KIr9G40q
kboFCpbT81hOQSQK
dgdr7rart8koI7Bd
...

Tagged as: No Comments
3Feb/110

command line GTD – task

A todo app is always handy, when you want to keep your shit together.

If you are not familiar with Getting Things Done from David Allen, do some googling & torrents reading, it worths the effort.

After trying ikog I settled with task, which is much richer in features (import/export vcalendars, etc)

I added the following lines to my .taskrc, which set some params and define a new view called l1.

defaultwidth=100
editor=vim

report.l1.columns=id,project,priority,due,tags,description
report.l1.filter=status:pending
report.l1.labels=ID,Project,Pri,Due,Tags,Description
report.l1.sort=due+,priority-,project+

So when I append the line to my .bashrc:

task l1

Every time I open a new terminal, I got reminded to my tasks.

Tagged as: , No Comments
29Jan/110

put/get files to/from ftp server non-interactively

I decided to sync my work/home computers' calendar/contact files.

Since I wanted to avoid gmail and other closed solutions, I chose ftp as a transfer method and after some search I found ncftp which does the job.

Now I can issue the get script after login and the put before logout at each machine.

#!/bin/bash
# get files from remote server

ncftpget -u USER -p PASS FTPSERVER /LOCALPATH/ std.ics
ncftpget -u USER -p PASS FTPSERVER /LOCALPATH/ std.vcf
#!/bin/bash
# upload files to remote server

ncftpput -u USER -p PASS FTPSERVER . /LOCALPATH/std.ics
ncftpput -u USER -p PASS FTPSERVER . /LOCALPATH/std.vcf
Tagged as: , No Comments