Skip to content

Instantly share code, notes, and snippets.

@adammiribyan
adammiribyan / callback.erb
Created November 5, 2012 08:38 — forked from amfeng/callback.erb
Stripe OAuth Example -- Ruby
<!doctype html>
<head>
<title>Stripe OAuth Example</title>
</head>
<body>
<%= @access_token %>
</body>
</html>
@adammiribyan
adammiribyan / users_controller_spec.rb
Created October 8, 2012 01:05
Controller spec refactoring
context "#start_phone_call", :focus do
before :each do
@harry = FactoryGirl.create(:client, first_name: "Harry", stripe_customer_token: nil)
@arnold = FactoryGirl.create(:lawyer, first_name: "Arnold")
controller.stubs(:current_user).returns(@harry)
end
it "should redirect to payment info page unless client has already has it saved" do
get :start_phone_call, { id: @arnold.to_param, client_number: "6087004680" }
request.should redirect_to call_payment_path(@arnold.to_param)
jQuery ->
($ ".dots-switcher").each (index, list) -> new DotsSwitcher(list)
class DotsSwitcher
constructor: (container) ->
@container = ($ container);
@items = @container.find("li")
@count = @items.length
@makeDots()
jQuery ->
# Model
class window.LineItem extends Backbone.Model
url: -> if @id then "/line_items/#{@id}?" else "/line_items?appointment_id=#{parseInt(($ 'input#appointment_id').val())}"
clear: ->
@destroy()
@view.remove()
# Collection
en:
devise:
invitations:
send_instructions: 'An invitation email has been sent to %{email}.'
invitation_token_invalid: 'The invitation token provided is not valid!'
updated: 'Your password was set successfully. You are now signed in.'
no_invitations_remaining: "No invitations remaining"
mailer:
invitation_instructions:
subject: 'Invitation instructions'
@adammiribyan
adammiribyan / invitation.html.erb
Created June 11, 2011 17:14
Invitation instructions email
<p>Hello <%= @resource.email %>!</p>
<p>Someone has invited you to <%= root_url %>, you can accept it through the link below.</p>
<p><%= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %></p>
<p>If you don't want to accept the invitation, please ignore this email.<br />
Your account won't be created until you access the link above and set your password.</p>
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@adammiribyan
adammiribyan / application.html.erb
Created April 14, 2011 09:15
rails app template layout file
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title><%= yield :title %></title>
<%= stylesheet_link_tag "reset", "application" %>
<%= javascript_include_tag "jquery.min", "application", "rails" %>
<%= csrf_meta_tag %>
</head>
<body>
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
@adammiribyan
adammiribyan / started_in_last_scope.rb
Created April 2, 2011 01:45
Interesting ActiveRecord scope method
# find_created_in_last(7.months)
def self.find_started_in_last(time_span)
old_time = Date.today - time_span
all(:conditions => ["created_at > ?", old_time.to_s(:db)])
end