Skip to content

Instantly share code, notes, and snippets.

@danshearmur
danshearmur / document_write.js
Created March 7, 2012 15:11
Replace document.write so that embedding gist script tags doesn't block the page
document._write = document.write;
document.write = function(str){
if (str.indexOf('<div id=\"gist-') != 0) {
if(str.indexOf('https://gist.github.com/stylesheets/gist/embed.css') == -1) {
// if you got this far it's not a github document.write call
document._write(str);
}
return;
}
@danshearmur
danshearmur / colorbox.less
Created September 12, 2011 15:31
Using colorbox with bootstrap
#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:10001; overflow:hidden;}
#cboxOverlay{position:fixed; width:100%; height:100%;}
#cboxMiddleLeft, #cboxBottomLeft{clear:left;}
#cboxContent{position:relative;}
#cboxLoadedContent{overflow:auto;}
#cboxTitle{margin:0;}
#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%;}
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
.cboxPhoto{float:left; margin:auto; border:0; display:block;}
.cboxIframe{width:100%; height:100%; display:block; border:0;}
(function () {
if (window.navigator.sendBeacon || !window.localStorage) return;
var TO_S = Object.prototype.toString;
var TYPE_RE = /\[object ([a-zA-Z0-9]*)\]/;
var LS_PFX = 'beaconfill-';
var LIMIT = 64 * 1024;
var WAIT = 1500;
var MAX_RETRIES = 3;
@danshearmur
danshearmur / README.md
Last active April 25, 2016 07:08
Hack Assembler

Hack Assembler

To run:

npm install
node index.js ./path/to/File.asm ./path/to/Output.hack
@danshearmur
danshearmur / dependency-injection.js
Last active December 30, 2015 03:29
Simple dependency injection (requires ES5 support)
'use strict';
var inject;
var specify;
(function (root) {
var depList = {};
var things = {};
@danshearmur
danshearmur / .gitignore
Last active December 30, 2015 03:19
Test domain length with gzip
*html*
(defn get-chars-at [seq count]
(reduce (fn [accum next]
(let [next-char (get next count)
char (if-not (nil? next-char) next-char " ")]
(str accum char)))
"" seq))
(defn max-count [seq]
(reduce (fn max-count [last line]
(let [c (count line)]
<!doctype html>
<html>
<head>
<link href="bootstrap.css" rel="stylesheet"/>
<style>
#expanded:target .nav-collapse {
height: auto;
}
.navbar .btn-contract {
display: none;
<!doctype html>
<html>
<head>
<link href="bootstrap.css" rel="stylesheet"/>
<style>
#expanded:target .nav-collapse {
height: auto;
}
</style>
</head>
<body id="expanded">
<div class="navbar">
<div class="navbar-inner">
<a class="btn btn-navbar btn-expand" href="#expand">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>