This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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 []) => [])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DatenDownloader { | |
| public void starteLangenDownload(DownloadFertigListener l) { | |
| new Thread(() -> { | |
| // download... | |
| String ergebnis = "ergebnis"; | |
| l.downloadFertig(ergebnis); | |
| }).start(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Calendar c = new GregorianCalendar(2004, 12, 12); | |
| c.get(Calendar.YEAR) ==> 2005 | |
| c.get(Calendar.MONTH) ==> 0 | |
| c.get(Calendar.DAY_OF_MONTH) ==> 12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn trans-alive? [net trans] | |
| (let [inputs (filter #(= (:trans %) (:name trans)) (:input net))] | |
| (every? (fn [input] | |
| (<= (:weight input) | |
| (:token (some #(= (:name %) (:name input)) #{})))) | |
| inputs))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| }]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def make_function(string): | |
| from math import * | |
| def f(x): | |
| return eval(string) | |
| return f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /******************** | |
| * 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. | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*************** | |
| * 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! | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
OlderNewer