Skip to content

Instantly share code, notes, and snippets.

View bentruyman's full-sized avatar
🕺

Ben Truyman bentruyman

🕺
View GitHub Profile
@bentruyman
bentruyman / Custom.css
Created August 22, 2011 19:35
Tomorrow Theme for Chrome Developer Tools
/**********************************************/
/*
/* Tomorrow Skin by Ben Truyman - 2011
/*
/* Based on Chris Kempson's Tomorrow Theme:
/* https://github.com/ChrisKempson/Tomorrow-Theme
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@bentruyman
bentruyman / Custom.css
Created August 17, 2011 00:30
IR_Black Theme for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@bentruyman
bentruyman / tab-size.user.js
Created July 19, 2011 19:39
Resizes tab characters to 2 spaces (currently only works in FF4 and Opera 10.60)
// ==UserScript==
// @match http://*/*
// @match https://*/*
// ==/UserScript==
var style = document.createElement('style');
style.textContent = [
'pre { ',
' -webkit-tab-size: 2;',
' -moz-tab-size: 2;',
@bentruyman
bentruyman / jquery-pubsub.js
Created February 14, 2011 23:16
Simple Pub/Sub Implementation for jQuery
/*
* Simple Pub/Sub Implementation for jQuery
*
* Inspired by work from Peter Higgins (https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js)
*
* This is about the simplest way to write a pubsub JavaScript implementation for use with jQuery.
*/
(function( $ ) {
// Cache of all topics
@bentruyman
bentruyman / express-stylus.html
Created February 13, 2011 19:27
Using Stylus Middleware with Express
<!doctype html>
<html lang="en">
<head>
<title>My Web Page</title>
<meta charset="utf-8">
<link href="/stylesheets/main.css" rel="stylesheet">
</head>
<body>
</body>
</html>
var foo = true
(function bar () {
return false
}())
@bentruyman
bentruyman / dynamic_property_names_in_object_literals.js
Created October 26, 2010 20:00
Dynamic property names in object literals
// Can we get something like this??
var howManyRainbows = 'double';
var rainbow = {
(howManyRainbows): true
};
if (rainbow.double) {
alert('What does it mean?');
@bentruyman
bentruyman / to_return_or_not_return.js
Created October 21, 2010 18:04
Don't abuse `return`
// BAD: `return` shouldn't be used to control flow/execution
function loadProductData(query) {
if ($('body').hasClass('busy'))
return;
$.ajax( /*...*/ );
}
// GREAT SUCCESS: Just do this instead (OMG duh!)
function loadProductData(query) {
@bentruyman
bentruyman / promise_example.js
Created October 14, 2010 21:15
Promise Example
// npm install promised-io
var promised = require('promised-io/promise');
// all of these async methods return an instance of promised.Promise
var filePromise = getFile('/foo.html')
, databasePromise = getDatabaseRecord('users/bentruyman')
, websocketPromise = establishWebsocketConnection();
promised.all([filePromise, databasePromise, websocketPromise], function (arrayOfResolvedData) {
// all promises have been resolved
PROMPT='%{$fg_bold[red]%}➠ %{$fg_bold[yellow]%}%n%{$fg_bold[white]%}%p%{$fg_bold[white]%} of %{$fg_bold[blue]%}%m%{$fg_bold[white]%} in %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$fg[white]%}commands thee to %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"