Skip to content

Instantly share code, notes, and snippets.

View evanp's full-sized avatar

Evan Prodromou evanp

View GitHub Profile
@evanp
evanp / gist:1566736
Created January 5, 2012 19:16
Backbone router with fragments
<html>
<head>
<title>test router</title>
<style>
#content { color: red; font-size: 32px }
</style>
</head>
<body>
<ul>
<li><a href="#">root</a></li>
@evanp
evanp / gist:1566760
Created January 5, 2012 19:21
Backbone router with pushState
<html>
<head>
<title>test router</title>
<style>
#content { color: red; font-size: 32px }
</style>
</head>
<body>
<ul>
<li><a href="/">root</a></li>
@evanp
evanp / gist:3029348
Created July 1, 2012 19:41
Request with hook
{
"hook": "http://example.com/search-results/30112A337",
"ids": [
"@t",
"evan@status.net",
"http://facebook.com/faddah",
"https://plus.google.com/113651174506128852447/posts",
"Jan-Christoph Borchardt"
]
}
Person.fromIdentifier(id, function(err, person) {
if (err) {
throw err;
} else {
res.json(person);
}
});
@evanp
evanp / gist:3048138
Created July 4, 2012 16:23
Subscribable multi-author feed for StatusNet
<feed>
<!-- ... -->
<author>
<activity:object-type>http://activitystrea.ms/schema/1.0/group</activity:object-type>
<uri>http://evan.status.net/group/3/id</uri>
<name>friends</name>
<link rel="alternate" type="text/html" href="http://evan.status.net/group/3/id"/>
<link rel="avatar" type="image/jpg" media:width="96" media:height="96" href="https://c778552.ssl.cf2.rackcdn.com/evan/3-96-20120419022937.jpeg"/>
<link rel="avatar" type="image/jpg" media:width="48" media:height="48" href="https://c778552.ssl.cf2.rackcdn.com/evan/3-48-20120419022938.jpeg"/>
<link rel="avatar" type="image/jpg" media:width="24" media:height="24" href="https://c778552.ssl.cf2.rackcdn.com/evan/3-24-20120419022938.jpeg"/>
@evanp
evanp / gist:3188646
Created July 27, 2012 15:24
Example of using nested teardowns
var vows = require('vows'),
assert = require('assert');
var suite = vows.describe('test teardown callback');
suite.addBatch({
'when we do an async operation': {
topic: function() {
var cb = this.callback;
process.nextTick(function() {
@evanp
evanp / gist:4359948
Created December 22, 2012 17:02
Adding a dropdown button with JQuery produces a usable dropdown
<!DOCTYPE html>
<html>
<head>
<title>Test data-* attributes</title>
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="foo">
<a href="#" class="btn" id="showdropdown">Show dropdown</a>
</div>
{
"actor": {
"url": "http://twitterbridge.example",
"objectType": "service"
},
"verb": "share",
"object": {
"url": "https://twitter.com/justinbieber/status/289601931230453760",
"objectType": "note",
"content": "another great show tonight..and the #countdown continues to #BELIEVEacoustic",
language: node_js
node_js:
- 0.8
script: "vows test/*-test.js && sudo vows test/*-test-as-root.js"
@evanp
evanp / assertequal
Created March 8, 2013 14:54
actual, expected output
// Test actual, expected
var vows = require("vows"),
assert = require("assert");
var suite = vows.describe("are actual and expected reversed?");
suite.addBatch({
"when we assert equality": {
topic: "actual",