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
# | |
# NOTICE: The stop/restart tasks won't work properly due to a bug in the daemons gem | |
# unless you use the ghazel-daemons gem by putting this in your environment.rb file: | |
# | |
# config.gem "ghazel-daemons", :lib => "daemons" | |
# gem "ghazel-daemons" | |
# require "daemons" | |
# | |
# This will force-load the 'ghazel-daemons' gem and make sure it's used instead of | |
# the 'daemons' gem. It works even with the 'daemons' gem installed, so you won't |
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 'action_view' | |
require 'active_support' | |
require 'mustache' | |
class Mustache | |
# Remember to use {{{yield}}} (3 mustaches) to skip escaping HTML | |
# Using {{{tag}}} will skip escaping HTML so if your mustache methods return | |
# HTML, be sure to interpolate them using 3 mustaches. |
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 genitivize(name) | |
name.strip.sub(/(s)?$/i) { |s| s.downcase == 's' ? "#{s}’" : '’s' } | |
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
module Archives | |
module Callbacks | |
def self.included(base) | |
base.send :include, Archives::Callbacks::InstanceMethods | |
base.before_create :do_something_awesome | |
end | |
module InstanceMethods | |
private |
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
// UITextFieldDelegate method, called when the "Return" key is pressed. | |
// Either advance the cursor to the next empty field, or submit the form. | |
// | |
- (BOOL)textFieldShouldReturn:(UITextField *)textField { | |
if([usernameField.text length] == 0) { | |
[usernameField becomeFirstResponder]; | |
} else if ([passwordField.text length] == 0) { | |
[passwordField becomeFirstResponder]; | |
} 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
module Mongo | |
module Instrumentation | |
def self.instrument(clazz, *methods) | |
clazz.module_eval do | |
methods.each do |m| | |
class_eval %{def #{m}_with_instrumentation(*args, &block) | |
ActiveSupport::Notifications.instrumenter.instrument "mongo.mongo", :name => "#{m}" do | |
#{m}_without_instrumentation(*args, &block) | |
end | |
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
module RequireLoggedUser | |
protected | |
def require_logged_user! | |
before_filter do | |
return true if current_user.present? | |
# if the method hasn't returned, there is no user logged in! | |
# flash a warning and redirect the user to the log in page | |
flash[:warning] = "You must log in before proceeding!" | |
redirect_to new_user_session_path and return | |
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
source :rubygems | |
gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'arel', :git => 'git://github.com/rails/arel.git' | |
gem 'rack', :git => 'git://github.com/rack/rack.git' | |
gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git' | |
gem 'sqlite3' | |
# Asset template engines |
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 Project < ActiveRecord::Base | |
class << self | |
def always_attributes | |
%w{attributes anybody can edit} | |
end | |
def draft_attributes | |
%w{available only while project is being written} |
OlderNewer