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 Email < Message | |
attr_accessor :to, :cc, :bcc | |
validates :to, :presence => true, :on => :create | |
validates :to, :cc, :bcc, :emails => true | |
normalize_attribute :subject, :message | |
attr_accessible :to, :cc, :bcc, :subject, :message |
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 FreemiumPlan | |
include Billing::Plan | |
def cost | |
0 | |
end | |
def number_of_users | |
5 | |
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
// backend | |
$(document).ready(function() { | |
// the server sets parentUrl in the page it serves, based on the http-referer | |
var windowProxy = new Porthole.WindowProxy(window.parentUrl + "/proxy.html"); | |
function send(data) { | |
windowProxy.postMessage(JSON.stringify(data)); | |
} | |
windowProxy.addEventListener(function(event) { |
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 "resque", :require => 'resque/server' | |
gem 'resque-history' |
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
# From @gruber http://daringfireball.net/2010/07/improved_regex_for_matching_urls | |
#http://ryanangilly.com/post/8654404046/grubers-improved-regex-for-matching-urls-written | |
UrlRegex = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/?)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s\`!()\[\]{};:\'\".,<>?«»“”‘’]))/i |
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
// Correction to this article: http://kresimirbojcic.com/2011/11/19/dependency-injection-in-ruby.html | |
class TaxCode | |
GENERATORS = { | |
:us => lambda { |id| "US-#{id}" }, | |
:br => lambda { |id| "#{id + 9}-BRA" }, | |
} | |
def self.generate(code, id) | |
gen = GENERATORS[code] || raise ArgumentError, "No generator for country #{code}" | |
gen.call(id) |
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 'minitest/autorun' | |
class TaxCodeBase | |
class AbstractMethod < StandardError | |
end | |
attr_accessor :user_id | |
def initialize(user_id=nil) | |
self.user_id = user_id |
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
App.Forms.ImageUploader = Ember.View.extend | |
classNames: ['ember-image-uploader'] | |
controller: null | |
didInsertElement: -> | |
controller = @get('controller') | |
if controller.get('imageUploadUrl') | |
@initUploader() | |
else | |
@get('controller').addObserver 'imageUploadUrl', => | |
if @get('controller.imageUploadUrl') |
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
App.AccountEditRoute = Ember.Route.extend({ | |
setupController: function(controller) { | |
controller.set('content', this.get('currentUser')); | |
} | |
}); |
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
Adapted from Tchak's code here https://gist.github.com/4511824 | |
//Passing a function instead of route name will setup an anonymous route and assign the function as `redirect` hook. | |
//Passing object instead of route name can be used to redirect for example. | |
App.Router.map(function { | |
this.resource('index', { path: '/'}, function() { | |
if (this.controllerFor('login').get('isSignedIn')) { | |
this.transitionTo('search'); | |
} else { | |
this.transitionTo('signIn'); |