selfjungle Just another WordPress weblog

27Feb/110

install cxxtest to gentoo

It is basically downloading the ebuild from the bgo-overlay - cxxtest and following the steps of this article at linuxreviews about how to install custom ebuilds with gentoo.

Which are in this case:

su

mkdir -p /usr/local/portage
echo PORTDIR_OVERLAY=/usr/local/portage >> /etc/portage/make.conf

mkdir -p  /usr/local/portage/metadata/
touch /usr/local/portage/metadata/layout.conf
echo "masters = gentoo" >> /usr/local/portage/metadata/layout.conf

mkdir -p /usr/local/portage/dev-util/cxxtest/
cd /usr/local/portage/dev-util/cxxtest/
wget http://gpo.zugaina.org/AJAX/Ebuild/2578437 -O cxxtest-3.10.1.ebuild
ebuild cxxtest-3.10.1.ebuild digest
emerge cxxtest
Tagged as: No Comments
20Feb/111

iwlist scan perl wrapper

The output of /sbin/iwlist scan is too much for me in most of the cases: I just want to know which WiFis are present, quality and open/passneeded state.

So here is a small perl script for it, the ESSIDs printed in descending order of quality which changed from 1-70 to 1-100.

#!/usr/bin/perl

use warnings;
use strict;

open(LIST, "/sbin/iwlist scan 2>&1 |") or die "Failed: $!\n";

my %wifis;
my $essid;
while () {
        if (/ESSID\:\"(.*)\"/) { $essid = $1; }
        elsif (/Quality=(\d*)\/70/) { $wifis{$essid}->{"quality"} = $1; }
        elsif (/Encryption key\:(\S*)/) { $wifis{$essid}->{"key"} = $1; }
}

sub by_quality {
        $wifis{$b}->{"quality"} <=> $wifis{$a}->{"quality"};
}

print "\n";
foreach $essid ( sort by_quality keys %wifis) {
        printf '%*s %*s   %-d', 30, 
                $essid, 
                6,  $wifis{$essid}->{"key"}=~/on/? "Pass" : "Open" , 
                int($wifis{$essid}->{"quality"}) / 70.0 * 100;
        print "\n";
}
print "\n";

A sample output I got at my flat:

cs0rbagomba@ramen ~ $ wifi_list 

                    gara_dlink   Pass   71
                     TP-Link01   Open   54
                           zaa   Pass   50
                         DBnet   Pass   50
                          anzo   Pass   47
                          3Com   Pass   22
                TP-LINK_9D27F4   Pass   21
                 TP-LINK_TOMEC   Pass   21
                           TNT   Pass   17
                   TimeCapsule   Pass   15
                       hpsetup   Open   14
                  Pannon Cargo   Pass   12
                       Airlive   Pass   10
                TP-LINK_DA3008   Open   10
                                 Open   8
     Szeretetre melto internet   Pass   8
                        KZSNET   Pass   8
                     CEO_iroda   Pass   8
                         Vani2   Pass   5
                      GIGABYTE   Open   4
                        csikos   Pass   2
                TP-LINK_E6395C   Pass   2
                      Dante_88   Pass   2
                        RG60SE   Open   2
                       default   Open   2
                        WIFI99   Pass   1
                         Zsoka   Pass   1
                           IKO   Pass   1

cs0rbagomba@ramen ~ $

PS: TP-Link01 Open - sharing is caring 🙂 default settings rulz

Tagged as: 1 Comment
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

globally recognized avatar – gravatar

The comment from peterhajdu made me wonder how could he have an avatar picture, without uploading or linking any images.

The solution was gravatar which allows to link an e-mail to a picture.

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