Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
TooTallNate / anotherScript.js
Created June 10, 2010 19:15
"getScriptName" is a cross-browser function to retrieve the absolute URL of the currently executing JavaScript file.
// If no exception is passed into 'getScriptName', it will only
// retrieve the URL of the script where 'getScriptName' is defined.
// In order to get the URL of a different script file, you must
// pass an exception generated in this script file to 'getScriptName'.
try {
(0)();
} catch(ex) {
getScriptName(ex, onScriptNameKnown);
}
_XMLHttpRequest = XMLHttpRequest;
XMLHttpRequest = function () {
Object.defineProperty(this,
"__onreadystatechange",
{value: null,
writable: true,
enumerable: false});
Object.defineProperty(this,
"onreadystatechange",
// Injecting JavaScript
// Basic compact
document.body.appendChild(document.createElement("script")).src="foo.js"
// Function wrapped
(function(d){d.body.appendChild(d.createElement("script")).src="foo.js"})(document)
// With "with"
with(document){body.appendChild(createElement("script")).src="foo.js"}
// Injecting CSS
@teich
teich / gist:1000964
Created May 31, 2011 17:53
May 31st Heroku Updates
@tlrobinson
tlrobinson / storage-decorators.js
Created November 2, 2011 18:12
Example localStorage decorators
// Storage decorator base class
function StorageDecorator(storage) {
this._storage = storage;
}
StorageDecorator.prototype.getItem = function(key) {
return this._storage.getItem(key);
}
StorageDecorator.prototype.setItem = function(key, value) {
return this._storage.setItem(key, value);
@bhenerey
bhenerey / ideal ops.md
Created May 23, 2012 19:40
ideal ops checklist

In a perfect world, where things are done well, not just quickly, I would expect to find the following when joining the company:

Documentation

  • Accurate / up-to-date systems architecture diagram

  • Accurate / up-to-date network diagram

  • Out-of-hours support plan

  • Incident management plan

@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@tlrobinson
tlrobinson / example.txt
Created November 2, 2012 01:56
A REPL that waits for (Promises/A) promises to be resolved before printing.
tlrobinson ~/tmp $ node promise-repl.js
q> require("q-fs").read("promise-repl.js")
<Buffer 0a 76 61 72 20 56 4d 20 3d 20 72 65 71 75 69 72 65 28 22 76 6d 22 29 3b 0a 76 61 72 20 52 45 50 4c 20 3d 20 72 65 71 75 69 72 65 28 22 72 65 70 6c 22 29 ...>
q>
@gavinandresen
gavinandresen / btcpayments.rst
Last active March 28, 2021 06:40
Bitcoin Payment Messages

SEE BIP 70

See https://en.bitcoin.it/wiki/BIP_0070 for the latest version of this document; I'll keep this document so the process of discussion/revision isn't lost.

Bitcoin Payment Messages

This document proposes protocol buffer-based formats for a simple payment protocol between a customer's bitcoin client software and a merchant.

@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active April 17, 2024 10:51
Backend Architectures Keywords and References