Skip to content

Instantly share code, notes, and snippets.

View christianromney's full-sized avatar
🏠
Working from home

Christian Romney christianromney

🏠
Working from home
View GitHub Profile
@christianromney
christianromney / _menu.rhtml
Created October 29, 2008 19:30
Granted the user conditions are a bit contrived...
<!-- Ahhh, cleaner :) -->
<% privileged_users do %>
<%= render :partial => 'admin/menu' %>
<% end.else do %>
<%= render :partial => 'menu' %>
<% end %>
history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -r
rake auth:gen:site_key # Generates config/initializers/site_keys.rb
rake cruise:test # Run all the specifications after resetting test database
rake db:abort_if_pending_migrations # Raises an error if there are pending migrations
rake db:charset # Retrieves the charset for the current environment's database
rake db:collation # Retrieves the collation for the current environment's database
rake db:create # Create the database defined in config/database.yml for the current RAILS_ENV
rake db:create:all # Create all the local databases defined in config/database.yml
rake db:development:backup # backs up the development database to development.pristine
rake db:development:load # load the local development database from the models specified in 'load_for'.
rake db:development:restore # restore the state of the deve
@christianromney
christianromney / application.rb
Created December 21, 2008 02:37
Forcing Rails to Think a Request is Using SSL
# app/controllers/application.rb
class ApplicationController < ActionController::Base
before_filter :modify_protocol
private
def modify_protocol
returning(true) do
if Rails.configuration.protocol_modifier
@christianromney
christianromney / gist:45151
Created January 9, 2009 16:15
Update Git Documentation on my Mac
# Usage: git-doc-up 1.6.1
function git-doc-up() {
wget http://www.kernel.org/pub/software/scm/git/git-manpages-$1.tar.bz2
sudo tar xjv -C /usr/share/man -f git-manpages-$1.tar.bz2
rm git-manpages*bz2
echo "Be sure to run 'sudo periodic weekly'"
}
@christianromney
christianromney / gist:57091
Created February 2, 2009 20:54
...from AWS::S3
def request(verb, path, options = {}, body = nil, attempts = 0, &block)
Service.response = nil
process_options!(options, verb)
response = response_class.new(connection.request(verb, path, options, body, attempts, &block))
Service.response = response
Error::Response.new(response.response).error.raise if response.error?
response
# Once in a while, a request to S3 returns an internal error. A glitch in the matrix I presume. Since these
# errors are few and far between the request method will rescue InternalErrors the first three times they encouter them
build do
copy 'src/specs', 'target/specs' do |filter|
filter.created_at < Time.now && filter.version == current_version
end
end
var links = Dom.getElementsBy(function (el) {
return el.href.match(/pica9/);
}, 'A', 'menu_travel_tools');
if (links && 0 < links.size) {
Dom.get('pica-link').href = links[0].href;
}
@christianromney
christianromney / gist:85531
Created March 25, 2009 15:41
Font replace H1 or H6 with the word 'title' in the class name (case-insensitive)
Dom.getElementsBy(function (el) {
return el.tagName.match(/^H[16]$/) && el.className.match(/title/i);
}, null, 'frame', Cufon.replace);
@christianromney
christianromney / string_reverse.js
Created April 17, 2009 17:56
String Reverse for Javascript
// The fastest way to reverse a string....
String.prototype.reverse = function () {
return this.split("").reverse().join("");
};