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
# no maint page unless migrations are required | |
def conditionally_enable_maintenance_page | |
super if required_downtime_stack? | |
if c.migrate? | |
info "~> testing necessity for migrations & maintenance page" | |
if `cd #{c.release_path} && bundle exec rake db:migrate:status`.scan(/^\s*down/).size > 0 | |
info "~> migrations pending, maintenance page required" |
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
# include from an initializer | |
module HstoreAccessor | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def hstore_accessor(hstore_attribute, *keys) | |
Array(keys).flatten.each do |key| |
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/perl -l | |
# written in "hasty" perl, my apologies. | |
use Data::Dumper; | |
use strict; | |
use vars qw($p $m $n $d $k $h $l); | |
# excuse to abuse the schwartzian later on |
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/perl | |
use strict; | |
use integer; | |
sub dqtoint ($) { | |
my $dq = shift; | |
return unpack('N', pack('CCCC', split(/\./, $dq, 4))); | |
} |
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/perl | |
use strict; | |
use integer; | |
my %sizeprefix = (); | |
for my $i (0..32) { | |
$sizeprefix{2**(32-$i)} = $i; # can't use 1<<32 | |
} |
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 'bundler' | |
Bundler.setup(:default) | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'testapp_development') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) |
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
console.log('Loading function'); | |
const https = require('https'); | |
const url = require('url'); | |
const slack_url = 'https://hooks.slack.com/services/...'; | |
const slack_req_opts = url.parse(slack_url); | |
slack_req_opts.method = 'POST'; | |
slack_req_opts.headers = { | |
'Content-Type': 'application/json' | |
}; |
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
Stethoscope.url = "/stethoscope_myapp_ae53unit" | |
Stethoscope.check :database do |resp| | |
resp[:last_migration] = ActiveRecord::Migrator.current_version | |
resp[:pg_version] = ActiveRecord::Base.connection.select_value('SELECT version()') | |
end | |
Stethoscope.check :release do |resp| | |
resp[:version] = "#{MyApp.config.version} (#{Rails.env})" | |
resp[:git_revision] = `git rev-parse HEAD`.chomp |
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" | |
require "sqlite3" | |
require "minitest/autorun" | |
require "logger" | |
require "pp" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do |
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
# frozen_string_literal: true | |
# config/initializers/path_resolver_dir_glob_cache.rb | |
# | |
# Work around glob performance woes for JS requests in development, c.f | |
# https://github.com/rails/rails/issues/30502, by | |
# prepending ActionView::PathResolver#find_template_paths to use a | |
# result cache. Cache invalidation via fs listeners. | |
# Use at your own peril. |
OlderNewer