Skip to content

Instantly share code, notes, and snippets.

View zbjornson's full-sized avatar

Zach Bjornson zbjornson

View GitHub Profile
@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 / colorGradientCalculator.js
Last active August 11, 2016 19:25
First attempt at hand-writing an asm.js module.
// Interpolates through 10 RGB values, given a value and its domain
colorGradientCalculator = function (stdlib, foreign, heap) {
"use asm";
var rgb = new stdlib.Uint8Array(heap);
var imul = stdlib.Math.imul;
var floor = stdlib.Math.floor;
var lowIndex = 0;
var partial = 0.0;
@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 / 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 / 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 / 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 / make_specs.rb
Created December 17, 2013 05:28
Designed to rough-out the spec folder of your Ruby on Rails application. For example, you have a ton of models living in WEB-INF/app/models and want WEB-INF/spec/models to have corresponding model_xxx_spec.rb files, complete with the header (e.g. schema, copyright--anything in the top of the file that starts with a #) and "describe #{method}" st…
puts "in #{Dir.pwd}\n"
Dir.entries("app/helpers").each do |file_name|
file_path = "#{Dir.pwd}/app/helpers/#{file_name}"
puts "Processing #{file_name}\n"
unless File.directory?(file_path)
spec_file_name = file_name.sub(/\.rb/, "_spec.rb")
unless File.file?("spec/helpers/#{spec_file_name}")
class_name = nil
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}
@font-face {
font-family: "xkcd";
src: url('http://antiyawn.com/uploads/Humor-Sans.ttf');
}
@zbjornson
zbjornson / LICENSE
Last active December 20, 2015 08:39 — forked from dfm/LICENSE
Copyright (c) 2012–2013 Daniel Foreman-Mackey
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">