Skip to content

Instantly share code, notes, and snippets.

fuzzy logic

Josh Goodall inopinatus

fuzzy logic
View GitHub Profile
inopinatus / eydeploy.rb
Created Aug 28, 2011 — forked from mutle/gist:1175364
no maintenance page unless we're migrating. who needs grep?
View eydeploy.rb
# 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"
inopinatus / hstore_accessor.rb
Last active Feb 22, 2019
hstore accessor class method for AR
View hstore_accessor.rb
# include from an initializer
module HstoreAccessor
def self.included(base)
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|
inopinatus / gist:3051871
Created Jul 5, 2012
Can't remember what this does, looks like it takes Debian package status as input
View gist:3051871
#!/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
use strict;
use integer;
sub dqtoint ($) {
my $dq = shift;
return unpack('N', pack('CCCC', split(/\./, $dq, 4)));
use strict;
use integer;
my %sizeprefix = ();
for my $i (0..32) {
$sizeprefix{2**(32-$i)} = $i; # can't use 1<<32
inopinatus / hstore_array_test.rb
Last active Dec 19, 2015
hstore array test code
View hstore_array_test.rb
require 'bundler'
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'testapp_development')
ActiveRecord::Base.logger =
View aws-slack-notify.js
console.log('Loading function');
const https = require('https');
const url = require('url');
const slack_url = '';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {
'Content-Type': 'application/json'
View stethoscope.rb
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()')
Stethoscope.check :release do |resp|
resp[:version] = "#{MyApp.config.version} (#{Rails.env})"
resp[:git_revision] = `git rev-parse HEAD`.chomp
inopinatus / rails-model-templates.rb
Last active Jul 20, 2017
Rails model templates, concept sketch
View rails-model-templates.rb
require "active_record"
require "sqlite3"
require "minitest/autorun"
require "logger"
require "pp"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.logger =
ActiveRecord::Schema.define do
inopinatus / path_resolver_dir_glob_cache.rb
Last active Jun 1, 2018
Temporary workaround for Rails globbing performance issue
View path_resolver_dir_glob_cache.rb
# frozen_string_literal: true
# config/initializers/path_resolver_dir_glob_cache.rb
# Work around glob performance woes for JS requests in development, c.f
#, by
# prepending ActionView::PathResolver#find_template_paths to use a
# result cache. Cache invalidation via fs listeners.
# Use at your own peril.