Skip to content

Instantly share code, notes, and snippets.

View beneggett's full-sized avatar

Ben Eggett beneggett

View GitHub Profile
15.times do
u = FactoryGirl.create(:user)
pic = Picture.create image: File.open(Dir["/Users/ben/Pictures/Stock\ Photos/people/*.jpg"].sample)
u.picture = pic
Random.rand(6).times do
u.tags.create FactoryGirl.attributes_for(:tag)
end
Random.rand(10).times do
p = u.projects.create FactoryGirl.attributes_for(:project)
(1 + Random.rand(6)).times do
@beneggett
beneggett / file-uploads.md
Last active December 27, 2015 00:49
File Uploads / Polymorphic Associations Lab

File Uploads / Polymorphic Associations Lab

High level Instructions

  • Add images to your projects & users model using the Paperclip Gem

  • Implement Paperclip by one of three methods: Directly on Model, Through an associated model (Gallery Images), or through polymorphic associations across multiple models.

Polymorphic Associations references:

@beneggett
beneggett / instructions.md
Last active December 26, 2015 09:19
MiniTest Instructions

Install needed Gems

Gemfile

group :development do
  gem 'powder'
  gem 'pry-rails'
  gem 'better_errors'
  gem 'binding_of_caller'
 gem 'meta_request'
@beneggett
beneggett / contact-form-seo.md
Created October 18, 2013 21:59
Creating a Contact Form, Mailer

Creating a Contact Form & Mailer

Create a working contact form in your application that will allow a user to send you an email. At a minimum should have a sender email, subject, and body as part of the form. It should have validations that make sure that required fields are submitted & email address is properly formatted. The messages should not be ultimately stored in the database, you can choose how to implement that (Non-active record model vs destroying entries after create)/

Instructions

  • Create a message model
  • Create a contact us controller with new & create actions & associated views
  • Create a mailer & associated views (use layout if you have one)
  • Hook the mailer up to the create action in your contact us controller
@beneggett
beneggett / gist:7016378
Last active December 25, 2015 17:49
Email Basics
Configure your email settings:
In config/environments/development.rb:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'localhost:3000',
user_name: ENV['GMAIL_EMAIL'],
password: ENV['GMAIL_PASSWORD'],
authentication: 'plain',
@beneggett
beneggett / savvi-membership-api.md
Last active December 25, 2015 05:38
Savvi Wholesale Partners API

Savvi Membership API for Wholesale Partners

This guide covers the inner working of Savvi's RESTful API. It assumes a basic understanding of the principles of REST.

The REST API is designed to give developers a convenient way to access data contained within Savvi. As Savvi continues to grow, the API will continue to be developed.

Making an API Call

Savvi provides a staging and production URL for creating users.

Staging URL: http://www.savvi-staging.com/api/v1/

@beneggett
beneggett / savvi-user-payment-integration-api.md
Created October 10, 2013 15:29
Savvi User & Payment Integration API for Call Centers

Savvi User & Payment Integration API for Call Centers

This guide covers the inner working of Braintree's Payment API & Savvi's RESTful API. It assumes a basic understanding of the principles of REST.

There are two steps that need to happen in order to successfully enroll a Savvi member:

1.) Create an customer with a credit card & billing address with Braintree

2.) Post the user's information to Savvi including the newly created Braintree token via the "Creating Call Center Members via API" method.

@beneggett
beneggett / .powenv
Last active February 17, 2017 22:55
.powenv
# detect `$rvm_path`
if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
then rvm_path="${HOME:-}/.rvm"
fi
if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
then rvm_path="/usr/local/rvm"
fi
# load environment of current project ruby
if
@beneggett
beneggett / ruby-encryptor-exercise.md
Created September 24, 2013 22:26
Ruby Encryptor Exercise

Encryptor

Have you ever wanted to send a secret message?

The Plan

Today we use computers to mask messages every day. When you connect to a website that uses "https" in the address, it is running a special encoding on your transmissions that makes it very difficult for anyone to listen in between you and the server.

Ruby in 100 Minutes

About Ruby

Ruby was written to make the programmer's job easy and not care if the computer's job is hard. In this brief introduction we'll look at the key language features you need to get started.

Key Language features

  1. Instructions and Interpreters