Skip to content

Instantly share code, notes, and snippets.

Avatar

Søren Lund soren

View GitHub Profile
@soren
soren / wc_reducer.pl
Created Nov 22, 2013
A Perl Word Count reducer script. Can be used as a reducer in Hadoop using the Streaming interface. Tested with Java 1.6 and Hadoop 1.0.4.
View wc_reducer.pl
#!/usr/bin/env perl
use warnings;
use strict;
my $current_word = "";
my $current_count = 0;
while (<>) {
chomp;
@soren
soren / WordCount.pm
Last active Dec 29, 2015
A Hadoop Word Count example implemented in Perl using Hadoop::Streaming. Tested with Java 1.6 and Hadoop 1.0.4.
View WordCount.pm
package My::Hadoop::WordCount;
use Any::Moose qw(Role);
sub map {
my ($self, $line) = @_;
$self->emit(lc $_ => 1) foreach split /[\s.,:;!?]+/, $line;
}
sub reduce {
@soren
soren / wc2_mapper.pl
Created Nov 22, 2013
A Hadoop Word Count example implemented in Perl using Hadoop::Streaming. Tested with Java 1.6 and Hadoop 1.0.4.
View wc2_mapper.pl
#!/usr/bin/perl -I./lib.jar
use My::Hadoop::WordCount;
My::Hadoop::WordCount::Mapper->run();
@soren
soren / wc2_reducer.pl
Last active Dec 29, 2015
A Hadoop Word Count example implemented in Perl using Hadoop::Streaming. Tested with Java 1.6 and Hadoop 1.0.4.
View wc2_reducer.pl
#!/usr/bin/perl -I./lib.jar
use My::Hadoop::WordCount;
My::Hadoop::WordCount::Reducer->run();
@soren
soren / AltMouseWindowMove.ahk
Created Dec 30, 2013
Move Windows by holding Alt and clicking (and holding) the left mouse button anywhere in the window.
View AltMouseWindowMove.ahk
; Move Windows by holding Alt and clicking (and holding) the left mouse button anywhere in the window.
; You'll need http://www.autohotkey.com to use this script
LAlt & LButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
if EWD_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
View StaticInitialization.java
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
// There's more than one way to do it
public class StaticInitialization {
private static final Map<String, String> MAP_ONE = new HashMap<String, String>() {{
put("one", "1. first");
}};
@soren
soren / utf8.el
Created Sep 24, 2014
Getting UTF-8 to work in GNU/Emacs
View utf8.el
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(if (eq window-system 'x)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
(if (eq system-type 'windows-nt)
@soren
soren / colorize.pl
Created Oct 1, 2014
Simple Perl script that adds colors to e.g. log files using ANSI escape codes
View colorize.pl
#!/usr/bin/env perl
=head1 NAME
colorize.pl - adds colors to e.g. log files using ANSI escape codes
=head1 SYNOPSIS
colorize.pl LOGFILE
some_command | colorize.pl
@soren
soren / pwdcomposer.user.js
Created Oct 10, 2014
Password Composer 2.04
View pwdcomposer.user.js
/* vim: ts=4 noet ai :
$Id: pwdcomposer.user.js 79 2006-09-08 07:44:01Z joe $
CREDITS
=======
Inspired by Nick Wolff's bookmarklet "Generate Password"
http://angel.net/~nic/passwdlet.html
MD5 hash functions (c) Paul Johnston
View listtrimdemo.pl
#!/bin/env perl
use warnings;
use strict;
my $line = "one,two, three, four , five ";
sub print_list {
printf "[%s]\n", join(', ', @_);
}