This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Capistrano "push strategy", take 2 | |
# | |
# It's based on "remote_cache", but doesn't rely on a central git repository. | |
# It assumes that the code is already pushed to its "cached-copy". | |
# | |
# Usage: | |
# | |
# git remote add origin example.com:/path/to/my-app/shared/cached-copy/.git | |
# cap deploy | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
RE="ruby-enterprise-1.8.6-20090520" | |
PREFIX=/opt/$RE | |
VERSION=2.2.2 | |
GEM_PATH="$PREFIX/lib/ruby/gems/1.8/gems/passenger-$VERSION" | |
DOMAIN=example.com | |
APP_ROOT=/u/apps/$DOMAIN | |
# install Apache2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.observe("dom:loaded", function() { | |
function updateElementsWithTime() { | |
$$("span[time]").invoke('updateTime') | |
} | |
// update immediately | |
updateElementsWithTime() | |
// continue updating every 2 minutes | |
new PeriodicalExecuter(updateElementsWithTime, 60 * 2) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.stripTags = String.prototype.stripTags.wrap( | |
function(proceed, allowTags) { | |
if (allowTags) { | |
if (Object.isString(allowTags)) allowTags = $w(allowTags) | |
this.gsub(/(<\/?\s*)([^\s>]+)(\s[^>]*)?>/, function(match) { | |
if (allowTags.include(match[2].toLowerCase())) | |
return match[1] + match[2] + match[3] + '>' | |
}) | |
} else { | |
// proceed using the original function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *** JSON to HTML markup for a single update *** // | |
var buildUpdateFromJSON = (function() { | |
var updateContainer = $E('ol', { 'class': 'statuses' }) | |
return function(data) { | |
var isReply = data.in_reply_to_screen_name, | |
date = new Date(data.created_at), | |
preparedData = { | |
id: data.id, reply_class: isReply ? 'reply' : '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'haml/engine' | |
module Haml::Precompiler | |
alias original_flush_merged_text flush_merged_text | |
def flush_merged_text | |
@to_merge.each_with_index do |item, i| | |
next_item = @to_merge[i + 1] | |
item[1].chomp!("\n") if item[1][0, 1] == '<' and (!next_item or next_item[1][0, 1] == '<') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currentSubmit = null | |
form.select('input[type=submit]').invoke('observe', 'click', function(e) { | |
currentSubmit = this.name | |
}) | |
form.observe('submit', function(e) { | |
var params = this.serialize({ submit: currentSubmit }) | |
console.log(Object.inspect(params)) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkUserscriptUpdate = (function(){ | |
if (typeof GM_xmlhttpRequest != "function") return (function() {}) // no-op | |
var update = { | |
get available() { return getValue('updateAvailable', false) }, | |
set available(value) { setValue('updateAvailable', value) }, | |
get scriptLength() { return getValue('scriptLength') }, | |
set scriptLength(value) { setValue('scriptLength', value) }, | |
get checkedAt() { return getValue('updateTimestamp') }, | |
set checkedAt(value) { setValue('updateTimestamp', value) }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /^I go to(?: the)? (.*?)(?: page)?$/ do |name| | |
visit get_named_route(name) | |
end | |
Then /^I should be on(?: the)? (.*?)(?: page)?$/ do |name| | |
path.should == get_named_route(name) | |
end | |
## features/support/env.rb | |
ActionController::Integration::Session.class_eval do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this goes in the $HOME dir | |
# needs mislav-rspactor v0.3.2 and RSpec 1.2 | |
RSpactor::Runner.class_eval do | |
alias old_formatter_opts formatter_opts | |
def formatter_opts | |
# update this path to where you saved unicode_formatter.rb | |
old_formatter_opts + " -r /Users/mislav/Projects/unicode_formatter -f UnicodeFormatter" | |
end | |
end |