View eydeploy.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
# 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" |
View gist:3051871
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 |
View numtoprefix.pl
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 | |
} |
View prefixtest.pl
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))); | |
} |
View aws-slack-notify.js
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' | |
}; |
View hstore_array_test.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 '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) |
View rails-model-templates.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 "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 |
View stethoscope.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
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 |
View ackermann.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 = Hash.new { |a,(m,n)| a[[m,n]] = m==0 ? n+1 : n==0 ? a[[m-1,1]] : a[[m-1, a[[m, n-1]]]] } #=> {} | |
A[[3,4]] #=> 125 | |
A.inspect #=> ... long |
View path_resolver_dir_glob_cache.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
# 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