Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'aws-sdk'
# initialize S3 client
s3_client = Aws::S3::Client.new(region: 'us-east-1')
# initialize KMS client
kms_client = Aws::KMS::Client.new(region: 'us-east-1')
@boy-jer
boy-jer / contact.rb
Created March 21, 2021 23:03 — 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.
class Contact < ActiveRecord::Base
...
def after_create
if Hook.hooks_exist?('new_contact', self)
Resque.enqueue(Hook, self.class.name, self.id)
# To trigger directly without Resque: Hook.trigger('new_contact', self)
end
end
@boy-jer
boy-jer / Rails Console Actionmailer test.rb
Created November 20, 2016 00:57 — forked from benoror/Rails Console Actionmailer test.rb
Rails Console Actionmailer test
# 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 = "[email protected]"
@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=\"http://blog.nimbo-x.com/nimbo-x-gold/\">test link</a>."
@boy-jer
boy-jer / url_regex.rb
Last active October 24, 2015 09:47 — forked from ryana/url_regex.rb
@gruber's improved regex for matching URLs written in Ruby
# From @gruber http://daringfireball.net/2010/07/improved_regex_for_matching_urls
#http://ryanangilly.com/post/8654404046/grubers-improved-regex-for-matching-urls-written
UrlRegex = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/?)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s\`!()\[\]{};:\'\".,<>?«»“”‘’]))/i
@boy-jer
boy-jer / Gemfile
Created October 11, 2015 19:28 — forked from mchail/Gemfile
Zapier Webhooks in Rails with Resque
gem "resque", :require => 'resque/server'
gem 'resque-history'
@boy-jer
boy-jer / multi-parameter_attributes_spec.rb
Created December 4, 2013 10:59 — forked from k-rudy/multi-parameter_attributes_spec.rb
Multiparameter Attributes support in Mongoid 4 (Rails 4.0.1) Code is taken from https://github.com/mongoid/mongoid/issues/2954 with minor amendments to work with Rails 4.0.1
# This class is needed since Mongoid doesn't support Multi-parameter
# attributes in version 4.0 before it's moved to active model in rails 4
#
# https://github.com/mongoid/mongoid/issues/2954
#
require "spec_helper"
require 'mongoid/multi_parameter_attributes'
describe Mongoid::MultiParameterAttributes do
@boy-jer
boy-jer / animations-router-stuff.coffee
Created July 18, 2013 09:39 — forked from ebryn/animations-router-stuff.coffee
animations in emberjs router
App.Router.map ->
@route "a"
@route "b"
@route "ab"
@route "ba"
App.ARoute = Em.Route.extend
events:
animateToB: ->
@transitionTo('ab')
@boy-jer
boy-jer / S3Upload.js
Created July 18, 2013 09:37 — forked from raytiley/S3Upload.js
This class uploads to an S3 bucket. And was adapted from this blog post: http://www.ioncannon.net/programming/1539/direct-browser-uploading-amazon-s3-cors-fileapi-xhr2-and-signed-puts/ You need to have an endpoint on your server that will sign your S3 request for you ('covered in the plog post'). To use: App.S3Upload.create({ file: file-from-fil…
App.S3Upload = Ember.Object.extend({
progress: 0,
state: "pending",
bucket: 'your-bucket'
complete: false,
s3url: null,
xhr: null,
file: null,
fileName: function() {
var file = this.get('file');
#!/usr/bin/env ruby
require 'curb'
require 'yaml'
hosts = %w(
example.com
google.com
)

Using Yo Ember instead of Ember-Rails

First Generate Ember application using Yo Ember generator

  1. Install yeoman npm install -g yo grunt-cli bower
  2. Install ember-generator npm install -g generator-ember
  3. Create your project mkdir webapp && cd webapp
  4. Generate ember template yo ember
  5. Run itgrunt server