The other week I saw this post about programming competitions and how they supposedly correlate negatively to job performance. This was according to Peter Norvig.
I found this interesting because as most will know the typical work of a programmer is very different from a programming competition.
After looking around a bit I found a Hacker News post for the same blog page with some interesting comments.
Continue reading →An old Perl script for replacing a string within multiple files.
#!/usr/bin/perl
#
# Replaces a string within multiple files
# specified on the command line
#
$mv = '/bin/mv';
$op = shift || die("Usage: $0 perlexpr [filenames]\n");
print "$op\n";
print "@ARGV\n";
if (!@ARGV) {
@ARGV = <STDIN>;
chop(@ARGV);
}
foreach $file (@ARGV) {
if (!-f $file) { print "Skipping non-regular file: $file\n"; next; }
if (-B $file) { print "Skipping binary file: $file\n"; next; }
$outfile = "/tmp/$file.$$";
open(FILE, $file) || die("Couldn't open $file: $!\n"");
undef $/;
$_ = <FILE>;
close(FILE);
if (eval $op) {
open(OFILE, "> $outfile") || die("Couldn't open $outfile: $!\n");
print OFILE;
close(OFILE);
system($mv, '-f', $file, "$file.bak");
system($mv, '-f', $outfile, $file);
print "File changed: $file\n";
}
else {
print "No change to file: $file\n";
}
}
exit(0);
Continue reading →
Show the amount of disk space the larger directories under your home directory are taking.
#!/bin/sh
pushd $HOME
du -sk * | sort -nr | head
popd
Continue reading →
Travelling today. Looks like 13 hours door to door.
Continue reading →You just committed to your Git repo and realized you have a typo in your commit message. Here is how you can edit the last commit's comment.
$ git commit --amend
Continue reading →