Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
def IRB.run_config
if @CONF[:RC]
begin
load rc_file
rescue LoadError, Errno::ENOENT
rescue
print "load error: #{rc_file}\n"
print $!.class, ": ", $!, "\n"
for err in $@[0, [email protected] - 2]
print "\t", err, "\n"
/*
* a smart poller for jquery.
* (by github)
*
* simple example:
*
* $.smartPoller(function(retry) {
* $.getJSON(url, function(data) {
* if (data) {
* doSomething(data)
@CodeOfficer
CodeOfficer / finder_sort.rb
Created July 7, 2009 22:07 — forked from ryanb/finder_sort.rb
sorting like mac's finder
# Mimic Mac OS X Finder's sort by name.
class Array
def finder_sort
sort_by { |s| s.to_finder_sort }
end
end
class String
def to_finder_sort
punctuation = %w[` ^ _ - , ; ! ? ' " ( ) [ ] { } @ *] + ['\\'] + %w[& # % + < = > | ~ $]
require '../lib/liquid'
class User
attr_accessor :name
liquid_methods :name
def initialize(name)
@name = name
end
end
# Install logrotate on OS X:
# sudo port clean --all logrotate && sudo port install logrotate
# Add e.g. this to your crontab:
# /opt/local/sbin/logrotate -s /Users/deploy/.logrotate/sites.status /Users/deploy/.logrotate/sites.conf
# This file would be sites.conf.
# See http://overstimulate.com/articles/logrotate-rails-passenger for more info.
daily
missingok
rotate 30
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
def update
@instructor = Instructor.find(params[:id])
respond_to do |format|
if @instructor.update_attributes(params[:instructor][course])
flash[:notice] = 'Instructor was successfully updated.'
format.html { redirect_to(@instructor) }
format.xml { head :ok }
else
format.html { render :action => "edit" }