per https://twitter.com/searls/status/1559543920673144834 -> https://blog.testdouble.com/posts/2022-08-15-migrating-postgres-extensions-to-the-heroku_ext_schema/
View download_all_lambda_functions.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: | |
# ./download_all.sh | |
# ./download_all.sh download us-east-1 my-function | |
# ./download_all.sh help | |
# | |
# Downloads all aws-lambda functions to a subdirectory | |
# Assumes you have a role that has at least read access to lambda. | |
# Credits to https://gist.github.com/nemani/defdde356b6678352bcd4af69b7fe529 |
View migrate-sidekiq-redis.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A script to migrate Sidekiq's redis to a new server. | |
# This obviously can work for any redis, but I only handled | |
# data types that Sidekiq uses. | |
require 'redis' | |
old_redis = Redis.new url: 'redis://old-redis:6379' | |
new_redis = Redis.new url: 'redis://new-redis:6379' | |
unknowns = [] |
View README.md
on CI and local
export RUBYOPT="-W:deprecated" # show warnings, deprecations only
View db-switch.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require(Dir.pwd + "/config/environment") | |
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| | |
ActiveRecord::Base.establish_connection(db_config.config) | |
context = ActiveRecord::Base.connection.migration_context | |
missing_migrations = [] |
View db.rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_record" | |
databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml | |
db_namespace = namespace :db do | |
if Rails.version.start_with?("6.0") | |
# https://github.com/rails/rails/pull/38770/files | |
namespace :rollback do | |
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name| |
View dump_memcache.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# List all keys stored in memcache. | |
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place. | |
require 'net/telnet' | |
require 'csv' | |
headings = %w(id expires bytes key) | |
rows = [] |
View live_database_dump.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatabaseController < ApplicationController | |
def database_dump | |
database = Rails.configuration.database_configuration[Rails.env]["database"] | |
send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup") | |
pipe = IO.popen("pg_dump '#{database}' -F c") | |
stream = response.stream | |
while (line = pipe.read(1024)) # per https://gist.github.com/njakobsen/6257887#gistcomment-1238467 | |
stream.write line | |
Thread.pass # per https://gist.github.com/njakobsen/6257887#gistcomment-1235792 |
View clock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Created by Benjamin Fleischer 2019 | |
# Distributed under the MIT license | |
# | |
# Usage: | |
# MINUTE_RANGES="0...10 30...40" ./clock echo 'we done it' | |
# DEBUG=true MINUTE_RANGES="0...10 30...40" ./clock echo 'we done it' | |
main() { | |
local ranges |
View jdbc_sample.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './lib/adsjdbc-10.10.0.28.jar' | |
java_import java.sql.Driver | |
java_import java.sql.DriverManager | |
java_import 'com.extendedsystems.jdbc.advantage.ADSDriver' | |
class AdsAdapter | |
def initialize(connect_string) | |
@connect_string = connect_string | |
end |
NewerOlder