Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby -rubygems
# This is a replacement for "livereload" gem for working with Rails.
# It watches the filesystem with OS X FSEvents rather than with EventMachine.
# This is better for large projects for wich EventMachine fails.
#
# Sass is supported; .sass files can also be stored in "app/styles/" directory.
#
# Command line options are "-D" to enable debug mode. All other parameters
# (if given) specify a list of directories to watch.
@micho
micho / Prompt git branch for bash
Created September 10, 2010 12:00
Git branches on terminal prompt. Add to your .bash_profile file
# This will add the git branch to your path, with something like this:
# ~/code/teambox[master]:
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
function precmd() {
PROMPT="%n@%m %~$(parse_git_branch)%# "
}
@micho
micho / gist:870485
Created March 15, 2011 09:15
CAPSLOCK PLUGIN FOR TALKERAPP.COM
plugin.onMessageSend = function (event) {
if ((new Date()).getDate() === 14) {
if ((event.content.match(/^([a-z]+)$/) || [false])[0]) {
alert('Y U NO UZ CAPSLOCK?');
}
Talker.sendMessage(event.content.toUpperCase());
Talker.getMessageBox().val('');
return false;
}
else {
@micho
micho / gist:872697
Created March 16, 2011 15:46
Cloudapp plugin for Talkerapp
plugin.onMessageSend = function (event) {
var match, url, content;
if (match = event.content.match(/(https?:\/\/cl.ly\/[^\/]+)(\/[^\/]+)*/)) {
url = match[1] || false;
content = match[2] || false;
if (!content || content.indexOf('/content') != -1) {
event.content = event.content.replace(url, url+'/content#.png');
Talker.sendMessage(event, "");
Talker.getMessageBox().val('');
return false;
@micho
micho / gist:1120193
Created August 2, 2011 13:37
Prompt branch for bash
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
function precmd() {
PROMPT="%n@%m %~$(parse_git_branch)%# "
}
export PATH="/usr/local/mysql/bin:${PATH}:/usr/local/git/bin"
function proml {
@micho
micho / debug.js
Created February 9, 2012 10:50
debug times for js
/**
* Create a debugger with the given `name`.
*
* @param {String} name
* @return {Type}
* @api public
*/
function debug(name) {
var now = Date.now();
alert(1)
@micho
micho / wysihtml5-resize.js
Created March 29, 2012 20:30
wysihtml5 resize plugin. Depends on jQuery and Underscore
(function () {
var setupRegularResize, setupIframeResize, e;
function bind(a, b) {
return function () {
return a.apply(b, arguments);
};
}
setupRegularResize = (function () {
@micho
micho / gist:2354772
Created April 10, 2012 21:39
Teambox for Box
// Run this in your JS console while on box.com
$("#files_tab").after(
'<li id="teambox_tab" class="current">' +
'<a id="teambox_tab_link" href="https://teambox.com?embedded=1" onmousedown="return false;">Teambox</a></li>'
);
$(".body .main").html(
'<iframe src="https://teambox.com?embedded=1" style="border: none; width: 720px; height: 100000px"></iframe>'
);
Resource Cache mechanism, for projects and people
Resource Cache is a key-value auto-expiring cache, where we pass
the path for a base model + a resource owned by it + modifiers.
Structure
---------
Each cacheable entry is called with two or three parameters: