Skip to content

Instantly share code, notes, and snippets.

View robbyrussell's full-sized avatar
🤡
Life: WIP

Robby Russell robbyrussell

🤡
Life: WIP
View GitHub Profile
# get the name of the branch we are on
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
branch=${ref#refs/heads/}
if [[ -d .git ]]; then
CURRENT_BRANCH="%{$fg[red]%}git:(%{$fg[green]${branch}$(parse_git_dirty)%{$fg[red])"
else
CURRENT_BRANCH=''
fi
@robbyrussell
robbyrussell / container_of_widgets.html
Created January 29, 2009 06:02
basic carousel-like class using Prototype
<div id="x_container">
<a id="x_back_button"><img src="/images/left-arrow.png" /></a>
<a id="x_forward_button"><img src="/images/right-arrow.png" /></a>
<div class="x_widget">
<p>content...1</p>
</div>
<div class="x_widget" style="display:none;">
<p>content...2</p>
map.resources :containers do |container|
container.resources :widgets
end
# gives us...
# /containers/:container_id
# /containers/:container_id/widgets/
# /containers/:container_id/widgets/:id
# but what i really want is...
Missing these required gems:
feedtools = 0.2.29
You're running:
ruby 1.8.6.114 at /opt/local/bin/ruby
rubygems 1.3.1 at /Users/robbyrussell/.gem/ruby/1.8, /opt/local/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
git:(master):
git:(master): gem list|grep feed
@robbyrussell
robbyrussell / better-favicon-for-google.js
Created January 12, 2009 22:15
Greasemonkey script to change the favicon for Google to a old and improved (and less colorful one)
// ==UserScript==
// @name BetterFavicon
// @namespace planetargon
// @description A better favicon for google
// @include http://*.google.com/
// ==/UserScript==
var favicon_link_html = document.createElement('link');
favicon_link_html.rel = 'icon';
favicon_link_html.href = 'http://robbyonrails.com/files/google-favicon.ico';
@robbyrussell
robbyrussell / subdomain_accounts.rb
Created January 11, 2009 22:40
handle subdomain-based accounts with rails
#
# Inspired by
# http://dev.rubyonrails.org/svn/rails/plugins/account_location/lib/account_location.rb
#
module SubdomainAccounts
def self.included( controller )
controller.helper_method(:account_domain, :account_subdomain, :account_url, :current_account, :default_account_subdomain, :default_account_url)
end
protected
def auto_complete_for_search_query
if params.has_key( :search_query ) and not params[:search_query].blank?
search_query = "%#{params[:search_query]}%"
@cars = Car.find( :all, :conditions => [ 'title LIKE ?', search_query ] )
render :partial => "search_results"
end
end
def search_query
auto_complete_for_search_query
<ul class="horizontal main_nav">
<li <%= 'class="active"' if current_page?( root_path ) -%>><%= link_to_unless_current( 'Plans', root_path, { :title => 'Boxcar Plans' } ) -%></li>
<li <%= 'class="active"' if current_page?( contact_path ) -%>><%= link_to_unless_current( 'Contact Us', contact_path, { :title => 'Contact Us' } ) -%></li>
<li <%= 'class="active"' if current_page?( support_path ) -%>><%= link_to_unless_current( 'Get Support', support_path, { :title => 'Get Support' } ) -%></li>
</ul>
@robbyrussell
robbyrussell / nightly-task.rb
Created November 24, 2008 05:46
a nightly task that could use some refactoring
#!/usr/bin/env ruby
sleep( 28800 )
#!/bin/sh
#
# bash script to run a git-pull... and restart mongrel for you...
#
function mongrel_reload {
mongrel_rails stop;
mongrel_rails start -d;
}