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 myreduce(func, list, initial): | |
... def inner(inner_list, acc): | |
... if not inner_list: return acc | |
... else: return inner(inner_list[1:], func(acc, inner_list[0])) | |
... return inner(initial + list, 0) | |
... |
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
#! /usr/bin/env python | |
import os | |
import sys | |
usage = "USAGE: {0} path".format(sys.argv[0]) | |
if len(sys.argv) != 2: | |
print usage | |
sys.exit(1) |
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
#include <stdio.h> | |
typedef struct Point { | |
int x; | |
int y; | |
} Point; | |
Point *create_point(int x, int y, Point *point) | |
{ | |
//point = struct Point; |
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
class A(object): | |
def foo(self): | |
print(1) | |
class B(object): | |
def foo(self): | |
print(2) | |
class C(A, B): | |
@staticmethod |
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
"""School.students migration script.""" | |
from pymongo import MongoClient | |
conn = MongoClient("mongodb://localhost:27017") | |
db = conn.school | |
students = db.students | |
for student in students.find(): |
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
# Andrew Erlichson | |
# MongoDB | |
# script to start a sharded environment on localhost | |
# clean everything up | |
echo "killing mongod and mongos" | |
killall mongod | |
killall mongos |
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
fun {Prefix L1 L2} | |
case L1 | |
of H|T then | |
if H == L2.1 then {Prefix T L2.2} | |
else false end | |
[] nil then true | |
end | |
end | |
fun {FindString L1 L2} |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import time | |
from ecs import Component, Entity, EntityManager, System, SystemManager | |
class MovementSystem(System): | |
"""Movement system to update position of Movable components.""" |
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
#!/usr/bin/python | |
import argparse | |
import os | |
import sys | |
from subprocess import check_output, CalledProcessError | |
def parse_args(): | |
parser = argparse.ArgumentParser() |
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
#!/bin/sh -e | |
PROG="${0##*/}" | |
usage() { | |
echo -e "Usage: ${PROG} ACTION FILE\n" | |
echo " ${PROG} moves or copies FILE to /usr/portage/distfiles and sets proper umask." | |
echo " ACTION: action {cp, mv}." | |
echo -e " FILE: path to file.\n" | |
echo " You mustn't run this script with root privileges." |