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
#!/bin/sh | |
# | |
# Copyright (c) 2005 Linus Torvalds | |
# | |
USAGE='' | |
SUBDIRECTORY_OK='Yes' | |
. git-sh-setup |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Try ember-set-helper'; | |
} |
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 'mechanize' | |
require 'set' | |
require 'pry' | |
ACCOUNT = ENV['OPENDNS_ACCOUNT'] | |
USERNAME = ENV['OPENDNS_USERNAME'] | |
PASSWORD = ENV['OPENDNS_PASSWORD'] | |
BLOCK_LIMIT = 25 | |
AGENT_NAME = 'Mac Safari' |
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
#!/usr/bin/env ruby | |
# from https://stackoverflow.com/posts/24458934/revisions | |
require 'digest/sha1' | |
def git_hash(filename) | |
data = File.read(filename) | |
Digest::SHA1.hexdigest("blob #{data.bytesize.to_s}\0#{data}") | |
end |
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
irb | |
irb(main):001:0> require 'active_record' | |
=> true | |
irb(main):002:0> ActiveRecord::Base.establish_connection(adapter: :postgresql, database: :view_demo) | |
=> #<ActiveRecord::ConnectionAdapters::ConnectionPool:0x007ffc83b088d0 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007ffc83b099d8>, @spec=#<ActiveRecord::ConnectionAdapters::ConnectionSpecification:0x007ffc84134d08 @config={:adapter=>:postgresql, :database=>:view_demo}, @adapter_method="postgresql_connection">, @checkout_timeout=5, @reaper=#<ActiveRecord::ConnectionAdapters::ConnectionPool::Reaper:0x007ffc83b09c58 @pool=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x007ffc83b088d0 ...>, @frequency=nil>, @size=5, @reserved_connections=#<ThreadSafe::Cache:0x007ffc83b0b440 @backend={}, @default_proc=nil>, @connections=[], @automatic_reconnect=true, @available=#<ActiveRecord::ConnectionAdapters::ConnectionPool::Queue:0x007ffc83b03f10 @lock=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x007ffc83b088d0 ...>, @cond=#<MonitorMixin::ConditionVariab |
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 'active_record' | |
spec = { adapter: :postgresql, database: :jgn } | |
ActiveRecord::Base.establish_connection(spec) | |
if ActiveRecord::Base.connection.table_exists?(:members) | |
ActiveRecord::Base.connection.drop_table :members | |
puts 'Dropped table' | |
end |
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 'active_record' | |
blacklist = { | |
icis_production: [ 'patient_versions', 'patients' ], | |
snowflake_production: [ 'persons' ] | |
} | |
blacklist.each_pair do |database, blacklisted_tables| | |
spec = { | |
adapter: :postgresql, |
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
# this is how you bring in a gem (a module). The gem should previous be | |
# installed with: gem install activerecord (yes, the gem name and what | |
# "require" are different.) | |
require 'active_record' | |
# This is a hash, like a dictionary in Python. | |
# The classic syntax looks like this: | |
# spec = { 'adapter' => 'postgresql', 'database' => 'icis_production' } | |
# However, the tokens preceded with the colon are actually symbols, where | |
# are like strings but they can't be changed. So, the following hash |
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
class UnexpectedOutputError < StandardError; end | |
class MockLogger | |
def initialize(expected_indirect_outputs) | |
@eio = Array(expected_indirect_outputs) | |
end | |
def info(s) | |
expected = @eio.shift | |
if expected != s | |
raise UnexpectedOutputError.new("Fail: got #{s}; expected #{expected}") | |
end |
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 'logger' | |
def get_logger | |
logger = Logger.new(STDOUT) | |
def logger.info(s) | |
@log_output ||= "" | |
@log_output << s << "\n" | |
end | |
def logger.log_output | |
@log_output | |
end |
NewerOlder