Skip to content

Instantly share code, notes, and snippets.

@ralexstokes
ralexstokes / RedisClient.prototype.hmset
Last active December 29, 2015 23:49
RedisClient.prototype.hmset
@@ -1033,8 +1033,15 @@ RedisClient.prototype.hmset = function (args, callback) {
callback = null;
}
- if (args.length === 2 && typeof args[0] === "string" && typeof args[1] === "object") {
+ if (args.length === 2 && (typeof args[0] === "string" || typeof args[0] === "number") && typeof args[1] === "object") {
// User does: client.hmset(key, {key1: val1, key2: val2})
+ // assuming key is a string, i.e. email address
+
+ // if key is a number, i.e. timestamp, convert to string
fn foo() {
let y = if true { 4 } else { 10 };
println!("{}", y);
}
// fails; returns () from if expression, compiler suggests an else is missing
fn bar() {
let y = if true { 5 };
println!("{}", y);
}
@ralexstokes
ralexstokes / keybase.md
Created September 20, 2017 16:52
Keybase proof

Keybase proof

I hereby claim:

  • I am ralexstokes on github.
  • I am ralexstokes (https://keybase.io/ralexstokes) on keybase.
  • I have a public key ASDMmUcmwR2mJyxznMUQgkpc-DrLbLvDckXhw6pw6bAm6go

To claim this, I am signing this object:

@ralexstokes
ralexstokes / spec-calculator.clj
Last active March 10, 2018 00:29
Non-recursive prefix calculator as an excuse to try out `clojure.spec`
(ns spec-calculator.core
(:require [clojure.spec.alpha :as s]))
(def ops {'+ +
'- -
'* *
'/ /})
(defn op-for [op]
(get ops op))
@ralexstokes
ralexstokes / purity_checker.se.lll
Created May 5, 2018 23:22
Serpent compiler LLL output from purity-checker serpent file
(return 0
(lll
(with '__funid
(div (calldataload 0)
26959946667150639794667015087019630673637144422540572481103610249216
)
(seq
(set 'mask
57897811465722876096115075801844696845150819816717216876035649536196444422144
)
@ralexstokes
ralexstokes / purity_walkthrough.md
Last active June 4, 2018 19:29 — forked from paulhauner/purity_walkthrough.md
Casper LLL Purity Checker Walk-through

Casper Purity Checker LLL Walk-through

WARNING: These are notes and are not complete, they may contain errors. They certainly contain awkward language (sorry).

These are my notes from reading the Casper LLL Purity Checker currently being reviewed here: ethereum/casper#143

Specifically, the casper/contracts/purity_checker.py file.

Preamble -- Contract creation

@ralexstokes
ralexstokes / msg_hash.py
Created June 9, 2018 18:13
Port `msg_hash.se.py` to Python code.
from web3 import Web3
import rlp
from eth_tester import (
EthereumTester,
PyEVMBackend
)
from web3.providers.eth_tester import (
EthereumTesterProvider,
)
@ralexstokes
ralexstokes / merkle.py
Created January 4, 2019 15:40
A sketch of the Merkleization logic used for the Eth1.0 deposit contract and the verification logic used in the Eth2.0 beacon chain.
import hashlib
def version_check():
import sys
assert sys.version_info.major >= 3
assert sys.version_info.minor >= 6
assert sys.version_info.micro >= 5
version_check() # using hashlib features from 3.6.5
@ralexstokes
ralexstokes / toggle-grayscale.applescript
Last active February 8, 2019 17:05
Toggles grayscale mode on the display in macOS Mojave
on run {input, parameters}
tell application "System Preferences"
reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events" to tell process "System Preferences"
delay 0.1
click checkbox "Use grayscale" of group 0 of window "Accessibility"
end tell
tell application "System Preferences" to if it is running then quit
return
@ralexstokes
ralexstokes / gist:206d536fbfd7814ffbb748fcb6a8ff4d
Created February 17, 2019 22:07
some notes on `ethereum/go-ethereum` repo organization (12ca3b172)
here are the top-level directories in the geth repo at the above commmit.
(skipping some things relating to CI or repo management)
accounts - an account manager (e.g. perhaps wraps key manager and (tx) signer)
build - config/tools for building parts of this repo
cmd - the various binary commands exposed in the repo
common - series of utilities used across the codebase
consensus - defines various consensus algos, like PoW or PoA
console - bind console to geth node for CLI interaction
containers - dockerfiles