View ScalableRewardDistribution.sol
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.24; | |
import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol"; | |
/// @title Scalable Reward Distribution | |
/// @dev ref. http://batog.info/papers/scalable-reward-distribution.pdf | |
contract ScalableRewardDistribution { | |
using SafeMath for uint256; |
View blockchain.ts
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
import { performance } from "perf_hooks"; | |
import { SHA256 as sha256 } from "crypto-js"; | |
function calculateTarget(difficulty: number): number { | |
return Math.ceil(2 ** 256 / difficulty); | |
} | |
function padLeft(str: string, to: number, chr: string): string { | |
return str.length < to ? padLeft(chr + str, to, chr) : str; | |
} |
View 3_presale.js
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
const SimpleToken = artifacts.require("./SimpleToken.sol"); | |
const PresaleCrowdsale = artifacts.require("./02-presale-multiple-rounds/PresaleCrowdsale.sol"); | |
module.exports = (deployer, network, [owner]) => { | |
return deployer | |
.then(() => deployer.deploy(SimpleToken, "Tooploox", "TPX", 18, 21000000)) | |
.then(() => deployer.deploy(PresaleCrowdsale, 10000, owner, SimpleToken.address, owner)) | |
.then(() => SimpleToken.deployed()) | |
.then(token => token.increaseApproval(PresaleCrowdsale.address, 1000000 * (10 ** 18))); | |
}; |
View ensutils-rinkeby.js
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
// STOP! | |
// Are you thinking of using this in an app? Don't! | |
// This script is designed for interactive use in the go-ethereum console. | |
// For use in an app, consider one of these fine libraries: | |
// - https://www.npmjs.com/package/ethjs-ens | |
// - https://www.npmjs.com/package/ethereum-ens | |
function namehash(name) { | |
var node = '0x0000000000000000000000000000000000000000000000000000000000000000'; | |
if (name !== '') { |
View web3Events.js
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
import Web3 from "web3"; | |
const web3 = new Web3(Web3.givenProvider); | |
const web3Events = new Web3(new Web3.providers.WebsocketProvider("wss://mainnet.infura.io/ws")); | |
const Contract = new web3.eth.Contract(ABI, ADDRESS); | |
const ContractEvents = new web3Events.eth.Contract(ABI, ADDRESS); |
View utils.js
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
function toPairs(obj) { | |
return Object.entries(obj); // ES2017 | |
} | |
describe("toPairs", () => { | |
it("transforms object to key-value pairs", () => { | |
expect(toPairs({ foo: "bar", foz: "baz" })).toEqual([ | |
["foo", "bar"], | |
["foz", "baz"] | |
]); |
View docx2pdf.py
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
import sys | |
import subprocess | |
import re | |
def convert_to(folder, source, timeout=None): | |
args = [libreoffice_exec(), '--headless', '--convert-to', 'pdf', '--outdir', folder, source] | |
process = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout) | |
filename = re.search('-> (.*?) using filter', process.stdout.decode()) |
View Dockerfile
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
RUN ["apt-get", "update"] | |
RUN ["apt-get", "install", "-y", "zsh"] | |
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true | |
# docker exec -it my-app-container /bin/zsh |
View validateType.js
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
export default function validateType(accepts) { | |
const typeExps = accepts.split(/ *, */).map(type => new RegExp(type)); | |
return file => Boolean(typeExps.find(exp => exp.test(file.type))); | |
} | |
// function onChange({ target }) { | |
// const acceptedFiles = target.files.filter(validateType("images/*, application/pdf")); | |
// } |
View storage.js
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
import storageFactory from "./storageFactory"; | |
export const localStore = storageFactory(localStorage); | |
export const sessionStore = storageFactory(sessionStorage); |
NewerOlder