Skip to content

Instantly share code, notes, and snippets.

@alexvandesande
alexvandesande / Proposal.js
Last active April 5, 2022 08:05
Proposal Framework for The DAO
/*
The contract is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The contract is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@konradkonrad
konradkonrad / solc
Last active March 5, 2020 06:03
solc from docker (sort of)
#!/usr/bin/env bash
# Usage:
# ./solc [options] inputfile > outfile
# Notes:
# - file i/o is limited to the current directory
# - this works with the pyethereum solc_wrapper
docker run -i --rm --user $(id -u):$(id -g) -v $(pwd):/tmp --workdir /tmp ethereum/solc:0.4.18 $@
@axic
axic / BigInt.sol
Created May 9, 2016 18:29
Big number library in Solidity (for modexp)
//
// Big number library in Solidity for the purpose of implementing modexp.
//
// Should have a similar API to https://github.com/ethereum/EIPs/issues/101
//
// Internally bignumbers are represented as an uint array of 128 bit values.
//
// NOTE: it assumes usage with "small" (<256bit) exponents (such as in RSA)
//
@axic
axic / stringaskey.sol
Last active July 10, 2019 00:10
How to use string as a key in a mapping in Solidity aka. how to store short strings cheape
//
// In Solidity, a mapping is like a hashmap and works with `string` like this:
// mapping (string => uint) a;
//
// However it doesn't support accessors where string is a key:
// mapping (string => uint) public a;
//
// "Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented."
//
// An accessor returns uint when called as `a(string)`.
@chriseth
chriseth / evm.js
Created March 29, 2016 14:52
EVM in EVM
contract EVM {
struct VMState {
uint[1024] stack;
uint stackHeight;
bytes bytecode;
uint pc;
uint[] mem;
}
function step(VMState _state) internal returns (bool)
{
@pbnj
pbnj / index.js
Last active September 13, 2018 20:41
Demo Command-Line Interface (CLI) Application
#!/usr/bin/env node
'use strict';
/**
* Require dependencies
*
*/
const program = require('commander'),
chalk = require("chalk"),
exec = require('child_process').exec,
pkg = require('./package.json');
@ChaunceyHoover
ChaunceyHoover / sleep.lua
Last active January 26, 2023 16:17
Lua asynchronous and synchronous sleeping
function sleep(time, func, ...)
local now = os.time()
local thread = coroutine.create(func)
repeat until (os.time() - now > time)
coroutine.resume(thread, ...)
end
function asleep(time, func, ...)
coroutine.wrap(function()
local now = os.time()
call NERDTreeAddKeyMap({'key': 't', 'callback': 'NERDTreeMyOpenInTab', 'scope': 'FileNode', 'override': 1 })
function NERDTreeMyOpenInTab(node)
call a:node.open({'reuse': "all", 'where': 't'})
endfunction
@AdamISZ
AdamISZ / tlsn-notarization-file-format.md
Last active April 3, 2023 20:27
TLSNotary notarization file format

Data format: binary. Default file extension: '.tlsn'

Contents

Field description (size in bytes) code in Python version
Header (29) 'tlsnotary notarization file\n\n'