Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
require 'minitest_helper'
ADDRESSES = {
toledo_ohio: {
street1: '',
city: 'Toledo',
state: '',
zip: '',
country: 'United States',
expected_obfuscated_street: '',
if Rails.env.production?
Braintree::Configuration.environment = Rails.env.staging? ? :sandbox : :production
Braintree::Configuration.merchant_id = ENV["braintree_merchant_id"]
Braintree::Configuration.public_key = ENV["braintree_public_key"]
Braintree::Configuration.private_key = ENV["braintree_private_key"]
else
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.merchant_id = "<super secret>"
Braintree::Configuration.public_key = "<super secret>"
Braintree::Configuration.private_key = "<super secret>"
@bsodmike
bsodmike / python_install.sh
Last active December 16, 2015 18:29 — forked from munhitsu/gist:1034876
python 2.7 install on Mac OS X 10.8 Mountain Lion using brew (pip, easy_install, virtualenv, virtualenvwrapper)
brew install python --framework
easy_install pip
pip install virtualenv
pip install virtualenvwrapper
mkdir $HOME/.virtualenvs
# homebrew python 2.7
echo 'export PATH="/usr/local/share/python:$PATH"' >> ~/.zshrc
#virtualenv wrapper
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
require 'capybara/rails'
class MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
@bsodmike
bsodmike / redis.markdown
Created November 4, 2012 18:43 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@bsodmike
bsodmike / config.ru
Created November 1, 2012 10:29 — forked from rizwanreza/config.ru
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
require "rails"
# Let's load only action controller. If you want
# to use active record, just require it as well.
require "action_controller/railtie"
class MyApp < Rails::Application
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@bsodmike
bsodmike / anonymous_user.rb
Created October 12, 2012 18:26 — forked from zacstewart/anonymous_user.rb
Rails Soft Sign-Up
class AnonymousUser < User
attr_accessible *ACCESSIBLE_ATTRS, :type, :token, as: :registrant
def register(params)
params = params.merge(type: 'User', token: nil)
self.update_attributes(params, as: :registrant)
end
end
@bsodmike
bsodmike / Gemfile
Created September 21, 2012 20:03 — forked from croaky/Gemfile
Getting a CouchDB app running on Rails 3 as of September, 2010
gem 'couchrest_extended_document'
@bsodmike
bsodmike / active_record_associations.rb
Created September 20, 2012 21:56 — forked from karmi/active_record_associations.rb
An example of elasticsearch & Tire setup for ActiveRecord associations
# An example of elasticsearch & Tire setup for ActiveRecord associations.
#
# A `Book has_many :chapters` scenario, with mapping and JSON serialization
# for indexing associated models.
#
# Demonstrates three important caveats as of now:
#
# 1. You you have to use `touch: true` in the `belongs_to` declaration,
# to automatically notify the parent model about the update.
#