Skip to content

Instantly share code, notes, and snippets.

View sideb0ard's full-sized avatar

thorsten sideb0ard sideb0ard

View GitHub Profile
// merge calls itself recursively
def merge(l1: List[Int], l2: List[Int]): List[Int] = {
// termination cases
(l1, l2) match {
case (Nil, Nil) => Nil
case (x, Nil) => x
case (Nil, y) => y
case (_, _) => l1.head.compare(l2.head) match {
case -1 => l1.head :: merge(l1.tail, l2)
case _ => l2.head :: merge(l2.tail, l1)
@sideb0ard
sideb0ard / gist:7728607
Created December 1, 2013 04:47
simple script for converting a tsv text dump from a wordpress export to markdown files for use in a static site generator. (Hugo in this case)
#!/usr/bin/env python
from __future__ import print_function
import csv
import datetime
import re
def qtr(word):
word = re.sub('^|$','"', word)
return word
@sideb0ard
sideb0ard / gist:7745005
Created December 2, 2013 04:17
remove brackets and replace space for all files starting with 808* ( e.g. --- 808 (19).wav )
ls 808\ \(* | while read file; do mv "$file" `echo $file | sed 's/[()]//g' | sed 's/ /_/'` ; done
@sideb0ard
sideb0ard / binary_adder.rb
Last active January 2, 2016 08:39
diy binary adder
#!/usr/bin/env ruby
@rg = [0,0,0,0]
@i = 0
def adder ()
while @i < 2 ** @rg.length
puts "#{@rg}"
def add(position)
int[] colors = new int[3];
// int numColors = int(pow(2, colors.length));
void setup() {
size(1000, 240);
background(255);
}
void draw() {
#!/usr/bin/perl -w
use strict;
my @urlies;
my $URLs = "URLS.txt";
open(my $ufh, "<", $URLs) or die "canne open $URLs!\n";
my $IDs = "artIdz";
open(my $ifh, "<", $IDs) or die "DIED!\n";
@sideb0ard
sideb0ard / weepurl.pl
Created January 28, 2014 23:39
wee purly
#!/usr/bin/perl -w
use strict;
my $URL = "http://prodapi.openaura.com/info/artists/__ARTID__?id_type=oa%3Aartist_id&api_key=special-key";
my $IDs = "artIdzz";
open(my $ifh, "<", $IDs) or die "DIED!\n";
my $NEWURLS = "URLS_4_BENCH.txt";
open(my $ofh, ">", $NEWURLS) or die "DIED!";
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"
)