Skip to content

Instantly share code, notes, and snippets.

View cgrusden's full-sized avatar

Corey G cgrusden

  • Ruby on Rails, iOS, Consulting
  • 100% Remote
View GitHub Profile
@cgrusden
cgrusden / forms_generator.rb
Created January 24, 2014 07:01
Generate forms that have Stripe inputs along with any other inputs on the page.. Example: You have an account sign up page: rails g forms:stripe account username:string name:string email:string password:string
module Stripe
class FormsGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
argument :forms_name, :type => :string, :default => "stripe_form"
desc "Generate Stripe.com enabled forms"
def create_stripe_form_js_coffeescript
create_file "app/assets/javascripts/#{forms_name}.js.coffee", <<-FILE
Stripe.setPublishableKey('YOUR_PUBLISHABLE_KEY');
@cgrusden
cgrusden / move_migration.rb
Created January 21, 2014 15:59
Move a migration before another $ move_migration <some_migration> <some_migration_i_want_the_first_argument_of_this_to_be_before>
#!/usr/bin/ruby
require 'date'
## usage: move_migration <migration_that_you_want_to_move> <migration_you_want_to_move_right_before>
migration_to_move = ARGV[0]
migration_to_prepend = ARGV[1]
puts <<HERE
Moving #{migration_to_move}
@cgrusden
cgrusden / links_to_text.js
Created November 11, 2013 19:55
Turn all links on Craiglist into copyable-text
@cgrusden
cgrusden / find_sat_and_sun.rb
Created October 1, 2013 15:59
Finding date of this past Sunday & this coming up Saturday, given I'm in the middle of the current week
sunday = (Date.today - Date.today.wday)
saturday = Date.today + (DateTime::DAYNAMES.index("Saturday") - Date.today.wday)
puts sunday.to_s
puts saturday.to_s
@cgrusden
cgrusden / base_template.rb
Last active December 18, 2015 11:48
Steven H. Allen & Co.'s (http://stevenhallen.com) rails template
# Steven H. Allen & Co. (http://stevenhallen.com)
#
# NOTICE: This template uses Postgresql exclusively for now
#
#
# To use this template:
#
# $ rails new <rails_app_name> -m https://gist.github.com/5777772.txt -S -T -d postgresql
@cgrusden
cgrusden / gist:5732520
Created June 7, 2013 21:25
Simple DATE_PART example
SELECT DATE_PART('DOW', created_at), COUNT(*) FROM stores GROUP BY DATE_PART('DOW', created_at);
@cgrusden
cgrusden / include_js.haml
Last active December 16, 2015 21:29
Hamlized Strip payment form
%script{:src => "https://js.stripe.com/v2/", :type => "text/javascript"}
:javascript
Stripe.setPublishableKey('<your publishable key>');
@cgrusden
cgrusden / jay_leno_post.md
Last active December 14, 2015 18:09
Jay Leno's quote that triggered a facebook post that trigged a short blog post

While you're at SxSW, we'll be working hard to get your customers - whomever they are.

With South By Southwest (SxSW 2013) starting today, it reminded me of something Jay Leno of 'The Tonight Show' said, "When my competition is sleeping, partying, or relaxing, I'm working harder to surpass them" (or, something very close to that).

All I'm saying is: Your customers are the same customers I am pursing. My customers aren't at SxSW.

@cgrusden
cgrusden / cgrusden.txt
Created November 5, 2012 18:33
How do you estimate your User Stories?
In a group of 10 developers, we sit on a Google Hangout and read each User Story in Pivotal, then do paper-rock-scissors on the count of 3 and show how many fingers the story should be estimated. We use the estimate that most people have "thrown".
@cgrusden
cgrusden / index.html
Created September 27, 2012 18:55
Save data when a form posts
<script>
$(document).ready(function() {
$('form:first').bind('submit', function() {
search = $(this).find('.input_text').val();
$.get(['https://serveletserve.herokuapp.com/PUBLIC_API_TOKEN_1234/track/twitter/cgrusden/searched_for', search].join("/"));
});
});
</script>
<html>