This file contains hidden or 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
// limit the number of events per second | |
function throttle(callback, delay) { | |
var previousCall = new Date().getTime(); | |
return function() { | |
var time = new Date().getTime(); | |
if ((time - previousCall) >= delay) { | |
previousCall = time; | |
callback.apply(null, arguments); | |
} | |
}; |
This file contains hidden or 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
$ sudo chown -R $(whoami) /usr/local |
This file contains hidden or 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 eth, miner, admin, net, web3 */ | |
// For Ethereum Networks with light activity | |
// automatically enable and disbale miner | |
// | |
// set var `thread` in global geth instance to change CPUs | |
// | |
// in geth console `geth attach` | |
// > loadScript('eth-smart-mine.js') | |
// | |
// adhered to standardjs.com/ |
This file contains hidden or 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
function supportsSvg() { | |
return document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1'); | |
} | |
function supportsObjectCreate() { | |
// | |
// Desktop | |
// Browser | Firefox | (Gecko) | Internet Explorer | Opera | Safari | |
// Basic support | 5 | 4.0 (2) | 9 | 11.60 | 5 | |
// |
This file contains hidden or 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
// Oraclize get data using `FlowCommunications/JSONPath` | |
json(https://data.ny.gov/resource/h6w8-42p9.json).[0].mega_ball |
This file contains hidden or 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
// Oraclize get data using `FlowCommunications/JSONPath` | |
// https://github.com/FlowCommunications/JSONPath#expression-syntax | |
// test with https://jsonpath.curiousconcept.com/ | |
// these APIs are public and do not require Authorization | |
// from kraken (returns String) | |
json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.[0] | |
// from cryptocompare (returns Number[Float]) | |
json(https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD).USD |
This file contains hidden or 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.10; | |
/* taking ideas from FirstBlood token */ | |
contract SafeMath { | |
/* function assert(bool assertion) internal { */ | |
/* if (!assertion) { */ | |
/* throw; */ | |
/* } */ | |
/* } // assert no longer needed once solidity is on 0.4.10 */ |
This file contains hidden or 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
// Manages contract ownership. | |
contract Owned { | |
address public owner; | |
function owned() { | |
owner = msg.sender; | |
} | |
modifier onlyOwner { | |
if (msg.sender != owner) throw; | |
_; | |
} |
This file contains hidden or 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
function loadWeb3 () { | |
let web3Injected = window.web3; | |
if(typeof web3Injected !== 'undefined'){ | |
// detect MetaMask.io | |
web3 = new Web3(web3Injected.currentProvider) | |
} else { | |
// eth node | |
web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) | |
} | |
} |
This file contains hidden or 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
// give me the raw wei | |
export function ether (_value) { | |
const value = web3.fromWei(_value, 'ether').toString(10) | |
return `Ξ\t${value}` | |
} |