Skip to content

Instantly share code, notes, and snippets.

View soren's full-sized avatar

Søren Lund soren

View GitHub Profile
@soren
soren / JavaCodeSample.java
Created October 7, 2013 10:47
Example of my Java code formatting rules.
package net.twonky.demo;
import java.util.HashMap; // Always import fully qualified packages
import java.util.Map; // The imports should be sorted alphabetically
// import third party classes here, e.g. import oracle.jdbc.pool.OracleConnectionCacheImpl;
// import you own classes here, e.g. import net.twonky.demo.StringUtil;
/**
@soren
soren / WordCount.java
Created October 29, 2013 11:51
A Hadoop Word Count example using built-in map and reduce classes. Tested with Java 1.6 and Hadoop 1.0.4.
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
@soren
soren / MyWordCount.java
Last active December 26, 2015 21:08
A Hadoop Word Count example using my own map and reduce classes. Tested with Java 1.6 and Hadoop 1.0.4.
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
@soren
soren / wc_reducer.pl
Created November 22, 2013 07:42
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.
#!/usr/bin/env perl
use warnings;
use strict;
my $current_word = "";
my $current_count = 0;
while (<>) {
chomp;
@soren
soren / WordCount.pm
Last active December 29, 2015 01:49
A Hadoop Word Count example implemented in Perl using Hadoop::Streaming. Tested with Java 1.6 and Hadoop 1.0.4.
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 / wc_mapper.pl
Created November 22, 2013 07:39
A Perl Word Count mapper script. Can be used as a mapper in Hadoop using the Streaming interface. Tested with Java 1.6 and Hadoop 1.0.4.
#!/usr/bin/env perl
use warnings;
use strict;
while (<>) {
chomp;
print lc $_,"\t1\n" foreach split /[\s.,:;!?]+/;
}
@soren
soren / wc2_mapper.pl
Created November 22, 2013 13:49
A Hadoop Word Count example implemented in Perl using Hadoop::Streaming. Tested with Java 1.6 and Hadoop 1.0.4.
#!/usr/bin/perl -I./lib.jar
use My::Hadoop::WordCount;
My::Hadoop::WordCount::Mapper->run();
@soren
soren / wc2_reducer.pl
Last active December 29, 2015 02:19
A Hadoop Word Count example implemented in Perl using Hadoop::Streaming. Tested with Java 1.6 and Hadoop 1.0.4.
#!/usr/bin/perl -I./lib.jar
use My::Hadoop::WordCount;
My::Hadoop::WordCount::Reducer->run();
@soren
soren / AltMouseWindowMove.ahk
Created December 30, 2013 08:40
Move Windows by holding Alt and clicking (and holding) the left mouse button anywhere in the window.
; 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.

reStructuredText Demo

This is reStructuredText, a simple lighteight markup language that is readable in source form.

See also Markdown and Wikipedia