Skip to content

Instantly share code, notes, and snippets.

@endymion
endymion / contact.rb
Last active February 18, 2024 22:49
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
mime_message = DATA.read
puts "To line before: "
puts ' ' + mime_message.match(/^(To\:.*)$/i)[1]
# Massage the To: line.
changed_to = 'CHANGED@example.com'
mime_message.gsub!(/^To\:.*$/i, "To: #{changed_to}")
puts "To line after: "
@endymion
endymion / gist:a5381dad4987c69bda9ec2141bf2b960
Last active May 23, 2021 12:04
Attempting to install the AWS SAM CLI on a Gravitron2-based EC2 M6g Amazon Linux 2 instance using PIP.
[ec2-user@ip-172-31-40-220 ~]$ pip3 install --user aws-sam-cli
Collecting aws-sam-cli
Downloading https://files.pythonhosted.org/packages/6d/f7/77aaa4d128dd5b9cc443b852f924cbe155cac7bb0ce191c2ac34d7c4d794/aws_sam_cli-1.23.0-py3-none-any.whl (3.8MB)
100% |████████████████████████████████| 3.8MB 383kB/s
Collecting requests==2.23.0 (from aws-sam-cli)
Downloading https://files.pythonhosted.org/packages/1a/70/1935c770cb3be6e3a8b78ced23d7e0f3b187f5cbfab4749523ed65d7c9b1/requests-2.23.0-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 12.8MB/s
Collecting Flask~=1.1.2 (from aws-sam-cli)
Downloading https://files.pythonhosted.org/packages/e8/6d/994208daa354f68fd89a34a8bafbeaab26fda84e7af1e35bdaed02b667e6/Flask-1.1.4-py2.py3-none-any.whl (94kB)
100% |████████████████████████████████| 102kB 13.3MB/s
@endymion
endymion / gist:53d5dec9ede03f4265ed739c9471f024
Created January 4, 2021 23:04
A list of AWS Lambda layers that Yumbda can create for you.
Last login: Mon Jan 4 17:54:28 on ttys005
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ryan-13:~ work$ docker run --rm lambci/yumda:2 yum list available
Unable to find image 'lambci/yumda:2' locally
2: Pulling from lambci/yumda
a3f8e652bdc4: Pull complete
b952bd002b0a: Pull complete
@endymion
endymion / wait_until.rb
Created March 9, 2012 17:59 — forked from metaskills/wait_until.rb
Never sleep() using Capybara!
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
click_link 'My HomeMarks'
within '#login_area' do
fill_in 'email', with: 'will@not.work'
fill_in 'password', with: 'test'
@endymion
endymion / exam.md
Last active August 2, 2019 16:00
Cloud Fu Exam Lab

Cloud Fu Exam Lab

This lab demonstrate aptitude with:

  • Unix
  • Git
  • virtualization
  • Vagrant

...and touches a bit on Ruby.

@endymion
endymion / gist:7dc56dd017339164841121c69657350c
Created January 5, 2018 20:02
The post body is not available to the Lambda function.
$ curl -v -X POST 'https://8cjjw9ynlb.execute-api.us-east-1.amazonaws.com/Prod' -H 'content-type: application/json' -d '{"callerName": "John"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 52.85.109.19...
* TCP_NODELAY set
* Connected to 8cjjw9ynlb.execute-api.us-east-1.amazonaws.com (52.85.109.19) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
@endymion
endymion / gist:f788fb06d8f9e68108ae9c52314afb97
Created April 24, 2017 15:59
'next upcoming event' Marketo template code
<h2>Custom Objects</h2>
<table>
<tr>
<th>#</th>
<th>date</th>
</tr>
#foreach($object in $openTableReservation_cList)
    <tr>
<td>$foreach.count</td>
<td>
@endymion
endymion / gist:73f026518256d19f4e77250167562ae4
Created February 23, 2017 22:15
The birth of Screen Driver.
ryan-15:projects rap$ curl https://install.meteor.com/ | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7786 0 7786 0 0 16883 0 --:--:-- --:--:-- --:--:-- 16852
Downloading Meteor distribution
######################################################################## 100.0%
Meteor 1.4.3.1 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
@endymion
endymion / gist:8588110
Created January 23, 2014 22:28
Somebody probed a staging server, the moment that I mapped a DNS name to it.
Processing ApplicationController#index (for 93.174.93.17 at 2014-01-23 22:04:45) [GET]
ActionController::RoutingError (No route matches "/cgi-bin/php" with {:method=>:get}):
sass (3.1.21) rails/./lib/sass/plugin/rack.rb:54:in `call'
sass (3.1.21) rails/./lib/sass/plugin/rack.rb:54:in `call'
/data/venuedriver/shared/bundled_gems/ruby/1.8/gems/newrelic_rpm-3.6.2.96/lib/new_relic/rack/agent_hooks.rb:18:in `call'
/data/venuedriver/shared/bundled_gems/ruby/1.8/gems/newrelic_rpm-3.6.2.96/lib/new_relic/rack/browser_monitoring.rb:16:in `call'
/usr/libexec/passenger/lib/phusion_passenger/rack/request_handler.rb:97:in `process_request'
/usr/libexec/passenger/lib/phusion_passenger/abstract_request_handler.rb:520:in `accept_and_process_next_request'