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
def query(conn, sql, timeout_ms:) | |
conn.send_query(sql) | |
if conn.block(timeout_ms / 1000.0) # seconds | |
conn.get_last_result | |
else | |
conn.cancel | |
conn.get_last_result | |
end | |
end |
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 'concurrent' | |
module ActiveSupport | |
module Cache | |
class AsyncWriteStore < SimpleDelegator | |
def self.supports_cache_versioning? | |
true | |
end | |
def initialize(klass_or_sym, *args) |
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
# config/initializers/umbra.rb | |
require 'umbra' | |
Umbra.configure do |config| | |
config.redis_options = { url: ENV['REDISCLOUD_URL'] } # connect to our redis instance | |
config.error_handler = proc { |e| Bugsnag.notify(e) } # notify our error tracker | |
config.request_selector = proc { |env, _resp| env['REQUEST_METHOD'] == 'GET' } # only replicate GET requests | |
config.logger = Rails.logger | |
end |
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 | |
set -eu | |
# Finds the heroku slug id from the compile apps latests releases | |
# via the commit SHA | |
function heroku_slug () { | |
heroku releases --app ${1} --json | \ | |
jq -rc --arg commit "${2}" \ | |
'.[] |
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 'bugsnag/api' | |
BUGSNAG_PERSONAL_TOKEN = ENV.fetch('BUGSNAG_PERSONAL_TOKEN') | |
URL_REGEX = /https:\/\/app.bugsnag.com\/carwow\/(?<project_slug>.*)\/errors\/(?<error_id>[a-zA-Z0-9]+)(\?.*)?/ | |
PROJECTS = { | |
'project_slug' => 'bugsnag_project_id' | |
} |
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 BackfillJob < ApplicationJob | |
queue_as :backfill | |
def perform(file_num:, max_file_num:, batch_size: 500) | |
fetch_from_s3(file_num).each_slice(batch_size) do |ids| | |
FactoryOrderQuote.where(id: ids).update_all(status: :not_renewable) | |
end | |
return if file_num >= max_file_num |
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 | |
set -eu | |
QUERY_FILE= | |
COUNTRY= | |
BUCKET= | |
OUTPUT=cars_${COUNTRY} | |
RAW_OUTPUT=${OUTPUT}.csv | |
SPLIT_DIR=${OUTPUT}_split |
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
WITH discontinued_derivatives AS ( | |
SELECT id | |
FROM research_site.derivatives | |
WHERE date_discontinued IS NOT NULL | |
AND date_discontinued < current_date | |
), | |
unavailable_models AS ( | |
SELECT slug | |
FROM research_site.models |
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 | |
set -u | |
# Do things... | |
tmux start-server | |
# Open tmux session for a project | |
function tmux_setup () { | |
local PROJECT=${1} | |
local PROJECT_DIR=${MORNING_PROJECTS_HOME}/${PROJECT} | |
cd ${PROJECT_DIR} |
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 'pathname' | |
# path to your application root. | |
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
Dir.chdir APP_ROOT do | |
test_env = 'test' | |
puts "Application Environment: #{test_env}" |
NewerOlder