Small apps

simple small apps for doing daily stuff

quick reload of ~/.gtkrc-2.0


// code ripped from gtkchtheme
// gcc -o regtk `pkg-config --cflags --libs gtk+-2.0` regtk.c
#include <glib.h>
#include <gtk/gtk.h>

int main (int argc, char *argv[]) {
    gtk_init(&argc, &argv);
    GdkEventClient event =
    { GDK_CLIENT_EVENT, NULL, TRUE, gdk_atom_intern("_GTK_READ_RCFILES",
            FALSE), 8 };
    gdk_event_send_clientmessage_toall((GdkEvent *) & event);
return0;
}

view all changes of specified file in perforce

shows diffs between each 2 successive revisions
e.g., having file with revisions 1,2,3 we'll get diff 1-2, diff 2-3

#!/usr/bin/perl
$f=$ARGV[0];

$p4out = `p4 changelists $f`;

@lines = split (/\n/, $p4out);
foreach (@lines) {
/^Change ([0-9]+) on ([0-9\/]+) by ([^ ]+). '(.*)'/;
$change = $1;
$date = $2;
$author = $3;
$comment = $4;
if ($prev) {
$diff = `p4 diff2 -u $f\@$change$f\@$prev`;
print (">>>>>>>> change #$change on $date by $author '$comment'\n");
print ($diff);
    }
$prev = $change;
}

show diffs for specified number of latest perforce changesets affecting files containing specific substring in their names


#!/usr/bin/perl
$f=$ARGV[0];
$num=$ARGV[1];

$p4out = `p4 changes -m $num`;

%aff = ();

@lines = split (/\n/, $p4out);
foreach (@lines) {
    /^Change ([0-9]+) on ([0-9\/]+) by ([^ ]+). '(.*)'/;
    $change = $1;
    $date = $2;
    $author = $3;
    $comment = $4;
    print STDERR "processing change #$change\n";
    $descr = `p4 describe -du $change`;
    $stage = 0;
    $match = 0;
    foreach (split (/\n/, $descr)) {
        if ($stage == 0) {
            if (/Affected files \.\.\./) {
                $stage = 1;
                next;
            }
        }
        if ($stage == 1) {
            if (/Differences \.\.\./) {
                last;
            }
            if (/$f/ && (/\.cpp#/ || /\.h#/)) {
                $aff{$_} = $_;
                $match = 1;
            }
        }
    }
    if ($match) {
        print $descr;
    }
}

# print full list of affected files
print "-------------\nfull list of matched files:\n";
foreach (keys (%aff)) {
    print "$_\n";
}