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 / 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 / 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 / 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 / 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 / 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 / links_to_text.js
Created November 11, 2013 19:55
Turn all links on Craiglist into copyable-text
@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 / 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 / ajaxUpload.js
Created August 1, 2014 01:38
Ajax File Upload
$('input#headshot').on('change', (event) ->
jQuery.active++
files = event.target.files
formData = new FormData()
for file in files
formData.append('images[]', file, file.name)
xhr = new XMLHttpRequest()
xhr.open('POST', $(this).closest('form').attr('action'), true)
@cgrusden
cgrusden / creed.txt
Last active August 29, 2015 14:05
Hunter S. Thompson
“My main luxury in those years-a necessary luxury, in fact-was the ability to work in and out of my home-base fortress in Woody
Creek.It was a very important psychic anchor for me, a crucial grounding point where I always knew I had love, friends, & good
neighbors.It was like my personal Lighthouse that I could see from anywhere in the world-no matter where I was, or how weird &
crazy & dangerous it got, everything would be okay if I could just make it home.When I made that hairpin turn up the hill onto
Woody Creek Road, I knew I was safe.”