Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
use strict;
use warnings;
# get a command name, or bail out if the user didn't supply one
my $name = $ARGV[0] or die "must supply a command name";
# get the 'which' output for the user-supplied command name
chomp( my $which_output = `which $name` );
#!/usr/bin/perl
use strict;
use warnings;
# github.com/dbbolton
#
# simple "truth table" evaluator
for my $i (0..1) {
for my $j (0..1) {
@dbb
dbb / fancy_urxvt
Created January 18, 2011 23:07
urxvt with transparency, blur, Xft font, etc
urxvt.perl-ext-common: default,tabbed,matcher,searchable-scrollback
urxvt*cutchars: "()*,<>[]{}|'
urxvt*termName: rxvt-unicode
urxvt*urlLauncher: iceweasel
urxvt*matcher.button: 1
urxvt*keysym.S-Prior: ^[[5;2~
urxvt*keysym.S-Next: ^[[6;2~
urxvt*geometry: 100x30
urxvt*highlightSelection: true
@dbb
dbb / gist:832973
Created February 17, 2011 23:32
carta options
Usage: carta [SYMBOL] [OPTIONS]
Symbol is required and case-insensitve;
Configuration:
You can set default options, the image viewing application, and down-
loading application in the top lines of the script file itself. The
default viewer is 'feh', and the default downloader is 'curl'.
Basic options:
if [[ -f $HOME/.perlbrew/init ]]; then
source $HOME/.perlbrew/init
fi
short_option=""
__perlbrew_reinit () {
echo '# DO NOT EDIT THIS FILE' > $HOME/.perlbrew/init
command perlbrew $short_option env $1 >> $HOME/.perlbrew/init
source $HOME/.perlbrew/init
@dbb
dbb / pi
Created March 14, 2011 20:10
leibniz' formula for pi
perl -wle 'for(0..10**7){if($_%2==0){$s+=(4/((2*$_)+1));}else{$s-=(4/(2*$_+1));}print$s}'
print '0b01110010 0b01100001 0b01100100'
0b01110010 0b01100001 0b01100100
perl -e 'print chr(0b01100001)'
a
print '0b01110010 0b01100001 0b01100100' | perl -lane 'print $_ for @F'
0b01110010
▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒
▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒▒
▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒
▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒█
▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█
▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒
▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒█
▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒
▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█
▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒█▒▒██▒▒▒█
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
open (my $in, '<', '/etc/passwd');
my %passwd;
while (<$in>) {
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
my $pattern = '<!-- placeholder -->';
my $text = << "EOF";
<html>
<head>