Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
@rwaldron
rwaldron / branch-count.sh
Created June 15, 2011 16:08
Count number of branches in a repo
git branch | wc -l
@rwaldron
rwaldron / weakmap.js
Created May 9, 2011 22:54
Example of WeakMap usage. Run in Firefox Nightly (>6.x)
var k = {}, v,
w = new WeakMap();
w.set( k, "value" );
console.log(
w.get( k )
);
// ...At some point the program no longer needs this
<?php
header("Content-Type: text/event-stream\n\n");
echo 'data: ' . json_encode(
array(
0 => array(
'time' => time(),
'message' => 'Some kind of foo'
),
1 => array(
/*!
* jQuery JavaScript Library v2.1.1pre
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
@rwaldron
rwaldron / Setting up Google Cloud Storage with CORS for Web Fonts.md
Created January 16, 2018 21:47 — forked from mhulse/Setting up Google Cloud Storage with CORS for Web Fonts.md
Setting up CORS on Google Cloud Storage: An unofficial quick start guide to serving web fonts from Google's cloud. (I'm sure a lot of this info could be improved... Please leave comments if you have tips/improvements.)

Login:

Google Cloud Storage

You'll want to login using an official Google account (i.e. if this is for your company, use the comapany Gmail account vs. a personal one.)

When logging in, you might be prompted to verify the account; if so, enter your cell number to get a verification e-mail or phone call.

Once verified, you'll have to agree to the terms of service; do that, and click continue.

@rwaldron
rwaldron / getMyCode.js
Created September 24, 2011 16:37 — forked from creationix/getMyCode.js
Script to download all repos for a user
// Run this with node and then run the output with sh
var Http = require('http')
var ChildProcess = require('child_process');
Http.cat("http://github.com/api/v2/json/repos/show/creationix", function (err, json) {
if (err) throw err;
var data = JSON.parse(json);
data.repositories.forEach(function (repo) {
console.log("echo " + JSON.stringify(repo.name + " - " + repo.description));
console.log("git clone --bare " + repo.url);
});
@rwaldron
rwaldron / iframe-document.js
Created July 28, 2011 16:57
Get the document of an iframe element
var iframe = document.getElementById("my-iframe"),
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
console.log( iframeDoc );
@rwaldron
rwaldron / Pattern.lua
Created September 24, 2011 16:37 — forked from creationix/Pattern.lua
Pattern.js ported to Lua
Pattern = {}
function Pattern:extend(obj)
local child = obj or {}
setmetatable(child, {__index = self})
return child
end
function Pattern:new(...)
local obj = {}
@rwaldron
rwaldron / a.js
Last active February 2, 2023 06:37
(function( exports ) {
function Menu( options ) {
var actions,
button = document.createElement("button");
// Assert qualities of options object here
// Store the option items in an object that allows access
// via string property name
@rwaldron
rwaldron / gettext-extraction.js
Created June 20, 2011 18:35
Extract gist text from document.write() embed
/*!
* getText lifted from Sizzle.getText
* Sizzle CSS Selector Engine
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
* More information: http://sizzlejs.com/
*/
function getText( nodeList ) {
var ret = "",
elem;