Skip to content

Instantly share code, notes, and snippets.

View sj26's full-sized avatar
🤹‍♂️

Samuel Cochran sj26

🤹‍♂️
View GitHub Profile
@sj26
sj26 / LICENSE.md
Last active March 8, 2024 18:31
Bash retry function

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit

@sj26
sj26 / papertrail-to-s3.rb
Last active August 24, 2018 23:07 — forked from mujtaba3B/dl_papertrail_archives
Backup old papertrail archive to s3
require "active_support/all"
require "aws-sdk"
require "concurrent"
papertrail_token = "..."
s3 = Aws::S3::Client.new(region: "us-east-1")
s3_bucket = "..."
s3_prefix = "papertrail/logs/[account-id]"
@sj26
sj26 / config-initializers-siginfo.rb
Created September 28, 2016 04:15
Send a SIGINFO to a rails process, get a backtrace of every thread!
# Send a process a SIGINFO like `kill -INFO <pid>` and it will print the
# current backtrace of all threads.
Signal.trap(29) do
puts "Thread dump:"
Thread.list.each do |thread|
puts thread.inspect.indent(2)
puts thread.backtrace.join("\n").indent(4)
end
end
@sj26
sj26 / buildkite-agent.service
Created May 27, 2016 04:57
Starting multiple buildkite-agents per-machine with systemd
[Unit]
Description=Buildkite Agents
Documentation=https://buildkite.com/agent
Wants=buildkite-agent@1.service
Wants=buildkite-agent@2.service
# ...
[Service]
Type=oneshot
ExecStart=/bin/true
@sj26
sj26 / main.go
Created May 26, 2016 01:51
Reproduce buildkite/agent#288 for erikdubbelboer/gspt
package main
import _ "github.com/ErikDubbelboer/gspt"
func main() {
}
source "https://rubygems.org"
gem "unicode-display_width"
docker run -it ubuntu /bin/bash
apt-get update -y
apt-get install -y curl build-essential libgmp-dev libpq-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s 1.26.11 --ruby=2.3.0
source /etc/profile.d/rvm.sh
rvm use 2.3.0@gemset --create
gem install --no-rdoc --no-ri \
aasm:4.7.0 \
@sj26
sj26 / a.rb
Created December 16, 2015 09:55
#!/usr/bin/env ruby -I.
class A
end
class A::B
end
class B
end
require "rspec/autorun"
require "rspec/mocks"
require "active_support/all"
RSpec.describe "presence" do
specify { expect(spy).to be_present }
end
#
# Failures:
# By default, DalliStore doesn't deal with `raw` correctly when inside the
# LocalCache per-request middleware. The MemCacheClient fixes this already by
# adding another little module. Let's do the same.
#
# A PR has been lodged upstream:
#
# https://github.com/mperham/dalli/pull/481
#
# Once merged @sj26 will update dalli and remove this workaround.
if defined? ActiveSupport::Cache::DalliStore and Rails.cache.is_a? ActiveSupport::Cache::DalliStore