This file contains hidden or 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 JobsController < ApplicationController | |
before_filter :require_user, :except => [ :index, :show ] | |
def index | |
@listings = Job.find_by_complex_search(current_user, params).paginate({ :page => params[:page], :per_page => CONFIG['per_page'] }) | |
flash.now[:notice] = "Sorry, there were no records found." if @listings.blank? | |
respond_to do |format| | |
format.html # index.html.erb |
This file contains hidden or 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
(function(message){ | |
alert(message); | |
})('hello!'); | |
// ------------------------- | |
var Test = function() { | |
var message = 'hello'; | |
return { | |
say: function() { |
This file contains hidden or 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
module AccordionsHelper | |
def accordions_for( *options, &block ) | |
raise ArgumentError, "Missing block" unless block_given? | |
accordions = AccordionsHelper::AccordionsRenderer.new( *options, &block ) | |
accordions_html = accordions.render | |
concat accordions_html | |
end | |
This file contains hidden or 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
/* | |
* a smart poller for jquery. | |
* (by github) | |
* | |
* simple example: | |
* | |
* $.smartPoller(function(retry) { | |
* $.getJSON(url, function(data) { | |
* if (data) { | |
* doSomething(data) |
This file contains hidden or 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
# adapted from http://blog.caboo.se/articles/2006/12/28/a-better-capistrano-backup | |
# supports multistage deploy setup | |
# allows for restore and local database imports | |
namespace :db do | |
desc "Copy the remote production database to the local development machine" | |
task :backup, :roles => :db, :only => { :primary => true } do | |
filename = "#{application}_#{Time.now.strftime("%Y%m%d_%H%M%S")}.sql.bz2" | |
backupfile = "/tmp/#{filename}" | |
data = capture "cat #{shared_path}/config/database.yml" |
This file contains hidden or 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.restForm = function(type, options) { | |
var defaults = { | |
method: 'post', | |
action: this.attr('href'), | |
confirm: false, | |
confirm_message: 'Are you sure?', | |
trigger_on: 'click' | |
}; | |
var opts = $.extend(defaults, options); |
This file contains hidden or 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
# 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[& # % + < = > | ~ $] |
This file contains hidden or 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
$('button[type="submit"]').bind('click', function() { | |
this.setAttribute('originalValue', this.innerHTML); | |
this.disabled=true; | |
this.innerHTML='Submitting...'; | |
result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit()); | |
if (result == false) { this.innerHTML = this.getAttribute('originalValue'); this.disabled = false }; | |
return result; | |
}); |
This file contains hidden or 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 'tempfile' | |
def say(cmd, voice='Fred') | |
temp_file = Tempfile.new('sayfile') | |
tf = File.new(temp_file.path, "w+") | |
tf.puts(cmd) | |
tf.close | |
`cat #{temp_file.path} | /usr/bin/say -v #{voice}` | |
temp_file.unlink | |
end |
This file contains hidden or 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
# another great snippet courtesy of http://heypanda.com/ | |
class Fixnum | |
# returns seconds | |
def hours | |
self * 3600 | |
end | |
end | |
def forever |