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!";
@sideb0ard
sideb0ard / seppy.c
Created February 11, 2016 16:49
string separator
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct freaky {
int num_freaks;
int *freaks;
} freaky;
freaky* new_freqs_from_string(char* string)
@sideb0ard
sideb0ard / ActivityA.java
Created April 25, 2016 02:36
Stackoverflow answer, "Singleton in Android"
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@sideb0ard
sideb0ard / bittyzzz.c
Created June 15, 2016 16:23
bitwise reverse lookup
#include <stdio.h>
int bignumz[16];
int conv_bitz(int num)
{
for ( int i = 0 ; i < 16; i++) {
//printf("Comparing %d with %d\n", num, ( 1 << i));
//printf("AND is %d\n", num & ( 1 << i));
if ( (num & ( 1 << i )) == num ) {