This file contains hidden or 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
# ./script --env=RAILS_ENV=production --rm -- bundle exec rails c | |
# DOCKER_ARGS: | |
# --env=RAILS_ENV=production | |
# --rm | |
# PROCESS_CMD: bundle exec rails c | |
function process_container_args { | |
DOCKER_ARGS=() | |
PROCESS_CMD=() | |
_state=DOCKER_ARGS |
This file contains hidden or 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 "open4" | |
require 'stringio' | |
class ShellCommand | |
class CommandError < StandardError | |
attr_reader :stderr_string | |
def initialize(message, stderr_string) | |
super(message) | |
@stderr_string = stderr_string |
This file contains hidden or 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
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"dis_max": { | |
"queries": [ | |
{ | |
"bool": { | |
"should": [ |
This file contains hidden or 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
DROP TABLE IF EXISTS allocations; | |
CREATE TABLE allocations ( | |
id SERIAL PRIMARY KEY, | |
dump_version varchar(255), | |
address varchar(255), | |
root varchar(30), | |
object_type varchar(30), | |
node_type varchar(30), | |
ivars integer, | |
class_address varchar(30), |
This file contains hidden or 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 'json' | |
require 'active_support/all' | |
class CreatePostgresDump | |
attr_accessor :filename, | |
:dump_version, | |
:append | |
COLS = %w(dump_version address root object_type node_type ivars class_address shared bytesize capacity value encoding memsize size length flags generation file line embedded struct is_frozen ref_addresses) |
This file contains hidden or 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
# To run: | |
# 1. cd into a bundler project directory | |
# 2. bundle exec ruby log_process.rb | |
require 'statsd' | |
require 'active_support/all' | |
METRICS = Statsd.new('127.0.0.1', | |
8127, | |
tags: ["service:console", |
This file contains hidden or 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 search(query_text = 'Portland, OR') | |
query_int = Search::Query.new | |
client = query_int.client | |
query_parsed = client.indices.analyze(text: query_text) | |
fragments = query_parsed['tokens'].map { |q| q['token'] } | |
field_matchers = [ | |
['State.name', :prefix], | |
['State.code', :term], |
This file contains hidden or 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
[1] website » class MyNull < ActiveRecord::Base | |
» end | |
=> nil | |
[2] website » my_null = MyNull.new | |
=> #<MyNull:0x007fc89cedd430> { | |
:id => nil, | |
:first_name => "foo", | |
:last_name => "bar" | |
} | |
[3] website » my_null.save! |
This file contains hidden or 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
househappy_test=# create table my_nulls (id integer not null, first_name character varying(255) default 'foo', last_name character varying(255) default 'bar'); | |
CREATE TABLE | |
househappy_test=# create sequence my_nulls_id_seq start with 1 increment by 1 no minvalue no maxvalue cache 1; | |
CREATE SEQUENCE | |
househappy_test=# alter table only my_nulls alter column id set default nextval('my_nulls_id_seq'::regclass); | |
ALTER TABLE | |
househappy_test=# insert into my_nulls (first_name) values (null); | |
INSERT 0 1 | |
househappy_test=# select * from my_nulls where first_name is null; | |
id | first_name | last_name |
This file contains hidden or 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 'spec_helper' | |
class InMemoryArel | |
attr_accessor :collection | |
def initialize(collection) | |
self.collection = collection | |
end | |
def all |