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
In [10]: def adventure(): | |
....: print 'there is cupcake. do you eat it?' | |
....: x = (yield) | |
....: if x: | |
....: print 'the cupcake is tasty' | |
....: print 'is this awesome?' | |
....: x = (yield) | |
....: if x: | |
....: print 'awesome!!' | |
....: while True: |
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 enumerated_casemap(case_handlers, things): | |
i = 0 | |
for x in things: | |
for p, f in case_handlers: | |
if p(x): | |
yield f(i, x) | |
i += 1 | |
break | |
def main(): |
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_display(): | |
def naturals(): | |
i = 0 | |
while True: | |
yield i | |
i += 1 | |
i = iter(naturals()) | |
def display(a, b): |
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
import itertools | |
from collections import defaultdict | |
GRID_SIZE = 3 | |
on_grid = lambda (a, b) : (0 <= a < GRID_SIZE) and (0 <= b < GRID_SIZE) | |
def gen_neighbours((a, b)): | |
for i, j in itertools.product((-1, 0, 1), repeat=2): | |
a_prime = a + i |
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
// goal: typeDefinitions = {"FIDO" : {864 : ["SUPER_864"]}, "SPOT" : {432 : ["LUCKY_SPOT_432"], 576 : ["MERRY_SPOT_576"]}} | |
// works with g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 | |
// | |
// g++ -Wall -Werror -pedantic -Wconversion --std=c++0x % && ./a.out | |
#include <vector> | |
#include <map> | |
#include <tuple> | |
#include <utility> |
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
import numpy | |
import py.test | |
MIN_SIZE = 2 # you cant have an unsorted array of size 1 ! | |
MAX_SIZE = 1000 | |
def is_sorted(a): | |
sa = numpy.sort(a) | |
return numpy.all(sa == a) |
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
this is the way to go: | |
https://wiki.debian.org/skype | |
it Just Worked. | |
to enable your mic, open `mate-volume-control` and ensure the input device is unmuted... | |
this is also interesting: it gives you a way to meddle with webcam brightness / contrast / sharpening filters: |
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
# HG changeset patch | |
# User Reuben Fletcher-Costin <[email protected]> | |
# Date 1409866198 -36000 | |
# Fri Sep 05 07:29:58 2014 +1000 | |
# Branch windows_support | |
# Node ID 88290ca7505a15b8f4a1fe1a4f94fafebd747d8e | |
# Parent 9051b4b72737edcd7b483716471c070c917c5fde | |
windows_support - use setuptools console_scripts entry point; combine wake.py and vulture into vulture.py | |
diff --git a/ez_setup.py b/ez_setup.py |
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
""" | |
a stupid population model | |
Simplifying assumptions: | |
assume everyone in each country behaves the same | |
everyone lives until their birth life expectancy | |
everyone has same number of kids [1] | |
uniform life expectancy (take geom average men and women) [2m 2f] | |
everyone pair-bonds into a couple and has kids |
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
<?xml version="1.0" encoding="utf-8" standalone="no"?> | |
<!--This file represents the results of running a test suite--> | |
<!--example comment--> | |
<!--another example comments. TFS VSO is a wonderful and intuitive test collection and reporting tool. --> | |
<test-results name="C:\Program Files\NUnit 2.6\bin\tests\mock-assembly.dll" total="2" errors="0" failures="1" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2015-10-07" time="11:22:00"> | |
<environment nunit-version="" clr-version="" os-version="Microsoft Windows NT 6.1.7600.0" platform="Any CPU" cwd="C:\Program Files\NUnit 2.6\bin" machine-name="CHARLIE-LAPTOP" user="charlie" user-domain="charlie-laptop" /> | |
<culture-info current-culture="en-US" current-uiculture="en-US" /> | |
<test-suite type="Assembly" name="FOO" executed="True" result="Failure" success="False" time="0.094" asserts="0"> | |
<results> | |