Skip to content

Instantly share code, notes, and snippets.

View lambda-fairy's full-sized avatar
💜
Hello!

Chris Wong lambda-fairy

💜
Hello!
View GitHub Profile
@lambda-fairy
lambda-fairy / chara.md
Created June 21, 2016 02:19
Chara design ideas

Design goals

  • Perfect C compatibility

    • Every C type is a Chara type and vice versa
    • Use a similar compilation model
  • Stay simple: don't add super advanced features like C++ or Rust

  • Clean up C cruft

  • Undefined integer overflow
@lambda-fairy
lambda-fairy / observer.js
Created June 9, 2016 08:49
Mutation observers on Facebook
var observer = new MutationObserver(records => {
for (var record of records) {
for (var node of record.addedNodes) {
// TODO: do something with the node
}
}
})
// TODO: is there a cleaner way to do this?
var hookMeUp = () => {
var feed = document.querySelector('#stream_pagelet > :last-child > div')
Expected to timeout, but passed: (15)
fast/dom/StyleSheet/stylesheet-move-between-documents-crash.html
fast/dom/htmlcollection-reachable.html
fast/dom/minor-dom-gc.html
fast/frames/cached-frame-counter.html
http/tests/security/w3c/cross-origin-objects.html
imported/web-platform-tests/html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-auto.html
imported/web-platform-tests/html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-fixed.html
imported/web-platform-tests/html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-percentage.html
imported/web-platform-tests/html/rendering/replaced-elements/svg-embedded-sizing/svg-in-object-auto.html
@lambda-fairy
lambda-fairy / Elo.hs
Created November 10, 2015 03:19
Elo rating code
module Elo where
updateRating :: Double -> Double -> Double -> Double -> Double
updateRating volatility me you result = me + change
where
change = volatility * (result - expected)
expected = 1 / (1 + (10 ** ((you - me) / 400)))
@lambda-fairy
lambda-fairy / 00-spec.md
Last active August 29, 2015 14:24
Rock Paper Scissors Protocol 1.0

Flow

Handshake

  1. Client: ayy
  2. Server: lmao

Game start

  1. Server: come
@lambda-fairy
lambda-fairy / m-expr.txt
Last active August 29, 2015 14:24
M-expression desugaring
f x y z => f[x, y, z]
f : g : x => f[g[x]]
{x, y, z} => Do[x, y, z]
----------------
If (x == 0) {
Say['Hello!']
@lambda-fairy
lambda-fairy / 00-setup.md
Last active April 9, 2017 00:55
VPS setup instructions

SSH

  • authorized_keys
  • config
  • lyra and lyra.pub

byobu and fish and GHC

sudo apt update
sudo apt install software-properties-common
@lambda-fairy
lambda-fairy / gist:d5461755c7d98d329352
Created June 19, 2015 05:25
NationStates 429 response
HTTP/1.1 429 Too Many Requests
Date: Fri, 19 Jun 2015 05:23:47 GMT
Server: Apache
Retry-After: 900
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<h1 style="color:red">Too Many Requests From Your IP Address</h1>
#!/usr/bin/env python3
from collections import defaultdict
from functools import lru_cache
import string
cipher = ["BUGVIOVBGB", "QVAZHBGOLO", "UMCKVQHLBQ", "XBQMVGDXGU", "TDDDOUJWCZ",
"TIWQKKGXTX", "QQCCQKULXU", "CVVOQQZGZD", "UVGCGITVTQ", "VRHGOBBVKK"]
@lambda-fairy
lambda-fairy / affixes.py
Last active August 29, 2015 14:19
Affixes
#!/usr/bin/env python3
names = set(map(str.strip, open('names.txt')))
affixes = ['rust', 'rs']
separators = ['_', '-']
n_affixed = 0
n_strippable = 0
for name in names: