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
charles-cooper /
Last active Apr 6, 2019
Use solidity's assembler for fun and profit
$ cat
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
View diligence_labeled.asm
PUSH1 0x80
PUSH1 0x40
PUSH1 0x04
PUSH2 0x005c
PUSH1 0x00
charles-cooper /
Last active Feb 7, 2019
web3 client which handles reorgs and does not require node filter state
#!/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 / 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 / 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.*,, -- columns indented, on separate lines, -- prefixed with the table name alias if there is a join

Keybase proof

I hereby claim:

  • I am charles-cooper on github.
  • I am charlescooper ( on keybase.
  • I have a public key ASBc3MIg-ZmRXFd8_NXIsH6FfxvXAzpf8lEZLwVBNnf3mgo

To claim this, I am signing this object:

charles-cooper / filtered_query.plan
Last active Jul 15, 2016
Row based access query plans
View filtered_query.plan
Nested Loop (cost
charles-cooper /
Created Jun 30, 2016
Cron job to shut down an idle computer
# 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 ]
init 0
charles-cooper / .profile
Created Jun 10, 2016
Default .profile for ubuntu
View .profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
charles-cooper / Main.hs
Last active Jul 6, 2016
waitForProcess bug
View Main.hs
module Main where
import System.Process
import Control.Concurrent
main :: IO ()
main = do
(_, _, _, p) <- createProcess ((shell "sleep 1") { create_group = True })
forkIO $ waitForProcess p >>= print
threadDelay 10
You can’t perform that action at this time.