Skip to content

Instantly share code, notes, and snippets.

View awwong1's full-sized avatar
🕳️
some

Alexander Wong awwong1

🕳️
some
View GitHub Profile
@awwong1
awwong1 / .block
Last active November 12, 2018 18:49
D3 Workshop: Part 1 - Basic HTML, d3, and Data Binding
license: mit
@awwong1
awwong1 / fuck.js
Last active June 19, 2018 05:50
wtf firefox crypto
var pw = window.crypto.getRandomValues(new Uint8Array(16));
window.crypto.subtle.importKey("raw", pw, "PBKDF2", false, ["deriveBits"]).then(key => {
console.log(key);
var st = window.crypto.getRandomValues(new Uint8Array(16));
const keySizeBits = 2048;
// const keySizeBits = 2056; // this breaks
return window.crypto.subtle.deriveBits({ name: "PBKDF2", salt: st, iterations: 10000, hash: "SHA-256" }, key, keySizeBits);
}).then(bits => {
console.log(bits);
}).catch(err => {
const backward = "backward";
const forward = "forward";
let shadowHealth = 20;
class Player {
playTurn(warrior) {
const senseHealth = warrior.health();
const shouldPivot = warrior.feel().isWall();
# https://github.com/cleanbrowsing/dnsperftest
# NO VPN FROM HOME
➜ dnsperftest git:(master) ./dnstest.sh | sort -k 22 -n
test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 Average
cloudflare 40 ms 41 ms 29 ms 36 ms 36 ms 30 ms 29 ms 28 ms 32 ms 40 ms 34.10
level3 41 ms 42 ms 49 ms 55 ms 55 ms 52 ms 43 ms 47 ms 44 ms 43 ms 47.10
quad9 45 ms 52 ms 47 ms 42 ms 47 ms 46 ms 63 ms 52 ms 44 ms 46 ms 48.40
neustar 47 ms 46 ms 56 ms 48 ms 46 ms 58 ms 48 ms 52 ms 45 ms 56 ms 50.20
google 54 ms 45 ms 44 ms 59 ms 53 ms 74 ms 51 ms 75 ms 44 ms 56 ms 55.50
@awwong1
awwong1 / gist:32a6abb8293b32b799b8bcdbd120aaa1
Created April 7, 2018 05:27
force add separate repo as subfolder in current repo
cd path/to/project-b
git remote add project-a path/to/project-a
git fetch project-a
git merge -s ours --allow-unrelated-histories project-a/master
git read-tree --prefix=project-a/ -u project-a/master
git commit -m "Merge project-a"
git remote remove project-a
@awwong1
awwong1 / circleOfTrust.js
Last active April 2, 2018 21:49
Circle of Trust
// https://www.reddit.com/r/CircleofTrust/comments/8950o3/hash/
var encryptedPassword = new Uint8Array([254, 49, 107, 19, 58, 24, 210, 3, 23, 245, 223, 217, 18, 231, 130, 33, 66, 77, 106, 50, 105, 143, 0, 149, 128, 242, 29, 251, 207, 11, 223, 127, 128, 2, 167, 235, 206, 26, 240, 155, 205, 240, 9, 216, 213, 196, 253, 156, 141, 156, 97, 35, 179, 248, 109, 0, 249, 92, 215, 58, 246, 73, 110, 0, 79, 201]);
var initializationVector = new Uint8Array([137, 244, 179, 47, 179, 29, 74, 151, 160, 85, 68, 111]);
var rawKey = JSON.parse("{\"alg\":\"A256GCM\",\"ext\":true,\"k\":\"gMjbMslfSKYPRDc-HJKqWrZ17tL5r97QUja62OG-944\",\"key_ops\":[\"encrypt\",\"decrypt\"],\"kty\":\"oct\"}");
window.crypto.subtle.importKey(
"jwk",
rawKey,
{ name: "AES-GCM", },

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@awwong1
awwong1 / rolldice.js
Created March 17, 2018 01:35
javascript roll dice
const rollDice = () => Math.floor(Math.random()*1414 % 6 + 1)
// > rollDice()
// 5
const rollNDice = (n) => Array(n).fill().map(rollDice)
// > rollNDice(6)
// [ 5, 3, 3, 5, 5, 2 ]
@awwong1
awwong1 / test.js
Last active February 20, 2018 20:03
ValidationError GraphQL
import { GraphQLError } from 'graphql';
class ValidationError extends GraphQLError {
constructor(errors) {
super('The request is invalid.');
this.state = errors.reduce((result, error) => {
if (Object.prototype.hasOwnProperty.call(result, error.key)) {
result[error.key].push(error.message);
} else {
result[error.key] = [error.message];