Skip to content

Instantly share code, notes, and snippets.

@joelrbrandt
joelrbrandt / jshint_runner.js
Created June 22, 2012 21:22
print out jshint parse data
// Requirements:
// * jshint.js in the same dir as this file
// * file you want to parse is called 'testfile.js'
var j = require('./jshint').JSHINT,
u = require('util'),
f = require('fs');
var s = f.readFileSync('testfile.js', 'utf-8');
@joelrbrandt
joelrbrandt / bench.js
Created June 23, 2012 17:09
parse list of files with jshint,
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global require */
// Requirements:
// * 'jshint.js' file in the same dir as this file
// * 'files' file in the same dir as this file. Should contain a list of files to parse
// with either absolute paths or paths that are relative to this dir
var j = require('./jshint').JSHINT,
u = require('util'),
@joelrbrandt
joelrbrandt / .gitignore
Created July 31, 2012 15:46
require-test
node_modules
function foo() {
alert('asdf');
}
//joel was here
@joelrbrandt
joelrbrandt / grey_checkerboard.css
Created August 24, 2012 17:13
grey checkerboard
body {
background-color: #999;
background-image: linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%, #ccc),
linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%, #ccc);
background-size:60px 60px;
background-position:0 0, 30px 30px
}
@joelrbrandt
joelrbrandt / node-ec2-notes.md
Last active December 14, 2015 13:19
Notes on setting up a node server on ec2

Setting up a Node server on EC2

Basic EC2 setup

  1. Select your region in the upper right corner of the management console. I always use N. California, since that's where I live, but Oregon is a little cheaper.
  2. Launch a Ubuntu instance. I chose a "Ubuntu Server 12.04.1 LTS 64-bit" server using the Quick Launch wizard. If you don't already have a keypair, you'll have to create one.
  3. Optional: Immediately shut down the instance and change the instance type to "m1.medium" (or larger). This will make the setup steps much faster. You can always scale it back later. Note: When you change instance sizes, elastic IP mappings can get hosed. You may need to unassociate and reassociate them.
  4. Add an elastic IP that is mapped to the new instance.
  5. Log in to your new instance with something like: ssh -i yourkey.private ubuntu@your.elastic.ip
@joelrbrandt
joelrbrandt / capitalize.js
Created March 26, 2013 12:32
Simple connect middleware that capitalizes every character in utf8 HTML files
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, node: true */
/*global $, define */
(function () {
"use strict";
var connect = require("connect");
function capitalize(req, res, next) {
var oldWrite = res.write,
@joelrbrandt
joelrbrandt / .gitignore
Last active December 15, 2015 12:49
example server that wraps html content in an iframe
node_modules
@joelrbrandt
joelrbrandt / simple_jquery_event.html
Created March 30, 2013 15:16
Simple jquery event, for testing debugger events
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function sayHi() {
console.log("hi");
}
$(function () {
$("h1").on("mousedown", sayHi);
@joelrbrandt
joelrbrandt / stream-perf-test.js
Created July 9, 2013 16:13
Test performance of various ways of reading from node v0.10 streams
(function () {
"use strict";
var stream = require("stream");
var b, i, j, t, count;
var OUTER_LOOP_ITERATIONS = 1000,
INNER_LOOP_ITERATIONS = 100,
BLOCK_SIZE = 10000;