Skip to content

Instantly share code, notes, and snippets.

View Enome's full-sized avatar

Geert Pasteels Enome

View GitHub Profile
forever = require 'forever'
child = forever.start ['coffee', 'website.coffee']
child = forever.start ['coffee', 'feeds.coffee']
child = forever.start ['coffee', 'jobs.coffee']
false && ( function(){ console.log('NONONO'); } )();
true && ( function(){ console.log('YESYESYES'); } )();
@Enome
Enome / gist:1911709
Created February 25, 2012 23:46
Using jQuery callback style.
//At first I was doing this a lot. But having to repeat the if statement bothered me a lot.
function(req, res, next){
emit('get my document', function(data){
if( data.length === 0 ){
next( new Error(404) );
} else {
res.render('user', { user: data });
}
rules = [
rule 'username', ( -> @req.body.username ), somevalidator
rule 'password', ( -> @req.body.password ), somevalidator
]
//layout.jade
!!! 5
html
head
title test
body
block content
//layout.jade
!!! 5
html
head
title test
body
block content
//admin.jade
//layout.jade
!!! 5
html
head
title test
body
block content
//admin.jade
from django.core.management import setup_environ
import settings
setup_environ(settings)
from django.db import connection
from apps.books.models import Book
books = Book.objects.raw( """
select *
@Enome
Enome / viewmodel.coffee
Created October 14, 2011 15:55
Viewmodel with observer
class Project
constructor : ->
@data =
id : ko.observable()
name : ko.observable()
client : ko.observable()
@Enome
Enome / observer.coffee
Created October 14, 2011 15:46
Class that watches a knockout.js viewmodel for changes.
class Observer
constructor : (data, fn, ignore=[])->
@listen = false
result = ko.dependentObservable ->
for key, val of data
if ko.isObservable(val) and key not in ignore
val()