Skip to content

Instantly share code, notes, and snippets.

View ohcibi's full-sized avatar
🕴️
Elevated

Tobias Witt ohcibi

🕴️
Elevated
View GitHub Profile
(ns bla.core-test
(:use midje.sweet))
(defn split-by-type [s] #{[1 2 3] [:a :b :c]})
(facts "about `split-by-type`"
(fact "it splits a sequence into subsequences of elements with the same type"
(split-by-type []) => []))
public class DatenDownloader {
public void starteLangenDownload(DownloadFertigListener l) {
new Thread(() -> {
// download...
String ergebnis = "ergebnis";
l.downloadFertig(ergebnis);
}).start();
}
}
Calendar c = new GregorianCalendar(2004, 12, 12);
c.get(Calendar.YEAR) ==> 2005
c.get(Calendar.MONTH) ==> 0
c.get(Calendar.DAY_OF_MONTH) ==> 12
(defn trans-alive? [net trans]
(let [inputs (filter #(= (:trans %) (:name trans)) (:input net))]
(every? (fn [input]
(<= (:weight input)
(:token (some #(= (:name %) (:name input)) #{}))))
inputs)))
requestManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:kApiURL]];
requestManager.requestSerializer = [AFHTTPRequestSerializer serializer];
[requestManager.requestSerializer setAuthorizationHeaderFieldWithToken:@"mytoken"];
AFHTTPRequestOperation * op = [requestManager GET:@"path/to/api" parameters:nil
success:^(AFHTTPRequestOperation * operation, id response) {
NSLog(@"JSON: %@", response);
} failure:^(AFHTTPRequestOperation * operation, NSError * error) {
NSLog(@"JSON: %@", error);
}];
def make_function(string):
from math import *
def f(x):
return eval(string)
return f
def chunks(l):
for i in range(0, len(l)-1):
yield l[i:i+2]
def compute_word_occurences(s):
res = {}
for (first, second) in chunks(s.strip().split()):
if first not in res:
res[first] = {}
/********************
* crispsContest.js *
********************
*
* The Algorithm is almost in our grasp!
* At long last, we will definitively establish
* that 3SAT is solvable in polynomial time. It's
* been a long, strange journey, but it will all be
* worth it.
*
/***************
* pointers.js *
***************
*
* You! How are you still alive?
*
* Well, no matter. Good luck getting through this
* maze of rooms - you'll never see me or the Algorithm again!
*/
def burrows_wheeler_forward(string):
l = []
for i in range(0, len(string)):
l.append(string[i:] + string[0:i])
l.sort()
code = "".join(map(lambda w: w[-1], l))
return code, l.index(string)