Skip to content

Instantly share code, notes, and snippets.

@Bredoxon
Bredoxon / aws_autoscaling_cron.rb
Created September 2, 2020 02:50 — forked from kixorz/aws_autoscaling_cron.rb
Running cron jobs in AWS Auto Scaling group is tricky. When you deploy the same code and configuration to all instances in the group, cron job would run on all of them. You may not want that. This script detects the first instance in the group and allows only this instance to run the job. IAM user used by this script needs to have permissions to…
#!/usr/bin/env ruby
require 'syslog'
require 'net/http'
require 'aws-sdk'
Syslog.open
AWS.config({
:access_key_id => '<iam user key>',
:secret_access_key => '<iam user secret>'
@Bredoxon
Bredoxon / haproxy-config-2-0.cfg
Created June 9, 2020 05:21 — forked from haproxytechblog/haproxy-config-2-0.cfg
HAProxy 2.0 configuration
#
# This is the ultimate HAProxy 2.0 "Getting Started" config
# It demonstrates many of the features available which are now available
# While you may not need all of these things, this can serve
# as a reference for your own configurations.
#
# Have questions? Check out our community Slack:
# https://slack.haproxy.org/
#
@Bredoxon
Bredoxon / bases_controller.rb
Created July 3, 2013 01:17
migrate nomination PDFs to Infringement::UploadedDocument model
Infringement::Offence::Base.nominated.each do |o|
filename = "/home/fpaterno/development/galleon/public/infringements/nomination-#{o.id}.pdf"
if o.nomination.blank? && File.exists?(filename)
o.documents << Infringement::UploadedDocument.new do |d|
d.document = File.open filename
d.document_type = 'Nomination'
end
FileUtils.rm_f(filename) if o.save
end
end