Skip to content

Instantly share code, notes, and snippets.

View mwdchang's full-sized avatar

Daniel Chang mwdchang

View GitHub Profile
@mwdchang
mwdchang / gh-pages.sh
Created April 9, 2021 22:56
gh-pages branch manipulation
#!/usr/bin/env bash
DIR=dist
git checkout --orphan gh-pages
npm run build
git --work-tree $DIR add --all
git --work-tree $DIR commit -m "gh-pages"
git push origin HEAD:gh-pages --force
rm -rf $DIR
git checkout -f master
@mwdchang
mwdchang / heap.js
Created March 4, 2021 04:42
Simple quickie binary heap
class Heap {
constructor(maxsize) {
this.size = 0;
this.maxsize = maxsize;
this.data = [this.maxsize + 1];
}
getParent(index) { return Math.round( index / 2); }
getLeftChild(index) { return 2 * index; }
getRightChild(index) { return 2 * index + 1; }
@mwdchang
mwdchang / package.json
Created November 15, 2020 19:13
Basic JS lib setup
{
"name": "jslib-test",
"version": "1.0.0",
"description": "Testing library packaging",
"main": "dist/cjs/main.js",
"module": "dist/esm/index.js",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w"
},
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import random
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("./MNIST/", one_hot=True)
tf.reset_default_graph()
@mwdchang
mwdchang / index.html
Created June 4, 2018 02:49
Tensorflow JS core test
<!DOCTYPE html>
<html lang="en">
<head>
<script src="tf.min.js"></script>
</head>
<body>
</body>
<script>
const LEARNING_RATE = 0.07;
const UNDEF = 'undefined';
const alpha = 2;
const beta = .5;
/* Utility */
const createArray = (x, y) => {
let r = [];
if (typeof x !== UNDEF && typeof y !== UNDEF) {
for (let i=0; i < x; i++) {
r.push(createArray(y));
@mwdchang
mwdchang / scraper.sh
Created March 16, 2018 11:27
Scrapes baseball reference player mug shots
#!/usr/bin/env bash
PLAYER_ID=$1
IDX=${PLAYER_ID:0:1}
URL="https://www.baseball-reference.com/players/${IDX}/${PLAYER_ID}.shtml"
echo "$URL"
curl ${URL} | grep "og:image" | egrep -o "http.*((jpg)|(png))" | xargs curl -o ${PLAYER_ID}
sips -s format jpeg ${PLAYER_ID} --out ${PLAYER_ID}.jpg
@mwdchang
mwdchang / dnn.py
Created February 9, 2018 04:47
Tensorflow DNN scratch pad
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]="2"
import tensorflow as tf
import numpy as np
## TODO
## - Move learning rate
## - Save model, restore model
class NNModel():
@mwdchang
mwdchang / server.js
Created October 17, 2017 15:37
Simple node proxy server
const express = require('express')
const app = express()
const proxy = require('express-http-proxy')
app.use('/', proxy('proxy-destination.com'))
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
@mwdchang
mwdchang / config.json
Created February 19, 2017 04:34
OICR proxy dashboard
[
{
"cmd": "ssh -D9002 proxy-something.lalala.com",
"des": "SOCK5 Proxy to proxy-something"
},
{
"cmd": "ssh -D9003 proxy-something-else.lalala.com",
"des": "SOCK5 Proxy to hproxy-dev"
},
{