Skip to content

Instantly share code, notes, and snippets.

@ColonelJ
ColonelJ / ApprovalChecker.sol
Created Apr 1, 2021
ERC20 approval frontrunning prevention detector
View ApprovalChecker.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
@ColonelJ
ColonelJ / tron_privkey_to_address.py
Created Oct 26, 2019
TRON private key to address
View tron_privkey_to_address.py
import sys
import ecdsa
import hashlib
import base58
from sha3 import keccak_256
def privkey_to_address(privkey):
privkey = bytes.fromhex(privkey)
s = ecdsa.SigningKey.from_string(privkey, curve = ecdsa.SECP256k1)
pubkey = s.verifying_key.to_string().hex()
@ColonelJ
ColonelJ / SafeMath.sol
Last active Aug 31, 2019
Tronpix smart contract
View SafeMath.sol
pragma solidity ^0.5.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
@ColonelJ
ColonelJ / gist:851875ed3a37dd6e10d4
Created Jan 11, 2015
TDM-GCC set Dwarf-2 binaries as the default (batch file). Also, delete cc.exe if it is present!
View gist:851875ed3a37dd6e10d4
copy c++-dw2.exe c++.exe
copy cpp-dw2.exe cpp.exe
copy g++-dw2.exe g++.exe
copy gcc-ar-dw2.exe gcc-ar.exe
copy gcc-dw2.exe gcc.exe
copy gcc-nm-dw2.exe gcc-nm.exe
copy gcc-ranlib-dw2.exe gcc-ranlib.exe
copy gcov-dw2.exe gcov.exe
copy mingw32-c++-dw2.exe mingw32-c++.exe
copy mingw32-g++-dw2.exe mingw32-g++.exe
View test.elm
import Window
main : Signal Element
main = display <~ Window.dimensions
display (w, h) = flow down [width w <| centered txt1, width w <| centered txt2]
txt1 = toText "Reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally long string"
txt2 = toText "Hello world"
@ColonelJ
ColonelJ / Elm example: Multitab GUI
Last active Aug 29, 2015
Elm Example: basic multitabbed text entry form
View Elm example: Multitab GUI
import Graphics.Input (input, button, Input)
import Graphics.Input.Field (input, button, defaultStyle, noContent, Content)
import Graphics.Input.Field
import Graphics.Element
import List
import Dict (Dict)
import Dict
import Maybe (maybe)
data DDict k v = DDict v (Dict k v)
View map2gen.v
Inductive bvec (T : Set) : nat -> Set :=
| BLeaf : T -> bvec T 0
| BNode log2len : bvec T log2len -> bvec T log2len -> bvec T (S log2len).
Definition bvec_leaf T (v : bvec T 0) := let 'BLeaf a := v in a.
Definition bvec_l T n (v : bvec T (S n)) := let 'BNode n l _ := v in l.
Definition bvec_r T n (v : bvec T (S n)) := let 'BNode n _ r := v in r.
Fixpoint zip (T U V : Set) (f : T -> U -> V) n (u : bvec T n) :=
match u in bvec _ n return bvec U n -> bvec V n with