Skip to content

Instantly share code, notes, and snippets.

View emberian's full-sized avatar

emberian

View GitHub Profile
module Support
module Mocks
class Irc < Travis::Task::Irc::Client
def wait_for_numeric
# no-op
end
end
end
end
from mongoengine import *
class Foo(Document):
pass
Foo.children = ListField(ReferenceField(Foo))
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "fastlz.h"
int main(void){
unsigned char foo[] = {0,26,5,1,0,0,0,0,0,0,0,1,0,0,0,246,0,0,0,247,0,0,0,0,0,0,0,1,0,2};
data = """
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
from mongoengine import Document
def to_dict(doc, include_id=True):
"""Turn a mongoengine object into a dict
mongoengine has no way to gather which attributes of a given object is a
field or is part of its own data. So, in order to serialize a document
into JSON, magic needs to be done.
This is not recursive, linked or embedded documents are likely to fail.
#include <stdio.h>
#include <stdlib.h>
unsigned long long int foo(short int a, short int b) {
if (a == 0 || b == 0) return 1;
return foo(a-1, b) + foo(a, b-1);
}
void main(int argc, char *argv[]) {
short int a;
@emberian
emberian / gist:3198760
Created July 29, 2012 13:25
Workstation cpuinfo, meminfo, lspci
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz
stepping : 9
microcode : 0x10
cpu MHz : 1600.000
cache size : 8192 KB
physical id : 0
number = 1
#creates the nth triangle number
def triangle(number):
return (number * (number + 1)) / 2
#finds factors for triangle numbers
def factors(number):
num_factors = 0
for i in xrange(1, int(number**0.5) + 1):
diff --git a/main.c b/main.c
index d1f81f5..4406444 100644
--- a/main.c
+++ b/main.c
@@ -3,10 +3,10 @@
unsigned int arena[30000];
-typedef struct {
+struct opcode {
@emberian
emberian / logic1.xml
Created September 1, 2012 23:36
Logic Circuit XML Representations
<circuit>
<output id="0">
<xor>
<and>
<input id="a" />
<input id="b" />
</and>
<not>
<input id="c" />
</not>