Skip to content

Instantly share code, notes, and snippets.

View mattscilipoti's full-sized avatar

Matt Scilipoti mattscilipoti

View GitHub Profile
#!/usr/bin/env ruby
# Used to convert json from MixPanel into csv
# see: https://stackoverflow.com/questions/7845015/convert-json-to-csv-in-ruby
# and: https://stackoverflow.com/questions/273262/best-practices-with-stdin-in-ruby
class MixPanelJsonToCsv
require 'csv'
require 'optparse'
attr_reader :config
@mattscilipoti
mattscilipoti / GeometrySpecRunner.html
Created November 7, 2014 17:09
Using Jasmine from jasmine-node OR html (interchangeably)
<!DOCTYPE html>
<html>
<head>
<title>geometry specs</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/jasmine.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/jasmine.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/boot.js"></script>
@mattscilipoti
mattscilipoti / rspec_cheat_sheet.rd
Last active August 29, 2015 14:26 — forked from byplayer/rspec_cheat_sheet.rd
rspec cheat sheet
INSTALL
=======
$ gem install rspec
RSPEC-RAILS
===========
RAILS-3
=======
@mattscilipoti
mattscilipoti / README
Created June 24, 2009 14:45
cucumber setup
Run all features:
`cucumber`
Run cucumber using selenium:
`cucumber -p selenium features`
TODO: we may be able to clean up the file locations using --exclude in the profiles
#usage: Incident.new.should delegate(:batch_code, :to => :incident_batch)
Spec::Matchers.define :delegate do |method_name, options|
match do |delegator|
associated_receiver = options[:to]
expected_value = 'TEST'
receiver = Spec::Mocks::Mock.new(associated_receiver, method_name => expected_value)
##retrieval
delegator.stub!(associated_receiver => receiver)
delegator.send(method_name) == expected_value
@mattscilipoti
mattscilipoti / crontab
Created August 18, 2009 14:09
script/runner and crontab
MAILTO=me@example.com
TIPS_ROOT=/home/user_name/projects/project1
# m h dom mon dow command
*/1 * * * * $TIPS_ROOT/script/local_runner.sh script/ping_em_all.rb log/ping.log
require 'rubygems'
require 'wirble'
#require 'utility_belt' #didn't play well with others, try again later.
require 'hirb' #nice console formatting
Wirble.init
Wirble.colorize
Hirb.enable
puts "`include RailsHelper` for named_urls, helpers, etc."
Transform /^table:.*$/ do |table|
#convert empty strings to nil (reverses #470)
table.hashes.each do |hash|
hash.each do |key, value|
hash[key] = value.empty? ? nil : value
end
end
table
end
@mattscilipoti
mattscilipoti / irb_rails_helper.rb
Created October 27, 2009 14:40
.irbrc RailsHelper
puts "`include RailsHelper` for named_urls, helpers, etc."
module RailsHelper
def self.included(base)
##from: http://kpumuk.info/ruby-on-rails/memo-6-using-named-routes-and-url_for-outside-the-controller-in-ruby-on-rails/
## this is slow because all routes and resources being calculated now
base.send('include', ActionController::UrlWriter)
base.default_url_options[:host] = 'www.example.com'
DatabaseCleaner.strategy = :truncation, {:except => SeedData.seed_tables}
puts "You can now utilize named_urls & DatabaseCleaner.clean"
#When I edit Jurisdiction/Location:L1
When /^I edit (.*)(?:\/)(.+):(.+)$/ do |requested_parent_model, requested_model, default_identifier|