Skip to content

Instantly share code, notes, and snippets.

View brettstimmerman's full-sized avatar

Brett Stimmerman brettstimmerman

View GitHub Profile
<?php
function getItems() {
$items = array();
// Get items from somewhere
return $items;
}
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
?>
<rss version="2.0">
@brettstimmerman
brettstimmerman / gist:382508
Created April 28, 2010 18:33
Show svn info in your bash prompt
# Returns (svn:<revision>:<branch|tag>[*]) if applicable
svn_prompt() {
if [ -d ".svn" ]; then
local branch dirty rev info=$(svn info 2>/dev/null)
branch=$(svn_parse_branch "$info")
# Uncomment if you want to display the current revision.
#rev=$(echo "$info" | awk '/^Revision: [0-9]+/{print $2}')
/*
This Vows test suite produces the following spec output with vows 0.5.1 and
node 0.2.1.
♢ Emitter
A NonEmitter does not inherit from EventEmitter
✓ and can be tested
✗ Errored » Emitter: An Emitter inherits from EventEmitter ∙ not fired!
@brettstimmerman
brettstimmerman / index.html
Created March 11, 2011 01:07
Duck punch Node.scrubVal's inability to handle empty arrays
<!doctype html>
<html>
<head>
<title>Duck punch Node.scrubVal's inability to handle empty arrays</title>
</head>
<body>
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
@brettstimmerman
brettstimmerman / svn-slog
Created April 9, 2011 01:19
Quick n' dirty svn log search.
#!/usr/bin/env ruby
trap(:SIGINT){}
opts = {}
pattern = []
help = <<HELP
svn-slog filters output from `svn log`. It reads standard input if given,
otherwise `svn log` is run in the background.
@brettstimmerman
brettstimmerman / gist:943498
Created April 27, 2011 00:38
Load a YUI Gallery module locally for testing.
/**
* Load a YUI Gallery module locally for testing.
*
* Assumes you've built your module with ant and have a local copy of the
* yui3-gallery repo.
*
* This will override Loader's Gallery configuration. Existing Gallery modules
* will load locally, and your new module should load locally as well.
*
* Props to Caridy for helping piece this together.
@brettstimmerman
brettstimmerman / inspector.html
Created May 5, 2011 23:24
Gallery modules and Y.Intl language bundles.
<!doctype html>
<html>
<head>
<title>Inspector: Loader Test</title>
<style>
body { font: 13px Arial; }
.error { color: #f00; }
</style>
</head>
<body class="yui3-skin-sam">
@brettstimmerman
brettstimmerman / gist:3711302
Created September 13, 2012 01:43
Echo all 256 tput foreground colors
# Echo all 256 tput foreground colors
for i in {0..255}
do
echo "$(tput setaf $i)$i: The quick brown fox jumps over the lazy dog.$(tput sgr0)"
done
@brettstimmerman
brettstimmerman / multilinejs.py
Created June 13, 2013 22:38
A non-Python developer's attempt at a SublimeText 2 plugin.
import sublime
import sublime_plugin
import re
'''
SublimeText 2 plugin to convert selections (or the entire document) to a
JavaScript multiline string using the [].join('\n') idiom.
Given a document like:
@brettstimmerman
brettstimmerman / README.md
Created September 23, 2013 17:34
Use `Function.prototype.bind` to debug `Function.prototype.bind`.

Bindception

Use Function.prototype.bind to debug Function.prototype.bind.

The Problem

Debugging functions created with Function.prototype.bind is not easy. Calling toString on a bound function gives only 'function () { [native code] }', and the details of the binding are buried inside and unavailable.