Skip to content

Instantly share code, notes, and snippets.

View marcuswestin's full-sized avatar

Marcus Westin marcuswestin

  • New York
View GitHub Profile
@marcuswestin
marcuswestin / javascript templating
Created December 2, 2011 22:28
Who needs fancy javascript templating languages when a good old 10-liner does the job.
<div id="output"></div>
<script type="text/html" id="greeting-template">
<div class="greeting">
Hello, {{ name }}!
</div>
</script>
<script>
function template(id, params) {
var html = document.getElementById(id).innerHTML
@marcuswestin
marcuswestin / gist:1979651
Created March 5, 2012 17:36
Custom font loading
module.exports = {
load:load
}
function load(callback) {
var testEl = document.createElement('span')
testEl.style.fontFamily = 'sans-serif';
testEl.innerHTML = 'TEST_STRING'
testEl.style.visibility = 'hidden'
testEl.style.position = 'absolute'
import localstorage
import filter
var tasks = []
localstorage.persist(tasks, 'todo-fun')
<link rel="stylesheet" type="text/css" href="http://addyosmani.github.com/todomvc/reference-examples/vanillajs/css/todos.css" />
<div id="todoapp">
@marcuswestin
marcuswestin / gist:2219899
Created March 27, 2012 20:13
Get started with fun and todo-mvc
sudo npm install -g fun
curl https://raw.github.com/marcuswestin/fun/master/apps/todo-mvc/todo-mvc.fun > todo-mvc.fun
curl https://raw.github.com/marcuswestin/fun/master/apps/todo-mvc/todo-mvc.css > todo-mvc.css
fun todo-mvc.fun
# Go to localhost:8080 in your browser
@marcuswestin
marcuswestin / npm-install-all
Created May 2, 2012 18:43
npm install all node_modules
setup:
for file in ./node_modules/*; do cd $$file && npm install --production . && cd ../..; done
.PHONY: setup
@marcuswestin
marcuswestin / run-dev-server.js
Created May 2, 2012 20:00
Dev server springboard
#!/usr/local/bin/node
require('color')
var jsCompiler = require('require/server'),
express = require('express'),
fs = require('fs'),
stylus = require('stylus'),
curry = require('std/curry'),
nib = require('nib')
@marcuswestin
marcuswestin / tags.js
Created May 2, 2012 21:42
tiny, standalone dom generator
;(function() {
var global = this
var tags = {
create: function(tagName, overrideRender) {
var F = function(args) {
this._args = slice(args)
this._tag = tagName
@marcuswestin
marcuswestin / gist:2648460
Created May 9, 2012 20:09
Get most recent git commit
git rev-parse --verify HEAD
@marcuswestin
marcuswestin / gitup.md
Created May 9, 2012 20:26
Update current git repo
@marcuswestin
marcuswestin / node-twilio-example.js
Created May 17, 2012 23:04
Useful node snippet I had lying around from when evaluating twilio
var request = require('request')
var accountSid = 'ABC'
var authToken = 'XYZ'
var twilioSandbox = 'QWE'
var yourPhone = 'ASD'
var text = 'Test'
var url = 'https://'+accountSid+':'+authToken+'@api.twilio.com/2010-04-01/Accounts/'+accountSid+'/SMS/Messages.json'
var params = { From: twilioSandbox, To: yourPhone, Body: text }