Skip to content

Instantly share code, notes, and snippets.

@zengargoyle
zengargoyle / ex.pl
Created September 24, 2010 19:19
What works
#!/usr/bin/perl
use strict;
use warnings;
print "Hello World!\n";
__END__
#!/usr/bin/perl -CSDAL
#
# Usage: PROGNAME big_list.txt small_list.txt > output.txt
# -CSDAL for unicode.
use strict;
use warnings;
# should maybe have this
use locale;
@zengargoyle
zengargoyle / example.idiom.txt
Created January 7, 2011 21:41
approximate XML to Anki example.
att passa någon som handen i handske;to be right up somebody's alley
(bildligt) rycka in och hjälpa till, (omedelbart) hjälpa till;step into the breach
bli sämre;be losing one's grip
bort med tassarna!;take your paws off!
brännas på bål;be burnt at the stake
bromsa något, hejda något;put the (a) brake on something
finnas i alla former och storlekar;come in all shapes and sizes
förbarma sig över någon;take pity on somebody
för Guds skull! (informellt);for crying out loud!
försöka lyckas i världen (särskilt litterärt);seek one's fortune
@zengargoyle
zengargoyle / README
Created January 10, 2011 01:27
delete files found in second directory
Usage: perl nukedups.pl $currentfolder $oldfolder
Run once with just the print and check output for sanity. If all looks good uncomment the 'unlink' line and re-run.
This code builds a list of the MD5 sums of the files in the first directory, then deletes the files in the second directory if their MD5 sum matches one of the sums seen in the first directory.
Follow with:
find $oldfolder -depth -type d -exec rmdir {} \;
#!/usr/bin/perl
use strict;
use warnings;
my $top = shift(@ARGV) || '.';
chdir $top or die "could not chdir to $top: $!\n";
open my $find, '-|', 'find .' or die "$!\n";
my %top_must = (
Compute digram frequency of <space>a-zA-Z
<space> is signified by 'S', A-Z are mapped onto a-z.
Output: Char1Char2 Count Count/Total
...
Sf 103 0.006550
...
eo 16 0.001018
...
15724 characters # on STDERR
@zengargoyle
zengargoyle / eg.c
Created May 22, 2011 03:16
x86 assembly UTF-16 -> UTF-8 test (GAS Syntax)
int out2(unsigned short int t) {
unsigned char c[3];
unsigned char *b;
unsigned char l = 0;
b = c;
// 0000 0000 0xxx xxxx -> 0xxx xxxx
// 0000 0yyy yyxx xxxx -> 110y yyyy 10xx xxxx
// zzzz yyyy yyxx xxxx -> 1110 zzzz 10yy yyyy 10xx xxxx
if ( ! (t & 0xFF80) ) {
c[l++] = t & 0x007F;
#!/usr/bin/env perl
use strict;
use warnings;
use File::Basename;
my $cbrfile = $ARGV[0] or die "Usage: $0 <cbrfile>\n";
# get a verbose basic list of archive contents. (path/to/file.ext)
my $pid = open my $fh, '-|', rar => vb => $cbrfile
@zengargoyle
zengargoyle / gist:1479795
Created December 15, 2011 04:06
weather
#!/usr/bin/perl
use 5.014;
use warnings;
use Weather::Google;
use Data::Dump qw(pp dd);
use LWP::UserAgent;
my $gw = Weather::Google->new('Glendale, CA');
my $current = $gw->current;
@zengargoyle
zengargoyle / gist:1479829
Created December 15, 2011 04:21
simple weather
#!/usr/bin/perl
use 5.014;
use warnings;
use Weather::Google;
use Data::Dump qw(pp dd);
use LWP::UserAgent;
my $gw = Weather::Google->new('Glendale, CA');
my $current = $gw->current;