Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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:

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 / 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