Skip to content

Instantly share code, notes, and snippets.

# rotate rails logs on OS X using newsyslog
# Place this file in /etc/newsyslog.d/
# change the logfilename to match where your rails apps are
# count: how many old files to keep around, this is dev, so 0
# size: 1000 kb
# when: * - only rely on the size property
# flags: G - interpret logfilename as a shell pattern
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/forge38/clients/**/**/rails/log/*.log 666 0 1000 * G
# add something like this to cron on a machine at home to always have a
# file with your current ip address of your home.
@hourly /usr/bin/curl www.whatismyip.com/automation/n09230945.asp > Dropbox/homeip.txt
// this is a fix for the jQuery slide effects
// found here: http://blog.pengoworks.com/index.cfm/2009/4/21/Fixing-jQuerys-slideDown-effect-ie-Jumpy-Animation
function slideToggle(el, bShow){
var $el = $(el), height = $el.data("originalHeight"), visible = $el.is(":visible");
// if the bShow isn't present, get the current visibility and reverse it
if( arguments.length == 1 ) bShow = !visible;
// if the current visiblilty is the same as the requested state, cancel
if( bShow == visible ) return false;
58143 entries for drawing 1691
Archived 5000 entries in 23.919985
Archived 5000 entries in 19.767098
Archived 5000 entries in 20.035886
Archived 5000 entries in 22.990958
Archived 5000 entries in 19.463445
Archived 5000 entries in 24.24046
Archived 5000 entries in 22.053064
Archived 5000 entries in 20.417995
Archived 5000 entries in 17.902337
@r38y
r38y / abstract.rb
Created November 12, 2010 17:49
How to declare which methods should be defined in a subclass of an abstract class
module Abstract
def abstract_methods(*args)
args.each do |name|
class_eval(<<-END, __FILE__, __LINE__)
def #{name}(*args)
raise NotImplementedError.new("You must implement #{name}.")
end
END
end
end
config.action_controller.asset_host = Proc.new do |source, request|
"#{request.protocol}asset#{source.hash % 4}.#{CONFIG.domain}"
end if ['staging', 'production', 'development'].include?(Rails.env)
@r38y
r38y / gist:737603
Created December 11, 2010 19:41
Notices from Postgres
NOTICE: CREATE TABLE will create implicit sequence "announcements_id_seq" for serial column "announcements.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "announcements_pkey" for table "announcements"
NOTICE: CREATE TABLE will create implicit sequence "comments_id_seq" for serial column "comments.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "comments_pkey" for table "comments"
NOTICE: CREATE TABLE will create implicit sequence "delayed_jobs_id_seq" for serial column "delayed_jobs.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "delayed_jobs_pkey" for table "delayed_jobs"
NOTICE: CREATE TABLE will create implicit sequence "email_reminder_templates_id_seq" for serial column "email_reminder_templates.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "email_reminder_templates_pkey" for table "email_reminder_templates"
NOTICE: CREATE TABLE will create implicit sequence "friends_id_seq" for serial column "friends.id"
NOTICE: CREATE
class Question < ActiveRecord::Base
belongs_to :question_group
has_many :all_options, :dependent => :destroy, :class_name => 'Option'
has_many :options, :conditions => {:active => true}
has_many :correct_options, :conditions => {:correct => true, :active => true}, :class_name => 'Option'
has_many :askings
has_many :notes, :as => :notable, :dependent => :destroy
scope :active, where(:active => true)
scope :inactive, where(:active => false)
@r38y
r38y / keep.r38y.conf
Created April 14, 2011 22:39
nginx vhosts for proxying requests from facebook to my local machine.
server {
listen 3838;
server_name r38y.publicdomain.com;
location / {
proxy_pass http://web1.tunnlr.com:publicport/;
proxy_redirect off;
}
}
server {
ree-1.8.7-2011.03 :003 > Time.zone.name
=> "UTC"
ree-1.8.7-2011.03 :004 > u[:updated_at]
=> Wed Jul 13 18:45:00 UTC 2011
ree-1.8.7-2011.03 :005 > Time.zone = 'Eastern Time (US & Canada)'
=> "Eastern Time (US & Canada)"
ree-1.8.7-2011.03 :006 > Time.zone.name
=> "Eastern Time (US & Canada)"
ree-1.8.7-2011.03 :007 > u[:updated_at]
=> Wed Jul 13 18:45:00 UTC 2011