Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
}
function foo() {
alert('asdf');
}
//joel was here
@joelrbrandt
joelrbrandt / .gitignore
Created July 31, 2012 15:46
require-test
node_modules
@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 / 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 / get.js
Last active August 29, 2015 14:08
getting the contents of a url as a string using node
var getURL = function (url, cb) {
var http = require("http");
var result = "",
finished = false;
var finishedHandler = function (err, val) {
if (!finished) {
finished = true;
cb(err, val);
@joelrbrandt
joelrbrandt / drag.html
Created July 24, 2014 13:14
in-window drag test
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Draggable - Default functionality</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<style>
#draggable { width: 150px; height: 150px; padding: 0.5em; border: thin solid black; background-color: white;}
</style>

Keybase proof

I hereby claim:

  • I am joelrbrandt on github.
  • I am joelrbrandt (https://keybase.io/joelrbrandt) on keybase.
  • I have a public key whose fingerprint is 4180 C780 88D4 FA7E 2C7F A110 2A65 A817 C946 ACE5

To claim this, I am signing this object: