This file contains 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
OpenReadCompletedEventHandler GetGenericOpenHandler<T>(ObservableCollection<T> destination, Func<XElement, IEnumerable<T>> elementQuery) | |
{ | |
return (object sender, OpenReadCompletedEventArgs e) => | |
{ | |
XElement xmlResult = this.GetXmlResult(e); | |
foreach (T result in elementQuery(xmlResult)) | |
{ | |
destination.Add(result); | |
} | |
}; |
This file contains 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
// Patchwork | |
void setup() | |
{ | |
size(640, 640, P3D); | |
noStroke(); | |
initialize(); | |
} | |
void initialize() |
This file contains 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
import re | |
import sys | |
i = sys.stdin.readline() | |
print "%.2f" % sum( [ x*y for x, y in zip([int(a) for a in re.match(r'(\d+)h (\d+)m (\d+)s', i).groups()], (1, 1/60., 1/(60.*60.))) ]) |
This file contains 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
# Copy SDLmain.m and SDLmain.h from the SDL DMG to the same directory | |
# To get decent framerates edit line 171 on ui_sdl.c and enter | |
# return SDL_GetTicks() / 3; | |
# ( source for that trick: http://lgo900.wordpress.com/2011/12/25/running-ibniz-on-mac-os-x/ ) | |
CC=gcc | |
EXE=ibniz | |
LFLAGS=-framework SDL -framework Cocoa | |
FLAGS=-I/Library/Frameworks/SDL.Framework/Headers | |
all: ibniz |
This file contains 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
Observable.FromEvent<MapDragEventArgs>(Map, "MapPan") | |
.Publish(mapPan_ => | |
{ | |
mapPan_.Subscribe( _ => | |
Observable.Timer(TimeSpan.FromMilliseconds(500)) | |
.TakeUntil(mapPan_) | |
.Subscribe(__ => Debug.WriteLine("Timeout")) | |
); | |
return mapPan_; |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Reactive; | |
using System.Reactive.Linq; | |
using System.Reactive.Concurrency; | |
using System.Reactive.Subjects; | |
namespace ReactiveTest |
This file contains 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
# wat am i doing wrong here? | |
def setUp(self): | |
cursor = connection.cursor() | |
script = open('epic/sql/player.sql').read() | |
cursor.execute(script) | |
transaction.commit_unless_managed() | |
def tearDown(self): | |
cursor = connection.cursor() |
This file contains 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
# -*- coding: utf-8 | |
import random | |
class APIHandler(object): | |
def __init__(self): | |
self.queue = list() | |
def do_api_request(self, *args, **kwargs): | |
# tässä koko kupletin juoni. työnnetään paikallisesti määritelty |
This file contains 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
from functools import wraps | |
def db(selector): | |
def _funcall(function): | |
@wraps(function) | |
def _wrapper(row): | |
got_args = { | |
'primary': { '1': ('baba', 15), '2': ('gaga', 16) }, | |
'secondary': { '1': ('foo', 17), '2': ('bar', 18) }, | |
} |
This file contains 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 multiple-of [number divisor] (and (not (= number divisor)) | |
(= (mod number divisor) 0))) | |
(defn not-multiples-or-1 [numbers divisor] | |
(filter (fn [n] | |
(and | |
(not (= n 1)) | |
(not (multiple-of n divisor)))) numbers)) | |
(defn primes-in-decreasing-seq [n] (reduce not-multiples-or-1 n (range 2 (Math/sqrt (first n))))) |