Skip to content

Instantly share code, notes, and snippets.

View sciguy16's full-sized avatar

David Young sciguy16

View GitHub Profile
@sciguy16
sciguy16 / crewlist.sh
Last active February 13, 2017 01:24
BASH script for producing a sign in/out sheet, given a list of names on stdin
#!/bin/bash
EVENT_NAME="LOpSoc's \\emph{The Mikado}"
HANDLE=`mktemp crew.XXXXXX`
NUM_COLUMN_PAIRS=8
NUM_COLUMNS=`echo "${NUM_COLUMN_PAIRS} * 2" | bc`
EXTRA_ROWS=10
COLUMN_STYLE="|l|"
@sciguy16
sciguy16 / gasException.sol
Created February 10, 2017 10:43
the gasException contract deliberately causes the call to A to fail by using up enough gas that there is not enough left for the call.
pragma solidity ^0.4.8;
contract gasException {
A a;
event print (uint _value);
function () {
print(msg.gas);
while(msg.gas > 22115) {
continue;
}
pragma solidity ^0.4.8;
contract raceCondition {
mapping (address => uint) balances;
event print (uint _value);
function sendCoin (address to, uint amount) {
if(balances[msg.sender] >= amount) {
pragma solidity ^0.4.8;
contract MutexBug {
bool functionCalled = false;
event print(uint _data);
modifier onlyOnce {
if(functionCalled == true) {
throw;
@sciguy16
sciguy16 / Reentrancy.sol
Last active February 23, 2017 12:48
Ether store that is vulnerable to reentrancy
pragma solidity ^0.4.8;
contract Reentrant {
mapping (address => uint) balances;
function deposit() payable {
balances[msg.sender] += msg.value;
}
function withdraw(uint amount) {
@sciguy16
sciguy16 / mutex_error.sol
Created February 6, 2017 18:03
mutex on recursive contract call
pragma solidity ^0.4.2;
contract A{
bool lock=false;
B b;
function f () {
if(!lock) {
b.g();
} else throw;
@sciguy16
sciguy16 / EvaluationOrder.sol
Created February 3, 2017 13:44
Contract for testing the order with which Solidity evaluates arguments to functions. This is explicitly declared to be unpredictable in the documentation.
pragma solidity ^0.4.2;
contract EvaluationOrder {
uint flag;
uint[] flags;
function EvaluationOrder(){
flag=1;
@sciguy16
sciguy16 / ModifierTest.sol
Created February 3, 2017 13:39
Contract skeleton for testing the behaviour of function modifiers in Solidity
pragma solidity ^0.4.2;
contract ModifierTest {
modifier preventFunction {
return;
_;
}
function test() preventFunction returns (uint) {
return 4;
}
}
@sciguy16
sciguy16 / rbuf.py
Last active December 9, 2016 16:03
A simple ring buffer with delay
#!/usr/bin/python3
# A simple ring buffer with delay
import sys
offset=3
buffer = [0]*10
def lines():
"Returns a generator that gives lines form stdin"
while True:
line=sys.stdin.buffer.readline()