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 Video < ActiveRecord::Base | |
validates_presence_of :title | |
named_scope :finished, :conditions => { :encoded_state => "finished" } | |
has_attached_file :video, | |
:url => ":class/:id/:style/:basename.:extension", | |
:path => ":class/:id/:style/:basename.:extension", | |
:storage => :s3 | |
validates_attachment_presence :video |
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
# this does not work: | |
case @object.class | |
when ModelHome then path_for_model_home | |
end | |
# this works: | |
case @object | |
when ModelHome then path_for_model_home | |
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
def get_events | |
# TODO: remove - this is for testing and benchmarking the two implementations | |
if false | |
(conditions ||= []) << "user_id IN (#{params[:employee_ids].split('-').map{|i| i.to_i}.join(',')})" unless params[:employee_ids].blank? | |
(conditions ||= []) << "client_id IN (#{params[:client_ids].split('-').map{|i| i.to_i}.join(',')})" unless params[:client_ids].blank? | |
(conditions ||= []) << "group_id IN (#{params[:group_ids].split('-').map{|i| i.to_i}.join(',')})" unless params[:group_ids].blank? | |
@events = conditions.blank? ? [] : Event.all(:conditions => ["(starts_on >= ? AND ends_on <= ?) AND (#{conditions.join(' OR ')})", Time.at(params[:start].to_i), Time.at(params[:end].to_i)], :include => :group) | |
render :json => { :events => @events.map {|e| e.attrs_for_json(params[:employee_ids], params[:client_ids]) } } | |
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
<?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>DVTConsoleDebuggerInputTextColor</key> | |
<string>0.995968 0.995968 0.995968 1</string> | |
<key>DVTConsoleDebuggerInputTextFont</key> | |
<string>Inconsolata - 16.0</string> | |
<key>DVTConsoleDebuggerOutputTextColor</key> | |
<string>0.995968 0.995968 0.995968 1</string> |
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
# controller | |
def notify | |
order = Order.capture_payment(request.raw_post) | |
render :nothing => true | |
end | |
# Order model | |
def self.capture_payment(raw_post) |
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 | |
class DispatchQueueCreator | |
class << self | |
def send_to_all_subscribers!(dispatch) | |
Subscriber.all.each do |subscriber| | |
qd = QueuedDispatch.create(:subscriber => subscriber, :dispatch => dispatch) | |
qd.send! |
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
# in the view | |
= form_for([:forge, @job, job_application], :remote => true) do |f| | |
# in the JS header portion of the view | |
$("form").on("ajax:success", function(data, status, xhr) { | |
alert("Success"); | |
}); |
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
- (void) handleDataFromRemoteOrigin:(id)data | |
{ | |
NSString *content; | |
*content = [data valueForKeyPath:@"content"]; | |
} |
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 Lead | |
state = "in-progress" | |
end | |
# OR | |
class Lead | |
constructor: -> | |
super |
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 Forge | |
require 'forge/settings' | |
require 'forge/credit_card_processor' | |
@@settings = YAML::load(File.open(Rails.root + 'config/settings.yml')).recursive_symbolize_keys! | |
def self.settings | |
@@settings | |
end |
NewerOlder