This file contains 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
pragma solidity ^0.4.0; | |
contract HexEncoding { | |
function hexEncodeTest(address addr) returns (bytes32 ret) { | |
uint x = uint(addr) / 2**32; | |
// Nibble interleave | |
x = x & 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff; | |
x = (x | (x * 2**64)) & 0x0000000000000000ffffffffffffffff0000000000000000ffffffffffffffff; |
This file contains 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
// Async FizzBuzz -- implemented using only callbacks | |
// | |
// node --stack-size=100000 ./async-fizzbuzz.js | |
// | |
// Wrap process.stdout.write | |
const print = (message, callback) =>{ | |
process.stdout.write(message, callback) | |
} |
This file contains 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
pragma solidity ^0.4.8; | |
import "../lib/Owned.sol"; | |
import "../lib/SafeMath.sol"; | |
// This contract can be used when a smart contract has a | |
// role that can be fullfilled by one account, but you would | |
// like several accounts to fullfill the role. | |
contract Multiplexer is Owned { |
This file contains 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
contract Owned { | |
address public owner; | |
function Owned() { | |
owner = msg.sender; | |
} | |
modifier onlyOwner() { | |
if (msg.sender != owner) { | |
throw; |
This file contains 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/env python3 | |
from os import urandom | |
# Damm's weakly totally antisymetric quasigroup of order 10 | |
# https://en.wikipedia.org/wiki/Damm_algorithm | |
Damm = [ | |
[0, 3, 1, 7, 5, 9, 8, 6, 4, 2], | |
[7, 0, 9, 2, 1, 5, 4, 8, 6, 3], | |
[4, 2, 0, 6, 8, 7, 1, 3, 5, 9], | |
[1, 7, 5, 0, 9, 8, 3, 4, 2, 6], |
This file contains 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
/* global WebAssembly */ | |
import wast2wasm from 'wast2wasm'; | |
// Run with: babel-node --expose-wasm ./wasm.js | |
const wast = `(module | |
(func $fac (param i32) (result i32) | |
get_local 0 | |
i32.eqz | |
if i32 |
This file contains 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
pragma solidity 0.4.20; | |
// pragma experimental ABIEncoderV2; // Does not affect outcome | |
contract Test { | |
function test1() public pure returns (bool) { | |
bytes32 hash1 = keccak256("abc", "def"); | |
bytes32 hash2 = keccak256("abcd", "ef"); | |
return hash1 == hash2; // Returns true | |
} |
This file contains 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
pragma solidity 0.4.20; | |
contract StructuredHashes { | |
struct Order { | |
address maker; | |
address taker; | |
address makerToken; | |
address takerToken; | |
address feeRecipient; |
This file contains 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
contract BloomNuke { | |
function nuke() { | |
assembly { | |
log4(0, 0, 0, 1, 2, 3) | |
log4(0, 0, 4, 5, 6, 7) | |
log4(0, 0, 8, 10, 11, 12) | |
log4(0, 0, 13, 14, 15, 16) | |
log4(0, 0, 17, 18, 19, 20) | |
log4(0, 0, 21, 22, 23, 24) | |
log4(0, 0, 25, 27, 28, 29) |
This file contains 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
// Simple lending contract demostrating complex call-stack | |
// dependant state invariants. | |
// @author Remco Bloemen <remco@0xproject.com> | |
pragma solidity ^0.4.25; | |
// Simple non-reentrant version. (Or actually, the innermost call is responsible for paying back everyone.) | |
contract Lending1 { | |
constructor () public payable { |
OlderNewer