Skip to content

Instantly share code, notes, and snippets.

@bruslim
bruslim / Registry.js
Last active April 12, 2017 20:21
Stupid Jelly - a bean compatible event system that proxies everything to native dom events
class Registry {
static split(string) {
return string.split(' ');
}
constructor() {
Object.defineProperties(this, {
map: {value: new WeakMap()}
});
}
@bruslim
bruslim / index.html
Created March 6, 2017 03:12
High Low
<!DOCTYPE html>
<html>
<head>
<title>Number Guesser</title>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
</head>
<body>
<h1>Guess the number!</h1>
<p><input id="guess"/></p>
<p><button id="submit">Guess!</button></p>
@bruslim
bruslim / bfs.js
Last active August 29, 2015 14:07
BFS with closures
/*jshint node: true*/
// TreeNode Class
function TreeNode(value, children) {
var _children = children || [];
Object.defineProperties(this, {
value: {
value: value,
enumerable: true,
writable: true,
@bruslim
bruslim / repeat-shim.js
Last active August 29, 2015 14:04
String.prototype.repeat Shim
// Repeat Shim
String.prototype.repeat = String.prototype.repeat || function(count) {
// temporary return array
var ret = [];
// count to count
for(var i = 0; i < count; i++) {
// push this (the string we want to repeat)
// into the array
ret.push(this);
}
@bruslim
bruslim / etl.js
Last active December 17, 2015 03:39
quick and dirty nodejs powered tsql etl engine
// requires
var Mappr = require('./mappr.js');
var Tsql2008 = require('./tsql2008.js');
var config = Mappr.BuildConfig({
databases : {
// source db name
source: 'lidacdev',//'LiDACDev',
// desitnation db name
destination: 'lidac_data'
(function() {
var results = '',
log = '';
function countSheet(sheet) {
var count = 0;
if (!sheet || !sheet.cssRules) return;
for (var j = 0; j < sheet.cssRules.length; j++) {
if (!sheet.cssRules[j] || !sheet.cssRules[j].selectorText) continue;
count += sheet.cssRules[j].selectorText.split(',').length;
@bruslim
bruslim / latency.markdown
Created June 14, 2012 19:59 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs