This file contains 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
# Given a set of class names, will require objects of those types to have been populated | |
# Usage: depends_on(User, Post, Comment) | |
def depends_on(*args) | |
raise "Depends on #{args.map{ |a| a.name.pluralize }.to_sentence.downcase} to populate data." if args.any? { |a| a.count.zero? } | |
args.each { |a| eval "@#{a.name.underscore.pluralize} = #{a}.all" } | |
end |
This file contains 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 'oauth/consumer' | |
require 'json' | |
class TwitterController < ApplicationController | |
before_filter :require_no_authentication | |
TWITTER_AUTH_KEY = '...' | |
TWITTER_AUTH_SECRET = '...' | |
TWITTER_AUTH_URL = 'http://twitter.com' | |
This file contains 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
dom_id = 'new_debt_lightview' | |
page << "e = $('#{dom_id}'); if (e != null) { e.remove() }" | |
page.insert_html :bottom, 'body', content_tag(:div, :id => dom_id, :style => 'display: none') { render :partial => 'new' } | |
page << "Lightview.show({ href: '##{dom_id}', rel: 'inline', title: 'New Debt', options: { width: 420, height: 280 } });" |
This file contains 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 AppTweeter < Struct.new(:status) | |
class << self | |
def new_user(user) | |
update("#{user.name} just signed up!") | |
end | |
def update(status) | |
status = "[#{Rails.env}] #{status}" unless Rails.env.production? | |
Delayed::Job.enqueue AppTweeter.new(status) | |
end |
This file contains 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
mysqldump --user username -ppassword -h host --complete-insert --skip-extended-insert --compact --no-create-info database_name table_name > output_file.sql |
This file contains 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
stylesheets = Dir.glob('public/**/*.css') | |
html = [] | |
stylesheets.each do |stylesheet| | |
stylesheet = stylesheet.gsub('public/stylesheets/', '') | |
if stylesheet =~ /html/ | |
html << stylesheet | |
else |
This file contains 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
gem 'haml', '3.0.18' |
This file contains 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
$column_width: 60px; | |
$gutter_width: 10px; | |
@mixin container($number_of_columns: 12) { | |
margin-left: auto; | |
margin-right: auto; | |
width: $number_of_columns * $column_width; | |
} | |
@mixin grid($number_of_columns) { |
This file contains 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
def accept_offer | |
self.update_attributes! { | |
:offer_accepted_at => Time.now, | |
:offer_declined_at => nil | |
} | |
self | |
end | |
def decline_offer | |
self.update_attributes { |
This file contains 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
def memcached_up? | |
client = Dalli::Client.new('...', :username => '...', :password => '...') | |
client.get('test').nil? | |
rescue | |
false | |
end |
OlderNewer