Skip to content

Instantly share code, notes, and snippets.

View awwong1's full-sized avatar
🕳️
some

Alexander Wong awwong1

🕳️
some
View GitHub Profile
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', '/static/common/js/testing.js', true);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === XMLHttpRequest.DONE) {
eval(xmlhttp.responseText);
update_match_details = function (data) {
console.log('match_token: ' + data.match_token);
console.log('internal_ip: ' + data.internal_ip);
var bridge_info = data.bridge_info;
console.log('watchLink: ' + get_match_link(data.server_ip, bridge_info.bridge_host, bridge_info.bridge_port, data.match_token));
{
uid: (node_uid)
submitter_uid: (user_uid)
text: blah
markdown: blah
image: blah
video: blah
...
required_uids: (set of node_uids)
# excluded_uids: (set of node_uids) (maybe this is impossible to do 'well')
@awwong1
awwong1 / beeMovieScriptNotica.sh
Created December 27, 2016 21:38
Bee Movie Script, Notica
#!/usr/bin/env bash
# Playing around with Tanner Collin's Notica service.
# Script from http://www.script-o-rama.com/movie_scripts/a1/bee-movie-script-transcript-seinfeld.html
# Notica from https://notica.us/
# Will send a single line of the bee movie script to Notica every 5 seconds.
# https://notica.us/BeeMovie
beemovieScript="
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
-----> Elixir app detected
-----> Checking Erlang and Elixir versions
Will use the following versions:
* Stack cedar-14
* Erlang 18.3
* Elixir 1.4.1
-----> Will export the following config vars:
DATABASE_URL
DOMAIN_NAME
LETS_ENCRYPT_CHALLENGE
@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];
@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 ]

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@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", },
@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