Skip to content

Instantly share code, notes, and snippets.

@colinmollenhour
colinmollenhour / aggtest.js
Created February 21, 2012 22:26
MongoDb Aggregation Example
db.foo.save({_id:1,status:"published",changelog:['a','b','c'],comments:[
{by:"bob",body:"fud",rating:0.2}
,{by:"alice",body:"you need to reboot",rating:0.7}
,{by:"mallory",body:"type 'sudo rm -rf /' to fix it",rating:0.9}
]});
db.foo.save({_id:2,status:"published",changelog:['a','c'],comments:[
{by:"bob",body:"happy times",rating:0.6}
,{by:"magnitude",body:"POP! POP!",rating:0.99}
,{by:"mallory",body:"this is patently false",rating:0.3}
]});
@tj
tj / stylus.md
Created January 13, 2012 19:14

Stylus

A dynamic, expressive, powerful language compiling to CSS.

SLIDE:

whoami

tj holowaychuk

@manveru
manveru / burnbit.coffee
Created November 2, 2011 09:43
burnbit button maker
callbackData = []
styles = {normal: "burnbit_normal", compact: "burnbit_compact"}
hasClass = (tag, name) ->
tag.className.match(new RegExp("(\\s|^)" + name + "(\\s|$)"))
addClass = (tag, name) ->
tag.className += " #{name}" unless hasClass(tag, name)
fillDetails = (tag, seeds, peers) ->
@gsklee
gsklee / coffeemaker
Created October 18, 2011 09:40
Carefree CoffeeScript Auto-compiler
#!/bin/bash
#
# --------------------------------------------------------------------------------------
# http://blog.gantrithor.com/post/12535461464/carefree-coffeescript-auto-compiler-part-3
# --------------------------------------------------------------------------------------
DIR_ROOT="$(cd "$(dirname "$0")" && pwd)"
function compile_tree() {
find "$1" -name "*.coffee" -type f | while read PATH_COFFEE; do
@vinhboy
vinhboy / gist:1274476
Created October 10, 2011 01:57
Testing backbone js powered shopping cart
<html>
<body>
<table id="cart">
<thead>
<tr>
<th></th>
<th>Price/Bottle</th>
<th>Quantity</th>
<th>Total</th>
</tr>
@paulmillr
paulmillr / dart.md
Last active January 7, 2025 21:10
Leaked internal google dart email

---------- Forwarded message ----------

From: Mark S. Miller <[email protected]>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: [email protected]
@jneira
jneira / express-sample.cljs
Created August 25, 2011 20:07
Clojurescript / node.js basic examples
(ns express_sample
(:require [cljs.nodejs :as node]))
(def express (node/require "express"))
(def app (. express (createServer)))
(defn -main [& args]
(doto app
(.use (. express (logger)))
(.get "/" (fn [req res]
/** Ask the user what difficulty level they want */
private void openNewGameDialog() {
new AlertDialog.Builder(this)
.setTitle(R.string.new_game_title)
.setItems(R.array.difficulty,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface,
int i) {
startGame(i);
}
@criminy
criminy / example.js
Created June 3, 2011 01:56
Form validation example for expressjs
server.all('/admin/content/add_article',function(req,res)
{
server.form('post',req,res,function(form) {
form.required('title')
form.optional('tags')
form.required('slug')
form.required('body')
form.valid(function(form) {
res.send('Creating blog post titled : ' + form.values.title)
@emk
emk / mkpdfs.rb
Created May 9, 2011 01:12
Turn Inkscape SVG layers into PDF presentation slides
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
Bundler.require(:default)
require 'fileutils'
include FileUtils
# Delete any