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
def set_bipartitioning_combinations(iterable): | |
return ( (i, j) for i in itertools.permutations(iterable, len(iterable) / 2) | |
for j in itertools.permutations(iterable, len(iterable) / 2) | |
if set(i).union(j) == set(iterable) ) |
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
protected void LoadFeedByName(string name, OpenReadCompletedEventHandler handler) | |
{ | |
WebClient client = new WebClient(); | |
client.OpenReadCompleted += handler; | |
if (App.UriProvider.IsFeedsAvailable) | |
{ | |
client.OpenReadAsync(App.UriProvider.UriForName(name)); | |
} | |
else |
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 processing.opengl.*; | |
void setup() | |
{ | |
size(1440, 960, OPENGL); | |
background(0); | |
} | |
void star(int size) |
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() |