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
SELECT FROM_UNIXTIME(CEILING(UNIX_TIMESTAMP(created_At)/600)*600) AS timeslice, | |
COUNT(id) AS count | |
FROM export_articles | |
GROUP BY timeslice | |
ORDER BY timeslice |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>name</key> | |
<string>Epic</string> | |
<key>settings</key> | |
<array> | |
<dict> | |
<key>settings</key> |
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 Blah | |
def self.go | |
begin | |
Blah.export | |
rescue => e | |
logger.error(e) | |
end | |
logger.info("Blah#go done") | |
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
class Feed | |
has_many :imports | |
# SQL: | |
# SELECT feeds.*, COUNT(imports.id) AS import_count | |
# FROM `feeds` | |
# LEFT OUTER JOIN imports ON imports.feed_id = feeds.id | |
# GROUP BY imports.feed_id | |
# ORDER BY import_count DESC | |
# LIMIT 5 |
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 YourModel < ActiveRecord::Base | |
validates_format_of :email, :with => RFC822::EmailAddress | |
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
# This Rails 2.3.x template will create a new git-based Rails project | |
# with Cucumber, RSpec and Remarkable pre-installed and ready to go. | |
# | |
# (C) 2009 under the MIT License by Ariejan de Vroom <[email protected]> | |
# | |
# USAGE: | |
# rails -d mysql -m http://gist.github.com/181167.txt APP_NAME | |
# Delete unnecessary files |
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
You must be using git and capistrano to deploy your app. Capistrano will place a file in your Rails.root named 'REVISION'. Tested with the following capistrano setting: | |
set :scm, :git | |
set :deploy_via, :remote_cache |
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
# This little nugget will remove an existing rake task. This allows you to | |
# redefine tasks. | |
# | |
# remove_task :test | |
# task :test => [:spec, :features] | |
# | |
Rake::TaskManager.class_eval do | |
def remove_task(task_name) | |
@tasks.delete(task_name.to_s) | |
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
# Use ApiKey.generate to generate a new API key | |
class ApiKey < ActiveRecord::Base | |
validates_presence_of :key | |
validates_uniqueness_of :key | |
def self.generate(description = "No description") | |
key = Digest::SHA1.hexdigest("--#{Time.now}--#{description}--") | |
ApiKey.create(:description => description, :key => key) | |
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
%! program = pdflatex | |
\documentclass[9pt,twoside,pageany]{memoir} | |
% Sets the papersize. | |
% \settrimmedsize{4.25in}{6.875in}{*} | |
% Sets the papersize. | |
\setstocksize{17.463cm}{10.795cm} |