Skip to content

Instantly share code, notes, and snippets.

View ChrisCalderon's full-sized avatar

Chris Calderon ChrisCalderon

View GitHub Profile
@ChrisCalderon
ChrisCalderon / .bashrc
Created September 8, 2016 00:00
Automatically enter python 'virtualenv's with these scripts.
### Add these to your .bashrc
function new_prompt(){
if [ -r bin/activate ]; then
. bin/activate
elif check_pyenv ; then
:
elif [ "$(type -t deactivate)" = "function" ]; then
deactivate
fi
}
@ChrisCalderon
ChrisCalderon / mk-pass.py
Created September 2, 2016 04:32
mk-pass: a simple password generator
#!/usr/bin/env python3
# -*- mode: python -*-
import random
import argparse
import sys
from string import ascii_letters
from string import digits
from string import punctuation
import os
@ChrisCalderon
ChrisCalderon / setup.py
Created August 11, 2016 20:41
Universal setup.py
from __future__ import print_function
from setuptools import setup
import os
import sys
if sys.version_info >= (3, 0):
from functools import reduce
class SetupError(Exception):
@ChrisCalderon
ChrisCalderon / crowdsale.se
Created June 10, 2016 16:27
A crowdsale similar to the one Augur did.
# -*- mode: python -*-
macro TOTAL_TOKEN_COUNT: 11000000 # replace this with your token amount
macro sale_ongoing(): sload(1)
macro tokens_claimed(): sload(msg.sender)
def init():
sstore(0, msg.sender) # stores the address to send money to after crowdsale
sstore(1, 1)
@ChrisCalderon
ChrisCalderon / delegatecall_test.py
Created June 9, 2016 23:33
Demos delegatecall in serpent
import serpent
from ethereum import tester as t
code = '''\
def foo(x, flag):
with prefix = 0:
if flag == "double":
prefix = 0x6ffa1caa*2**248
else:
prefix = 0x70cd69ae*2**248
# -*- mode: python -*-
def foo(x, flag):
with prefix = 0:
if flag == "double":
prefix = "\x6f\xfa\x1c\xaa"
else:
prefix = "\x70\xcd\x69\xae"
delegate_calldata = alloc(36)
with out = alloc(32):
mstore(ref(delegate_calldata), prefix / 2**248)
@ChrisCalderon
ChrisCalderon / load_contract.py
Created April 10, 2015 23:56
Adds a contract to the blockchain using geth
#!/usr/bin/python2
import serpent
import socket
import sys
import json
coinbase = '0x5437fb967926e559c08dcfcb39eb3a224fecadae'
data = json.dumps({
'jsonrpc': '2.0',