Skip to content

Instantly share code, notes, and snippets.

@aaronstjohn
aaronstjohn / uniswap_all_pairs.py
Last active October 4, 2023 07:18
All pairs uniswap query: `pip install python_graphql_client`
from python_graphql_client import GraphqlClient
import json
from pprint import pformat
from multiprocessing import Pool
import concurrent.futures
from itertools import repeat , chain
import math
import os
@aaronstjohn
aaronstjohn / SafeMath.sol
Created November 6, 2020 19:40
Safe Math for ERC20 token
pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
@aaronstjohn
aaronstjohn / ERC20_Token.sol
Created November 6, 2020 19:39
Example of an ERC20 Token implementation
pragma solidity ^0.4.24;
import "./SafeMath.sol";
/**
* @title ERC20 standard token implementation.
* @dev Standard ERC20 token. This contract follows the implementation at https://goo.gl/mLbAPJ.
* @dev Generously borrowed code from Open Zepplin Implementation at https://rb.gy/tbviaq
*/
// contract Token is
// ERC20
@aaronstjohn
aaronstjohn / 1_Storage.sol
Created October 30, 2020 00:22
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.26+commit.4563c3fc.js&optimize=false&gist=
pragma solidity >=0.4.22 <0.7.0;
/**
* @title Storage
* @dev Store & retrieve value in a variable
*/
contract Storage {
uint256 number;
def plot_decision_boundary_gpu(pred_func):
# Set min and max values and give it some padding
x_min, x_max = train_X[:, 0].min() - .5, train_X[:, 0].max() + .5
y_min, y_max = train_X[:, 1].min() - .5, train_X[:, 1].max() + .5
h = 0.01
# Generate a grid of points with distance h between them
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
X.set_value((np.c_[xx.ravel(), yy.ravel()]).astype('float32'))
#Z = pred_func(np.c_[xx.ravel(), yy.ravel()])
contract RockPaperScissors
{
enum Move {Rock,Paper,Scissors}
struct Turn
{
address player;
Move move;
uint bet;
}
struct Game