Skip to content

Instantly share code, notes, and snippets.

View tcr's full-sized avatar
🚮
bad command or file name

Tim Ryan tcr

🚮
bad command or file name
View GitHub Profile
@tcr
tcr / code.coffee
Created October 23, 2011 07:30
How to get started with OAuth and Github's API on node.js?
config =
key: "github_key"
secret: "github_secret"
clientID: "github_client_id"
# Network shim.
net =
post: (host, path, query, headers, data, fn) ->
headers ?= {}
@tcr
tcr / code.coffee
Created October 23, 2011 07:34
Using node.js and socket.io, when I broadcast to all other sockets with a callback, can I get a reference to each socket inside the callback?
# Iterate through all sockets excluding origin
broadcast = (origin, fn) ->
fn(socket) for socket in io.sockets.clients() when socket != origin
@tcr
tcr / summary.md
Created October 25, 2011 22:22
What's a mechanism for asynchronously loading 3rd party JavaScript?

LightningJS is a sandbox that integrates seamlessly with third party libraries by loading code into iframes and deferring execution so it doesn't slow down page load. It adds a level of indirection to third-party APIs, so code rewriting is required. Benchmarks are in its favor however.

@tcr
tcr / code.js
Created October 26, 2011 06:22
How can you use Mustache with Node.js?
var express = require('express');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.set('view engine', 'mustache');
app.set('views', __dirname + '/views');
app.register(".mustache", require('stache'));
@tcr
tcr / code.html
Created October 26, 2011 23:02
How do different browsers handle empty paragraphs/blocks using contentEditable?
<!-- most modern browsers -->
<p><br></p>
<!-- ie9 -->
<p></p>
<!-- ie7-8 -->
<script>
document.body.appendChild(document.createElement('p'))
</script>
@tcr
tcr / summary.md
Created October 26, 2011 23:21
How can you test IE versions on Mac OS X?

Follow this guide. It'll set up three VMs for you, one with each version respectively.

I then follow the additional steps, to save time:

  1. Load up each clean profile and pass through the boring Windows setup/driver finding.
  2. Open up Internet Explorer to a non-intensive page (Hacker News works)
  3. Create a snapshot "Running" and then close out of the window.

Then each time you want to run a version of IE, load "Running". When you're done, click "Power off the Machine" and click the checkbox to reload the snapshot "Running".

@tcr
tcr / code.sh
Created October 26, 2011 23:24
What's a simple way to serve a local directory through HTTP?
python -m SimpleHTTPServer
@tcr
tcr / summary.md
Created October 27, 2011 21:29
How can I learn Git from a low-level perspective?

Includes a description of Git including blobs, objects, trees, and explains everything through DAC graphs.

@tcr
tcr / code.js
Created October 28, 2011 02:18
How do you use Twilio with Node.js on Heroku?
var TwilioClient, Twiml, app, config, express, phone, port, twilio;
express = require('express');
TwilioClient = require('./twilio').Client;
Twiml = require('./twilio').Twiml;
app = express.createServer(express.logger());
app.use(express.bodyParser());
config = {};
@tcr
tcr / code.css
Created October 28, 2011 09:36
What's a way to support "white-space: pre-wrap" (significant whitespace, but lines still break) across all browsers?
element {
white-space: pre; word-wrap: break-word; /* Internet Explorer 5.5+ */
white-space: pre-wrap; /* CSS3*/
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
}