Skip to content

Instantly share code, notes, and snippets.

View zbjornson's full-sized avatar

Zach Bjornson zbjornson

View GitHub Profile
@zbjornson
zbjornson / pancakes.recipe
Created September 23, 2015 00:03
Protein pancakes
Version 1:
5 egg whites ┐
1 whole egg │
0.5 c flour │ combine all and cook
1 heaping scoop of vanilla Monster Milk ┘
http://www.bodybuilding.com/store/cs/monstermilk.html
Version 2:
1 c flour ┐
@zbjornson
zbjornson / demo.java
Created October 12, 2015 19:36
Running arbitrary jobs in parallel on Google Dataflow
package demo.pipeline;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;
@zbjornson
zbjornson / has_lib.js
Created April 24, 2016 19:05
has_lib.sh in javascript for node-canvas
var query = process.argv[2];
var fs = require('fs');
var path = require("path");
var childProcess = require("child_process");
var SYSTEM_PATHS = [
"/lib",
"/usr/lib",
"/usr/local/lib",
"/opt/local/lib",
@zbjornson
zbjornson / node_buffer.asm
Created June 20, 2016 17:51
swap32 without alignment check
void Swap32(const FunctionCallbackInfo<Value>& args) {
00007FF79E253100 push rbx
00007FF79E253102 push rdi
00007FF79E253103 sub rsp,28h
00007FF79E253107 mov rdi,rcx
Environment* env = Environment::GetCurrent(args);
00007FF79E25310A call node::Environment::GetCurrent (07FF79E22D240h)
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
00007FF79E25310F cmp dword ptr [rdi+10h],0
Environment* env = Environment::GetCurrent(args);
@zbjornson
zbjornson / Base.js
Created July 11, 2016 23:41
(SO question) JS for typescript, trying to create generic factory method on base class
"use strict";
var MyNS;
(function (MyNS) {
var Base = (function () {
function Base() {
}
Base.create = function (foo) {
return new MyNS[foo.type]();
};
return Base;
@zbjornson
zbjornson / cluster-events.js
Last active August 3, 2019 12:12
Showing off all cluster events
const cluster = require("cluster");
if (cluster.isMaster) {
function messageHandler(msg) {
console.log(msg);
}
cluster.on("message", function (worker, message) {
console.log(`master: (cluster.onMessage) '${message}'`);
@zbjornson
zbjornson / example.js
Last active August 10, 2016 16:16
SO 5263716
var http = require('http');
var server = http.createServer(function (req, res) {
req.connection.unref(); console.log("Got request. Connection unref'ed again");
res.writeHead(200, {"Content-Type": "text/plain"});
setTimeout(function () {
console.log("Handler timeout invoked");
res.end("Hello", function (err) {;
@zbjornson
zbjornson / EmbeddedTLB
Created August 14, 2016 20:35
SO 38945481
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: VWorksCPPATL.dll
[
uuid(83ED4BB2-4E00-4349-AD9E-493801A0FC62),
version(1.0),
custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134218331),
custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1471199125),
custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 8.00.0603 at Sun Aug 14 11:25:24 2016
@zbjornson
zbjornson / github-issues.wl
Last active December 14, 2016 03:20
GitHub Issue Charts in Mathematica
(* Common: *)
ToJSON[x_] := ImportString[FromCharacterCode[x, "Unicode"], "RawJSON"](*Ignore emoji*)
getIssues[repo_] := getIssues[repo, "*"]
getIssues[repo_, milestone_] :=
getIssues[repo, milestone] = Block[{url, head, pageCount, issues},
url = URLBuild[{"https://api.github.com/repos", repo, "issues"},
{"state" -> "all",
(*"access_token" -> "...",*) (* use for private repos, larger API quota*)
"sort" -> "created",
@zbjornson
zbjornson / styler.js
Created May 24, 2017 20:39
Styler utility
/**
* Tool to change styles with dynamic CSS. Use instead of setting style
* properties on individual elements.
*/
function Styler() {
this.styleEl = document.createElement("style");
document.head.appendChild(this.styleEl);
// Map for quickly looking up an existing rule by its selector.
this.ruleMap = new Map();
}