Skip to content

Instantly share code, notes, and snippets.

View richardjortega's full-sized avatar

Richard Ortega richardjortega

View GitHub Profile
@richardjortega
richardjortega / gist:1832638
Created February 15, 2012 02:25 — forked from panicsteve/gist:1641705
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', :version => 2, :all_after_pass => false, :cli => '--drb' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^spec/.+_spec\.rb$})
module SubscriptionStatus
Trialing = 'trialing'
Active = 'active'
Past_due = 'past_due'
Canceled = 'canceled'
Unpaid = 'unpaid'
end
@richardjortega
richardjortega / hooks_controller.rb
Created June 5, 2012 16:03
webhooks_controller_stripe
class HooksController < ApplicationController
protect_from_forgery :except => :receiver
require 'json'
require 'stripe'
#Hooks can only be used with a live URL
# Recommended testing options:
## pagekite.me - free trial
@richardjortega
richardjortega / index.html.erb
Created October 19, 2012 21:26
Payment page
<!-- to display errors returned by createToken -->
<span class="payment-errors"></span>
<%= form_for @subscription, :html => { :class => 'payment-form', :id => 'payment-form' } do |f| %>
<%= f.hidden_field :stripe_card_token %>
<%= f.hidden_field :last_four %>
<noscript>
<p>This form requires Javascript to use</p>
@richardjortega
richardjortega / assocation.rb
Created March 13, 2013 18:26
testing multiple models through same has_many :through assocation
## I need to have a Group that can consist of Users and/or Companies
class User
has_many :relationships
has_many :companies, :through => :relationships
end
class Relationships
belongs_to :user
belongs_to :company
require_relative "../marketinglist/upload_csv_to_db.rb"
## You would run this with: $ rake myrakes:upload_blast_list
namespace :myrakes do
desc "Uploads a given CSV file to ActiveRecord table: Blast"
task :upload_blast_list => :environment do
#Uncomment blast to delete all prior data
puts "Dropping data from Blasts table"
Blast.delete_all
@richardjortega
richardjortega / redis_install.sh
Created June 6, 2013 03:28
Super easy REDIS install with brew
# install Redis on Mac OS X
$ brew update
$ brew install redis
# Caveats
# To have launchd start redis at login:
# ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
# Then to load redis now:
# launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
@richardjortega
richardjortega / currency.php
Last active August 29, 2015 13:57
currency phpeople challenge
<?php
require('/Users/richardjortega/.composer/vendor/autoload.php');
echo "Enter the amount in US dollars: $";
$money = read_stdin();
echo "What currency do you want to convert to? (E)uros, (P)esos, (B)ritish Pounds: ";
$currency = strtoupper(read_stdin());