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
/* 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
#!/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
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
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
// 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.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; |
NewerOlder