Skip to content

Instantly share code, notes, and snippets.

View sym3tri's full-sized avatar
🌴
On vacation

Ed Rooth sym3tri

🌴
On vacation
View GitHub Profile
@jed
jed / rendering_templates_obsolete.md
Created October 19, 2012 05:07
Rendering templates obsolete

(tl;dr DOM builders like [domo][domo] trump HTML templates on the client.)

Like all web developers, I've used a lot of template engines. Like most, I've also written a few of them, some of which even [fit in a tweet][140].

The first open-source code I ever wrote was also one of the the first template engines for node.js, [a port][node-tmpl] of the mother of all JavaScript template engines, [John Resig][jresig]'s [micro-templates][tmpl]. Of course, these days you can't swing a dead cat without hitting a template engine; one in eight packages on npm ([2,220][npm templates] of 16,226 as of 10/19) involve templates.

John's implementation has since evolved and [lives on in Underscore.js][underscore], which means it's the default choice for templating in Backbone.js. And for a while, it's all I would ever use when building a client-side app.

But I can't really see the value in client-side HTML templates anymore.

@wilmoore
wilmoore / console.js
Created October 3, 2012 20:11
PhantomJS Mocha Console Runner (spike)
/*!
* phantomjs console.js test/index.html
*/
(function () {
'use strict';
if (phantom.args.length < 1) {
console.log("Usage: phantomjs console.js <pageUrl>");
phantom.exit();
@mikefowler
mikefowler / _base.scss
Created August 15, 2012 15:24
Sass Theming Structure
/**
* The result of this file structure is ONE *.css file per theme. Making a global change
* to _base or _config partial will update all themes that inherit from them. #win
*/
@import 'config';
/**
* Global
*/
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jboner
jboner / latency.txt
Last active May 7, 2024 19:39
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jarek-foksa
jarek-foksa / gist:2648095
Last active April 26, 2020 09:59
SVGElement.prototype.innerHTML shim
// Important: You must serve your pages as XHTML for this shim to work,
// otherwise namespaced attributes and elements will get messed up.
Object.defineProperty(SVGElement.prototype, 'innerHTML', {
get: function() {
var $child, $node, $temp, _i, _len, _ref;
$temp = document.createElement('div');
$node = this.cloneNode(true);
_ref = $node.children;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
$child = _ref[_i];
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@joeytrapp
joeytrapp / run-mocha.js
Created April 6, 2012 02:09
JavaScript: PhantomJS Mocha Scrapper
/*global phantom:true, console:true, WebPage:true, Date:true*/
(function () {
var url, timeout, page, defer;
if (phantom.args.length < 1) {
console.log("Usage: phantomjs run-mocha.coffee URL [timeout]");
phantom.exit();
}
url = phantom.args[0];
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@JeNeSuisPasDave
JeNeSuisPasDave / README.markdown
Created March 17, 2012 20:29 — forked from erikfried/README.markdown
shell script to invoke jslint via jsc on Mac OS X

Forked from ericfried's original gist; cleaned up some broken links, fixed a shell script bug, and added some optional setup.

I just realized that there is a rather well hidden javascript interpreter in the mac os x terminal out of the box. /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc See http://www.phpied.com/javascript-shell-scripting/

Then i figured it coud be quite easy to set up a command line util to run jslint from anywhere. Thought i´d share how.

Setup