Skip to content

Instantly share code, notes, and snippets.

@pete2786
pete2786 / capybara cheat sheet
Created October 16, 2012 00:54 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
public class Filewalker {
public void walk( String path ) {
File root = new File( path );
File[] list = root.listFiles();
if (list == null) return;
for ( File f : list ) {
@pete2786
pete2786 / warmup_email_provider.rb
Created August 22, 2014 14:36
Module can included in a mailer to help warmup a new email provider on a static IP. This code was written for a transition from sendgrid to mailgun for a mailer which handled about 200k emails/day. The constants are set to transition from 100k/day to 3m/day with a 25% daily increase.
module mail_provider_warmup
DAILY_INCREASE_RATE = 1.25 # 25%
INITIAL_MAIL_VOLUME = 100000
FINAL_MAIL_TARGET = 3000000.0
WARMUP_START_DATE = Date.new(2014,7,24)
PROVIDER_FROM = :sendgrid
PROVIDER_TO = :mailgun
#selected_provider = self.class.select_provider(rand)
def self.select_provider(random)
@pete2786
pete2786 / project_comment.rb
Last active May 30, 2016 08:38
Slack Notifiable and Example
class ProjectComment < ActiveRecord::Base
include SlackNotifiable
belongs_to :user
belongs_to :project
has_one :organization, through: :project
def slack_message
"#{user.name} has commented on #{project.title}: #{description}"
end
@pete2786
pete2786 / gist:741ee77da13ea57a48c1
Created November 12, 2015 17:56
75kb of Hello, World!
Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! He