Skip to content

Instantly share code, notes, and snippets.

var Laws = {
drinking_age : function (fn) {
fn(this.age > 21);
}
}
/* snip */
Laws.drinking_age.call(this, function (able_to_drink) {
<div id="profile">
<div class="notice-box">
<img id="picture" class="small box" src="/nopicture.jpg" />
<span id="name" class="push-2">Username</span>
<ul id="notifications">
<li class="notification">No notifications</li>
</ul>
</div>
<div id="settings box">
var me = {
name : 'Joshua Kehn',
picture : '/josh.jpg',
age : 24,
email : "[email protected]",
notification : [
'Someone commented',
'A server went down',
'The grilled cheese is ready',
'Downtime scheduled'
map : function (parent, element, key, value) {
if (key === 'sources') {
element.setAttribute('data-original', value);
element.setAttribute('href', '/source/link/' + value);
element.innerHTML = value;
}
}
<div class="notice-box">
<img id="picture" class="small box" src="/josh.jpg">
<span id="name" class="push-2">Joshua Kehn</span>
<ul id="notifications">
<li class="notification">Someone commented</li><li class="notification">A server went down</li><li class="notification">The grilled cheese is ready</li><li class="notification">Downtime scheduled</li></ul>
</div>
<div id="settings box">
<li><input class="input-email" id="email" value="[email protected]"></li>
<li><input class="input-number" id="age" value="24"></li>
#!/bin/sh
# Figure out what we are comparing to.
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=2ca2a592640b979a4092c19daa1938f9dd1baa46
fi
var http = require('http');
function catch_sigint (server) {
process.on('SIGINT', function () {
process.stdout.write('\r');
console.log('Interrupt');
try {
server.close();
} catch (e) {
// This is a JavaScript comment
console.log('This is some output.')
// Another comment
console.log('More output.');
// Last comment
// but no output!
<!DOCTYPE html> <html> <head> <title>file.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> file.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>This is a JavaScript comment</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap">
@joshkehn
joshkehn / eventemitter.js
Created November 21, 2011 20:34 — forked from joshsmith/eventemitter.js
Hands-On Node Event Emitter Exercise 1
var EventEmitter = require('events').EventEmitter;
var util = require('util');
// Here is the Ticker constructor
var Ticker = function() { // This is a pseudo-class
}
util.inherits(Ticker, EventEmitter);
// Emit tick on the tick event