View omitting.rb
gem "activerecord", "~> 4.0.0"
require "active_record"
## Implementation
module ActiveRecord::OmitMethods
# Inverse of #merge, negates and merges the conditions from <tt>other</tt>, if <tt>other</tt> is an <tt>ActiveRecord::Relation</tt>.
# Returns an array representing the subset of the resulting records not appearing in <tt>other</tt>, if <tt>other</tt> is an array.
# Post.where(published: true).joins(:comments).omit( Comment.where(spam: false) )
View enumerator-rate_limiting.rb
require "thread"
# Simple thread safe rate limiter
#
# Supply a limit of operations, and an interval in seconds (defaults to 1
# second, so ops/sec).
#
# Call `#wait` on every operation which will return immediately or sleep until
# the rate limit is satified.
#
View retry.sh
# Retry a command up to a specific numer of times until it exits successfully,
# with exponential back off.
#
# $ retry 5 echo Hello
# Hello
#
# $ retry 5 false
# Retry 1/5 exited 1, retrying in 1 seconds...
# Retry 2/5 exited 1, retrying in 2 seconds...
# Retry 3/5 exited 1, retrying in 4 seconds...
View papertrail-to-s3.rb
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]"
View config-initializers-siginfo.rb
# 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
View buildkite-agent.service
[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
View main.go
package main
import _ "github.com/ErikDubbelboer/gspt"
func main() {
}
View Gemfile
source "https://rubygems.org"
gem "unicode-display_width"
View mailcatcher-rvm-test.sh
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 \
View a.rb
#!/usr/bin/env ruby -I.
class A
end
class A::B
end
class B
end