Example of a bare-minimum terraform script to setup an API Gateway endpoint that takes records and puts them into an SQS queue.
Start by creating the SQS queue.
resource "aws_sqs_queue" "queue" {
require "json" | |
require "rest-client" | |
require "honeybadger" | |
def command_parser(message) | |
case message | |
when /shirt/i | |
response = RestClient.post("https://#{ENV["PRINTFECTION_TOKEN"]}:@api.printfection.com/v2/orders", | |
JSON.dump({campaign_id: ENV["PRINTFECTION_SHIRT_CAMPAIGN"]}), | |
{content_type: :json, accept: :json}) |
#!/bin/bash | |
curl https://github.com/stympy.keys > /root/.ssh/authorized_keys |
Example of a bare-minimum terraform script to setup an API Gateway endpoint that takes records and puts them into an SQS queue.
Start by creating the SQS queue.
resource "aws_sqs_queue" "queue" {
class Heya::Broadcast < ApplicationRecord | |
FROM_FORMATS = [ | |
/\A\[email protected]\z/, | |
/\A.+ <\[email protected]>\z/ | |
] | |
validates_presence_of :subject, :body | |
validate :valid_from_format | |
def self.create_and_send(subject:, body:, users:, from: nil) |
# /etc/consul-template/conf.d/pgbouncer.conf | |
template { | |
source = "/etc/consul-template/templates/pgbouncer.ini.tmpl" | |
destination = "/etc/pgbouncer/pgbouncer.ini" | |
command = "service pgbouncer reload" | |
command_timeout = "60s" | |
backup = true | |
} |
service: hook-relay | |
provider: | |
name: aws | |
custom: | |
resources: | |
us-east-1: ${file(./resources/timestream.yml)} # The resources that should be created in just one region | |
resources: |
class ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
include ActivityLogger | |
end |
require "ipaddr" | |
require "resolv" | |
require "uri" | |
class UrlChecker | |
SCHEME_REGEX = Regexp.new(/\Ahttps?/) | |
HOST_REGEX = Regexp.new(/.+\..+/) | |
IPV4_REGEX = Regexp.new(/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/) | |
IPV6_REGEX = Regexp.new(/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/) | |
PRIVATE_RANGES = %w[127.0.0.0/8 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 100.64 |
#!/usr/bin/env ruby | |
root = "/tmp/intercom" | |
IntercomClient.conversations.all.each do |c| | |
puts c.id | |
FileUtils.mkdir_p(path = "#{root}/conversations/#{c.id.to_s.first(4)}") | |
File.open("#{path}/#{c.id}.json", "w") { |f| f.puts IntercomClient.conversations.find(id: c.id).to_json } | |
end |
# Drop this in config/initializers/active_record.rb | |
class ActiveRecord::ActiveRecordError | |
def initialize(message = nil) | |
if message.respond_to?(:gsub) | |
super(message.gsub(/dearmor\(.*\)/im, '[FILTERED]')) | |
else | |
super(message) | |
end | |
end | |
end |