Skip to content

Instantly share code, notes, and snippets.

View erjjones's full-sized avatar

Eric Jones erjjones

  • Indianapolis, Indiana
View GitHub Profile
@BoyCook
BoyCook / ServerITSpec.js
Last active May 14, 2019 18:28
Integration testing a node.js web app with Mocha
var should = require('should');
var request = require('request');
var url = 'http://localhost:8080';
var HttpServer = require('./server').HttpServer;
var server;
describe('HttpServer', function () {
before(function (done) {
server = new HttpServer({port: 8080}).start(done);
@thecodejunkie
thecodejunkie / gist:3937110
Created October 23, 2012 06:09
Using the Browser for intra application communication
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Testing;
public class Home : NancyModule
{
public Home()
{
Get["/"] = _ =>
{
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Backbone.js • TodoMVC</title>
<link rel="stylesheet" href="../../assets/base.css">
<!--[if IE]>
<script src="../../assets/ie.js"></script>
<![endif]-->
@addyosmani
addyosmani / index.html
Created August 16, 2012 12:44
This was inspired by the Dribbble shot to the left of the canvas by Ramiro Galan, which can be found here: http://dribbble.com/shots/674715-Sparkle-Light-Trail. Some browsers still won't fully clear a canvas all the way with the destination-out globalCom
<!-- source image and inspiration from Ramiro Galan on Dribbble: http://dribbble.com/shots/674715-Sparkle-Light-Trail -->
<img src="http://dribbble.s3.amazonaws.com/users/36991/screenshots/674715/game.png" />
@jboner
jboner / latency.txt
Last active November 15, 2024 14:00
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@erjjones
erjjones / jsonp-usage.js
Created March 7, 2012 21:13 — forked from sindresorhus/jsonp-usage.js
JSONP function - Easily fetch remote JSONP files
// Example usage: Fetch it's own code from GitHub
JSONP( 'https://api.github.com/users/erjjones?callback=?', function( response ) {
var data = response.data;
console.log(data.followers);
});
@sindresorhus
sindresorhus / jsonp-usage.js
Created February 24, 2012 12:38
JSONP function - Easily fetch remote JSONP files
// Example usage: Fetch it's own code from GitHub
JSONP( 'https://api.github.com/gists/1900694?callback=?', function( response ) {
console.log( 'JSONP function:', response.data.files['jsonp.js'].content );
});
@erjjones
erjjones / NodeJsProxy
Created January 25, 2012 21:58
Node.js Proxy
var http = require('http');
http.createServer(function(request, response) {
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.addListener('end', function() {
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
desc 'Generate tags page'
task :tags do
puts "Generating tags..."
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')