Skip to content

Instantly share code, notes, and snippets.

Adrien Friggeri friggeri

View GitHub Profile
@friggeri
friggeri / gist:1570840
Created Jan 6, 2012
More CoffeeScriptish
View gist:1570840
do ($ = jQuery) ->
$.fn.zebraTable = (options) ->
defaults =
evenColor: '#ccc'
oddColor : '#eee'
options = $.extend(defaults, options)
@each ->
$("tr:even", @).css('background-color', options.evenColor)
$("tr:odd", @).css('background-color', options.oddColor)
@friggeri
friggeri / clark.coffee
Created Nov 25, 2011
Sparklines in CoffeeScript
View clark.coffee
#!/usr/bin/env coffee
ticks = ['','','','','','','','']
exports.clark = (data) ->
m = Math.min data...
n = (Math.max(data...)-m)/(ticks.length - 1)
(ticks[(t-m)/n >> 0] for t in data).join('')
if require.main == module
data = process.argv
@friggeri
friggeri / haiku
Created Oct 6, 2011
random heroku-like name generator
View haiku
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
View gist:808454
var fs = require('fs'),
http = require('http');
var out = fs.createWriteStream('some-file', {flags:'w',encoding:'utf8'});
http.createServer(function(req, res){
var buffer = [];
req.on('data', [].push.bind(buffer)).on('end', function(){
out.write(data);
});
View fancy git prompt
function git_prompt {
branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"`
if [ -n "$branch" ]; then
case `git status 2> /dev/null | tail -n1` in
"nothing to commit (working directory clean)")
color="01;33m";;
"nothing added to commit but untracked files present (use \"git add\" to track)")
color="01;35m";;
*)
color="01;31m";;
View gist:504889
var swift = require('./lib/swift');
swift.compile('{#users}{name} | {lowercase}\n{/users}', {
users:[
{name:'John'},
{name:'Jack'}
],
lowercase:function(){
return this.name.toLowerCase()
}
You can’t perform that action at this time.