Skip to content

Instantly share code, notes, and snippets.

@nfeldman
nfeldman / gist:1128011
Created August 5, 2011 17:16
datauri for a generic ajax spinner
/* there's nothing special or interesting about this, I just need a place to store it and a gist seemed as good as any */
.loading {
background: url(data:image/gif;base64,R0lGODlhHgAeAPf2AP7+/v39/fDw8O/v7/z8/PHx8e7u7vv7++Xl5fr6+vn5+ebm5gAAAPX19fT09Pb29vPz8/f39/j4+Ofn5/Ly8tTU1O3t7dXV1cnJyezs7Ojo6Orq6uTk5OPj476+vuvr69nZ2cjIyNbW1unp6crKytjY2MvLy9zc3LOzs7KyssfHx+Hh4b+/v9/f3+Li4tPT097e3sDAwNfX193d3dra2sHBwYmJidvb2+Dg4L29vby8vM/Pz7e3t9LS0sTExNDQ0LS0tIiIiLW1tcbGxszMzLi4uLq6uoyMjHBwcMPDw8XFxVhYWLGxsXFxccLCws7Ozra2trCwsG9vb42Njbm5uc3NzXNzc4qKilpaWtHR0bu7u3JycpKSkjs7O3Z2dq+vr66urj09PVlZWaioqKSkpISEhIKCgpqaml5eXnR0dJGRkSIiIltbW2lpaaWlpYaGhouLi1NTUz4+PqmpqXh4eI6OjpWVlZCQkJSUlJ6enpiYmJycnKqqqmpqakNDQ4eHh6Kiop+fn6ysrCUlJW5ubklJSa2trVRUVIODg4WFhUBAQCAgIKGhoV9fX0FBQYGBgaamppaWlmxsbFxcXGBgYFdXV5OTk5mZmTY2NiQkJB8fH21tbXl5eVBQUDw8PHt7ez8/P11dXX9/fzU1NSgoKJubm2dnZzQ0NDMzM52dnVFRUWtra5eXlyoqKk5OTiMjI1VVVQoKCmRkZE1NTaurq0ZGRjk5OTc3N35+fo+Pj0VFRX19fSEhISkpKURERBsbGywsLCcnJ6enpxgYGB4eHmJiYlJSUhoaGk9PT3V1dWFhYR0dHUdHRwUFBQcHBzg4

Keybase proof

I hereby claim: * I am nfeldman on github. * I am nfeldman (https://keybase.io/nfeldman) on keybase. * I have a public key ASCmL7tE2W7jN4gXhtoFUTduRozJbn3qI0_NcNZezyu43wo To claim this, I am signing this object:

{   "body": {     "key": {       "eldest_kid": "012017a0cec1358416502289e93d6554e27a1b0673393019fd87cc5823a264a2718d0a",       "host": "keybase.io",       "kid": "0120a62fbb44d96ee337881786da0551376e468cc96e7dea234fcd70d65ecf2bb8df0a",       "uid": "df44552e375176116764d9d3c2671e19",       "username": "nfeldman"     },     "merkle_root": {       "ctime": 1570906265,       "hash": "73506821e290f784ab76b707d4dc81cf57fdae13c32b6aab792dd98ac57a0459162527863950692ef8681b435eafbc0a1bdbef04208b0736ed50cae36cdf732a",       "hash_meta": "1c81bbdbbd54f3327f38fe38f6ac007e30989d7d088eb7d3ec54577e9486fb87",       "seqno": 8062689     },     "service": {       "entropy": "PQCRv9BmA+/WJqWU/d/h+ADZ",       "name": "github",       "username": "nfeldman"     },     "type": "web_servi
@nfeldman
nfeldman / gist:1432857
Created December 5, 2011 08:29
Using PHP Excel to perform a simple JSON to XSL transformation
<?php
error_reporting(E_ALL);
require realpath(dirname(__FILE__)) . '/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
// DEMO ONLY (potentially unsafe)
$data = json_decode($_POST['json']);
$key = $_POST['key'];
@nfeldman
nfeldman / firebug-xpath.js
Last active May 11, 2017 16:51
Standalone version of XPath Module from Firebug, assumes strings have a trim method
// AMD, Node flavored CommonJS, and old fashion global
(function (global, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
@nfeldman
nfeldman / custom-elements.md
Last active April 27, 2016 04:58
notes on custom elements

There are two types of custom elements.

  1. custom tag
  2. type extension

Tag names must have a hyphen and must start with [a-z]. Plus some other rules.

Tag names must not be any one of:

  • annotation-xml
@nfeldman
nfeldman / dictionary.js
Created July 7, 2012 23:27
one way to do a dictionary in ES5
// as a nodejs module
module.exports = makeDictionary();
function makeDictionary (dict) {
return function Dictionary () {
!dict && (dict = Object.create(null));
var Dictionary = {
__proto__: null,
get: function (name) {
@nfeldman
nfeldman / gist:2949291
Created June 18, 2012 16:35
constructor for building xml like strings
// extracted from an earlier gist that had a more comprehensive DOM-like implementation
// in this case, I didn't care about namespaces and I didn't require any operation but
// append. This is too basic to be useful for most things, but good enough for what I've
// used it for. Note that the use of ES5 accessors makes this incompatible with IE < 9.
function Tag (name) {
this.name = name;
this.attrs = Object.create(null);
this.children = [];
return this;
@nfeldman
nfeldman / gist:2934140
Created June 15, 2012 01:39
recursive readdir for node (via stackoverflow)
// http://stackoverflow.com/q/5827612/
function walk(dir, done) {
var results = [];
fs.readdir(dir, function (err, list) {
if (err) {
return done(err);
}
var i = 0;
(function next() {
var file = list[i++];
@nfeldman
nfeldman / gist:2904580
Created June 10, 2012 08:59
break text into lines of length n
// a bit messy and not optimized, but handy for basic formatting of short blocks of text
function splitToLines (string, leftMarginWidth, maxLineWidth) {
var lines = [],
line = [],
padding = Array(leftMarginWidth).join(' '),
i = 0, // cursor
p = 0, // left anchor
m = 0, // counter for searching 5 char wrap zone
s, // tmpvar
@nfeldman
nfeldman / gist:1868037
Created February 20, 2012 05:53
mimetypes list
// from node-paperboy
{
"aiff": "audio/x-aiff",
"arj": "application/x-arj-compressed",
"asf": "video/x-ms-asf",
"asx": "video/x-ms-asx",
"au": "audio/ulaw",
"avi": "video/x-msvideo",
"bcpio": "application/x-bcpio",
"ccad": "application/clariscad",