Skip to content

Instantly share code, notes, and snippets.

View put_env_to_s3
#!/usr/bin/env ruby
require 'aws-sdk'
# initialize S3 client
s3_client = 'us-east-1')
# initialize KMS client
kms_client = 'us-east-1')
boy-jer / contact.rb
Created Mar 21, 2021 — forked from endymion/contact.rb
Example of integrating a Ruby on Rails app with Zapier using the REST hooks pattern. With support for triggering the REST hooks from Resque background jobs.
View contact.rb
class Contact < ActiveRecord::Base
def after_create
if Hook.hooks_exist?('new_contact', self)
# To trigger directly without Resque: Hook.trigger('new_contact', self)
View Rails Console Actionmailer test.rb
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
set_tracking_headers 'test_campaign'
@recipients = ""
@from = "Equipo Nimbo X <hola@" + Rails.application.secrets.sparkpost_domain + ">"
@subject = "sparkpost email test with open & click tracking"
@body = "This is a test email. With a <a href=\"\">test link</a>."
View checkout.rb
require 'minitest/autorun'
require_relative 'checkout'
class TestCheckoutTest < Minitest::Test
def setup
@checkout ='strawberry')
View tac.rb
class Board
attr_reader :grid
def initialize(input_array_hash = {})
@grid = input_array_hash.fetch(:grid, board_default_grid)
def fetch_cell(x, y)
View tic
ruby ~/dev-gt/test/ttt/lib/ttt.rb
For example, a Tic Tac Toe program requires data structures for storing
the board and conditional logic for knowing whose turn it is or if someone has won.
You can use Enumerable#all? which returns true if the given block returns true for all the elements in the collection.
boy-jer / url_regex.rb
Last active Oct 24, 2015 — forked from ryana/url_regex.rb
@gruber's improved regex for matching URLs written in Ruby
View url_regex.rb
# From @gruber
UrlRegex = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/?)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s\`!()\[\]{};:\'\".,<>?«»“”‘’]))/i
boy-jer / Gemfile
Created Oct 11, 2015 — forked from mchail/Gemfile
Zapier Webhooks in Rails with Resque
View Gemfile
gem "resque", :require => 'resque/server'
gem 'resque-history'
boy-jer / search.rb
Last active Aug 29, 2015
Simple Model Search with Rails
View search.rb
class OffenceController < ApplicationController
def index
@offenses = []
@search =,params[:search])
if @search.conditions
@offenses =