Skip to content

Instantly share code, notes, and snippets.

View sideb0ard's full-sized avatar

thorsten sideb0ard sideb0ard

View GitHub Profile
REGISTER file:/home/hadoop/lib/pig/piggybank.jar;
DEFINE EXTRACT org.apache.pig.piggybank.evaluation.string.EXTRACT();
DEFINE CustomFormatToISO org.apache.pig.piggybank.evaluation.datetime.convert.CustomFormatToISO();
DEFINE ISOToUnix org.apache.pig.piggybank.evaluation.datetime.convert.ISOToUnix();
DEFINE DATE_TIME org.apache.pig.piggybank.evaluation.datetime.DATE_TIME();
DEFINE FORMAT_DT org.apache.pig.piggybank.evaluation.datetime.FORMAT_DT();
DEFINE FORMAT org.apache.pig.piggybank.evaluation.string.FORMAT();
RAW_LOGS = LOAD '$INPUT' as (line:chararray);
@sideb0ard
sideb0ard / gist:10802752
Created April 16, 2014 03:23
Pig Nginx log parser
register file:/home/hadoop/lib/pig/piggybank.jar
DEFINE EXTRACT org.apache.pig.piggybank.evaluation.string.EXTRACT;
RAW_LOGS = LOAD 's3://apiaxle-logs/*' USING TextLoader as (line:chararray);
LOGS_BASE = FOREACH RAW_LOGS GENERATE
FLATTEN(
EXTRACT(line, '^(\\S+) (\\S+) (\\S+) \\[([\\w:/]+\\s[+\\-]\\d{4})\\] "(.+?) (.+)&api_key=(.+?)(&.+)? (.+?)" (\\S+) (\\S+) "([^"]*)" "([^"]*)"')
)
as (
remoteAddr: chararray,
package main
import (
"bytes"
"fmt"
"log"
"os"
"strings"
)
package main
import (
"bytes"
"fmt"
"log"
"os"
"strconv"
)
### Keybase proof
I hereby claim:
* I am sideb0ard on github.
* I am sideb0ard (https://keybase.io/sideb0ard) on keybase.
* I have a public key whose fingerprint is 612E 4F5B 6AC2 3248 70CB 8484 24F3 D920 4EC7 80FF
To claim this, I am signing this object:
@sideb0ard
sideb0ard / heroku2psql_format_logs.pl
Last active August 29, 2015 14:07
heroku2psql_format_logs.pl
#!/usr/bin/perl -w
use strict;
use Time::Piece;
die "Ooft, mate, i need an input file\n" unless (scalar @ARGV == 1);
my $date = localtime->strftime('%m-%d-%Y');
my $infile = $ARGV[0];
my $outfile = $infile . ".$date";
open(FILE, $infile) || die "Cannae open yer file, buddy\n";
@sideb0ard
sideb0ard / philosorpator.go
Created November 18, 2014 15:53
Dining Philosoraptors with Channels as Semaphores
package main
import (
"fmt"
"math/rand"
"time"
)
type Philosopher struct{}
@sideb0ard
sideb0ard / boring.go
Created December 2, 2014 00:55
Boring go from Rob Pike, Google IO 2012
package main
import (
"fmt"
//"math/rand"
//"time"
)
type Message struct {
str string
@sideb0ard
sideb0ard / marky.go
Last active August 29, 2015 14:12
markov gold chains
package main
// bits of code gratutiously borrowed from https://golang.org/doc/codewalk/markov/
import (
"bufio"
"fmt"
"io"
"math/rand"
"os"
#cloud-config
hostname: <%= shortname %>
ssh_authorized_keys:
- ssh-rsa xxxx rsa-key-20120604
coreos:
units:
- name: settimezone.service
command: start