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
>>> class Foo: | |
... def __init__(self, value): | |
... self.value = value | |
... def __nonzero__(self): | |
... return self.value | |
... | |
>>> a = Foo(1) | |
>>> b = Foo(0) | |
>>> assert a | |
>>> assert 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
>>> class Borg: | |
... __shared_state = {} | |
... def __init__(self): | |
... self.__dict__ = self.__shared_state | |
... | |
>>> a = Borg() | |
>>> b = Borg() | |
>>> a.x = 1 | |
>>> print b.x | |
1 |
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 foo: | |
pass |
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
# -*- coding: utf-8 -*- | |
import argparse | |
import json | |
import re | |
import u1db | |
from datetime import datetime | |
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
# encryptor.py | |
import sys | |
import os.path | |
from Crypto.PublicKey import RSA | |
PUBLIC_KEY = os.path.join(os.path.expanduser('~'), '.ssh/id_rsa.pub') | |
def encrypt(message): | |
with open(PUBLIC_KEY, 'r') as pub_key: |
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
# decryptor.py | |
import os.path | |
from Crypto.PublicKey import RSA | |
PRIVATE_KEY = os.path.join(os.path.expanduser('~'), '.ssh/id_rsa') | |
def decrypt(): | |
with open(PRIVATE_KEY, 'r') as prv_key: | |
decryptor = RSA.importKey(prv_key) |
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
function get_git_branch () | |
{ | |
DIRTY="" | |
CLEAN="nothing to commit (working directory clean)" | |
[ "`git status 2> /dev/null | tail -n1`" != "$CLEAN" ] && DIRTY='*' | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/⚡\1$DIRTY/" | |
} | |
PS1='\h \W$(get_git_branch)\$ ' |
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
#!/usr/bin/python2.7 | |
import json | |
import httplib | |
API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
loadavg = open('/proc/loadavg').read().split() | |
data = {'datastreams': [ |
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
#include <stdio.h> | |
int main(int argc, char const **argv) | |
{ | |
int list[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; | |
for (int i = 0; i < (sizeof(list) / sizeof(int)); i++) { | |
printf("%d\n", list[i]); | |
} | |
printf("size: %d\n", sizeof(list) / sizeof(int)); | |
return 0; |
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 drange(start, stop, step=1): | |
r = start | |
while r < stop: | |
yield r | |
r += step |