Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
class QuerySetDoubleIteration(Exception): | |
"A QuerySet was iterated over twice, you probably want to list() it." | |
pass | |
# "Skinny" here means we use iterator by default, rather than | |
# ballooning in memory. | |
class SkinnyManager(Manager): | |
def get_query_set(self): | |
return SkinnyQuerySet(self.model, using=self._db) |
#!/bin/sh | |
# ================================================================ | |
# | |
# Convert a mysql database dump into something sqlite3 understands. | |
# | |
# Adapted from | |
# http://stackoverflow.com/questions/489277/script-to-convert-mysql-dump-sql-file-into-format-that-can-be-imported-into-sqlit | |
# | |
# (c) 2010 Martin Czygan <martin.czygan@gmail.com> |
### possible_moves = ['e':0, 'n':0, 'w':0, 's':0, 'halt':0] | |
### extra = {} # pass info to others if needed | |
class Strategies: | |
INITIAL_MOVES = dict([(m, 0) for m in AIM.keys()]) | |
@classmethod | |
def best_option(cls, moves): | |
return max(list(moves.keys()), key=lambda d: moves[d]) |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# the admin password for all of the IE VMs is “Password1″ without the quotes, it's also used for the password hints | |
1) Install VirtuaBox on your mac | |
http://download.virtualbox.org/virtualbox/4.1.10/VirtualBox-4.1.10-76795-OSX.dmg | |
2) Decide which versions of Internet Explorer you want to download and install – each version of Internet Explorer is contained within a separate virtual machine that runs within VirtualBox. In other words, if you want to run Internet Explorer 7, 8, and 9, you will need to download three separate VM’s, which may take a while so keep that in mind. Select the text below and copy it: | |
# Install ALL versions of Internet Explorer: IE 7, IE 8, and IE 9 (for now this script will also pull down a IE 6 vm with windows xp) |
] wc -l domains.txt | |
783 domains.txt | |
] time go run domain_lookup_parallel.go | |
real 0m5.743s | |
user 0m0.359s | |
sys 0m0.355s | |
] time go run domain_lookup_sequential.go |
function SomeConstructor (request, npm, monk) { | |
// do something with the injected node modules | |
} | |
var instance = require('./injector')(SomeConstructor) // create a new instance with dependencies injected |
--- context_hello_world.c 2013-10-23 19:47:07.000000000 -0400 | |
+++ context_hello_world1.c 2013-10-23 19:47:13.000000000 -0400 | |
@@ -7,8 +7,11 @@ | |
#define STACKSIZE 4096 | |
+ucontext_t main_context; | |
+ | |
void f(){ | |
printf("Hello World\n"); |
#include <ucontext.h> | |
#include <sys/types.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#define STACKSIZE 4096 | |
void f(){ |