Skip to content

Instantly share code, notes, and snippets.

Charles Cooper charles-cooper

Block or report user

Report or block charles-cooper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View erc20.lll.py
[seq,
[mstore, 32, 1461501637330902918203684832716283019655932542976],
[mstore, 64, 170141183460469231731687303715884105727],
[mstore, 96, -170141183460469231731687303715884105728],
[mstore, 128, 1701411834604692317316873037158841057270000000000],
[mstore, 160, -1701411834604692317316873037158841057280000000000],
# Line 26
[codecopy, 320, ~codelen, 128],
[assert, [iszero, callvalue]],
[codecopy, 448, [add, ~codelen, [codeload, ~codelen]], 96],
@charles-cooper
charles-cooper / foo.lll.py
Last active Sep 13, 2019
Vyper example for talk (filenames suffixed with .py to trigger syntax highlighter)
View foo.lll.py
[seq,
[return,
0,
[lll,
[seq,
[mstore, 28, [calldataload, 0]],
[mstore, 32, 1461501637330902918203684832716283019655932542976],
[mstore, 64, 170141183460469231731687303715884105727],
[mstore, 96, -170141183460469231731687303715884105728],
[mstore, 128, 1701411834604692317316873037158841057270000000000],
@charles-cooper
charles-cooper / foo.ir
Last active Apr 6, 2019
Use solidity's assembler for fun and profit
View foo.ir
$ cat foo.ir
IR:
/*******************************************************
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
* !USE AT YOUR OWN RISK! *
*******************************************************/
View diligence_labeled.asm
# https://ethstats.io/account/0x68cb858247ef5c4a0d0cde9d6f68dce93e49c02a
PUSH1 0x80
PUSH1 0x40
MSTORE
PUSH1 0x04
CALLDATASIZE
LT
PUSH2 0x005c
JUMPI
PUSH1 0x00
@charles-cooper
charles-cooper / reorg_listener.py
Last active Feb 7, 2019
web3 client which handles reorgs and does not require node filter state
View reorg_listener.py
#!/usr/bin/env python
import asyncio, json, sys, os
import pickle
import websockets
import datetime
import time
import web3
from web3 import Web3
@charles-cooper
charles-cooper / abi.json
Last active Dec 7, 2018
Return nested structs
View abi.json
[
{
"name": "returnB",
"outputs": {
"type": "tuple",
"name": "out",
"components": [
{
"type": "bytes",
"name": "b3"
@charles-cooper
charles-cooper / sample.sql
Last active Jul 13, 2017
SQL style guide
View sample.sql
WITH y AS ( -- WITH is not indented
SELECT -- subquery on its own line and indented one level
*
FROM schema2.table2
) -- closing paren flush with WITH
SELECT -- keywords in caps
z.*,
x.id, -- columns indented, on separate lines
y.foo, -- prefixed with the table name alias if there is a join
View keybase.md

Keybase proof

I hereby claim:

  • I am charles-cooper on github.
  • I am charlescooper (https://keybase.io/charlescooper) on keybase.
  • I have a public key ASBc3MIg-ZmRXFd8_NXIsH6FfxvXAzpf8lEZLwVBNnf3mgo

To claim this, I am signing this object:

@charles-cooper
charles-cooper / filtered_query.plan
Last active Jul 15, 2016
Row based access query plans
View filtered_query.plan
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nested Loop (cost
@charles-cooper
charles-cooper / shutdown_idle.sh
Created Jun 30, 2016
Cron job to shut down an idle computer
View shutdown_idle.sh
#!/bin/sh
# This script, intended to be run as a cron job, checks if there are any logins or recent logins and shuts down if there are none. It is not intended to be portable and was written on a Ubuntu 16.04 machine.
last_login_time=$(grep "systemd-logind" /var/log/auth.log | perl -pe "s/ ip.*//" | tail -1 | date --file=/dev/stdin +%s)
if [ $(($cur_time - $last_login_time)) -ge 3600 ] && [ $(who | wc -l) -eq 0 ]
then
init 0
else
You can’t perform that action at this time.