Skip to content

Instantly share code, notes, and snippets.

View robert-nix's full-sized avatar

Robert Nix robert-nix

View GitHub Profile
@robert-nix
robert-nix / index.js
Last active July 23, 2016 07:24
requirebin sketch
document.write(require('wow-legion-wdb5-build-ids-that-are-actually-build-ids').buildIDs.join(', '));
@robert-nix
robert-nix / _readme.md
Last active September 8, 2016 07:08
Terra and IACA

This is a quick example of using Terra and IACA to do micro-optimization.

  • llc on the path should be the same version as Terra's builtin llvm (3.5.0 in my case)
  • iaca should also be on the path
  • run terra test.t to compile the function and invoke iaca on the output

The math for the test function is derived from http://fabiensanglard.net/doom3_documentation/37726-293748.pdf, and also incorporates the scale, translation, and transform origin vectors typical of traditional animation. Disclaimer: the code was translated from C++ and may be completely wrong due to translation errors.

Interacting with an emscripten-compiled module from javascript usually takes the form of writing a simple wrapper in C to return a string-serialized version of the data you need that is then parsed in javascript. This function is called using Module.ccall, and its result is converted out of the heap using Module.*ToString(result) and then (hopefully) freed.

However, this is annoying, because you have to recompile the module any time you want to use the library in a different way. Here is an example of interacting with the emscripten heap directly, using the typed ArrayViews provided and my library for defining C structs over ArrayBuffers.

@robert-nix
robert-nix / AutoDictKr.user.coffee
Last active August 29, 2015 14:22
Korean autodictionary
###
// ==UserScript==
// @id AutoDictKr
// @name Korean Autodictionary
// @namespace https://gist.github.com/Mischanix/dd5d9b0303c59e4feb7a
// @version 3
// @author Mischanix
// @description Provides inline definitions for selected Korean text
// @include *
// @license Creative Commons CC0 (public domain)
@robert-nix
robert-nix / index.js
Created May 11, 2015 17:56
requirebin sketch
var varint = require("varint");
var num = varint.decode([0xAF, 0x95, 0x8B, 0xF5, 0x0C]);
document.write(num);
// includes:
#include <tmmintrin.h>
#include <stdint.h>
// remember to enable AVX instructions for the 3-op VEX mode if you want it
#define USE_SSSE3_MASK_GEN 1
// initializations:
@robert-nix
robert-nix / lzo_d.h
Created March 2, 2015 15:56
lzo decompressor (lzo1x) with the crap stripped out ("crap" includes sanity checks, so this will crash on invalid bitstream)
#ifndef assert
#define assert(x) ((void)0);
#endif
#define LZO_E_OK 0
#define LZO_E_ERROR (-1)
#define LZO_E_INPUT_OVERRUN (-4)
#define LZO_E_OUTPUT_OVERRUN (-5)
#define LZO_E_LOOKBEHIND_OVERRUN (-6)
#define LZO_E_EOF_NOT_FOUND (-7)
; Listing generated by Microsoft (R) Optimizing Compiler Version 18.00.30501.0
TITLE D:\dev\PdbStaticTest\PdbStaticTest\unit1.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES
unit0.OneName = 94b000
unit0.X::OneName = 94b004
test = 7cfaf8
unit1.OneName = 94b00c
extern unit0.OneName = 94b000

Subject: Apologies for the downtime, but we're coming back stronger.

Dear Simon,

As you may already know, BrowserStack experienced an attack on 9th November, 2014 at 23:30 GMT during which an individual was able to gain unauthorized access to some of our users’ registered email addresses. He then tried to send an email to all our registered users, but he was only able to reach less than 1% (our estimate is 5,000 users). The email contained inaccurate information, even claiming that BrowserStack would be