View add-gitproj-as-rails-plugin
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
#!/bin/bash | |
PROJECT=$1 | |
GITPATH=$2 | |
if test -z "$PROJECT" || test -z "$GITPATH" | |
then | |
echo Usage: $0 project gitpath | |
exit 1 | |
fi | |
git remote add -f $PROJECT $GITPATH |
View gist:32869
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
#!/bin/bash | |
# | |
# place this file in the directory you want to keep the backup | |
# mysqldumps. this script lets you retrieve dumps of last 7 days, | |
# last month or any year | |
# | |
BACKUP_DB=app_production | |
cd `dirname $0` | |
mysqldump $BACKUP_DB -u root > today.sql && \ |
View gist:43643
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 searchtext = $('.searchtext')[0]; | |
function slow_hunt_for_ie(items, index) { | |
items = items || $('#ele, #ele *'); | |
index = index || 0; | |
searchtext.value = index; | |
var max = index + 5; | |
for (; index < max && index < items.length; index++) { | |
$(items[index]).css({ | |
border: '1px #000 solid', | |
margin: '0px', |
View load_vendor-gems.rb
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
# Modified from http://errtheblog.com/posts/50-vendor-everything | |
Dir["#{File.join(File.dirname(__FILE__), '..')}/vendor/gems/**"].map do |dir| | |
require_paths_file = File.join(dir, ".require_paths") | |
paths = File.exists?(require_paths_file) ? | |
IO.read(require_paths_file).split(/[\r\n]+/).collect {|subdir| File.join(dir, subdir) } : | |
[(File.directory?(lib = "#{dir}/lib") ? lib : dir)] | |
$LOAD_PATH.unshift(*paths) | |
end |
View gist:64557
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
class BigurlsController < ApplicationController | |
def index | |
url = URI.parse(params[:url]) | |
res = Net::HTTP.start(url.host, url.port) {|http| http.get([url.path, url.query].compact.join('?'), "User-Agent" => request.user_agent) } | |
render :text => (res['location'] || params[:url]) | |
rescue | |
"#{params[:url]}##{$!.to_s}" | |
end | |
end |
View gist:75025
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
# Append this content into ~/.irbrc | |
# | |
# irb console prompt to make the output copy-paste friendly | |
# overrides :simple for use in Rails' script/console | |
# overrides :default for use in regular irb session | |
IRB.conf[:PROMPT][:SIMPLE] = IRB.conf[:PROMPT][:DEFAULT] = { | |
:PROMPT_I => "\"%N(%m):%03n:%i>\"; ", # normal prompt: an inconsequential statement, a string | |
:PROMPT_S => "", # prompt for continuing strings: nothing | |
:PROMPT_C => "", # prompt for continuing statement: nothing | |
:RETURN => "#=> %s\n" # return value output is commented to not disrupt the code flow |
View gist:78819
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 controller illustrates the problem of Rails sending "Set-Cookie" back to the client | |
# when cookie-store is being used -- even when session data has NOT changed. | |
class HomeController < ApplicationController | |
def index | |
%w[one two three four five six].each do |word| | |
session[word] = word | |
end | |
render :text => "<a href='#{url_for(:action => 'show')}'>click here</a>" | |
end |
View simple function to inline css into chunk of html string.rb
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
def simple_inline_css(html, *css_files) | |
doc = Hpricot(html) | |
css_files.each do |css_file| | |
css_content_without_comments = IO.read(css_file).gsub(/\/\*.*?\*\//m, '') | |
css_content_without_comments.split('}').each do |rule| | |
(match, properties) = rule.split('{') | |
next unless properties | |
match.gsub!(/^\s*|\s*$/, '') | |
properties.gsub!(/^\s*|\s*$/, '') | |
(doc/match).each do |ele| |
View jQuery.highlight.js
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
jQuery.fn.extend({ | |
highlight: function(newColor, originalColor) { | |
newColor = 'yellow'; | |
if (! originalColor) { | |
var coloredElem = this; | |
while (!originalColor && originalColor != 'transparent' && coloredElem) { | |
originalColor = coloredElem[0].originalColor || coloredElem.css('background-color'); | |
coloredElem[0].originalColor = originalColor; | |
coloredElem = coloredElem.parent(); | |
} |
View facebox.shim.js
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
/* iframe shim for facebox */ | |
(function($) { | |
$(document).bind('reveal.facebox', function(event) { | |
$('#facebox')[0].shim = $('<iframe src="about:blank" frameborder="0"></iframe>').css({ | |
top: $('#facebox').offset().top + "px", | |
left: $('#facebox').offset().left + "px", | |
height: $('#facebox').height() + "px", | |
width: $('#facebox').width() + "px", | |
position: 'absolute' | |
}); |
OlderNewer