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
drop table if exists student; | |
create table student ( | |
sno integer, | |
sname varchar(10), | |
age integer | |
); | |
drop table if exists courses; | |
create table courses ( | |
cno varchar(5), |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Try ember-set-helper'; | |
} |
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 '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 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 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 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 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 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 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 CachedSequence | |
extend ActiveSupport::Memoizable | |
def initialize(cache_key) | |
@cache_key = cache_key | |
ensure_value | |
end | |
def next | |
Rails.cache.increment(cache_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
require 'active_support/version' | |
require 'active_support/core_ext/time/zones' | |
require 'active_support/core_ext/time/calculations' | |
require 'active_support/time_with_zone' | |
puts "ActiveSupport: #{ActiveSupport::VERSION::STRING}" | |
Time.zone = 'Eastern Time (US & Canada)' | |
def show_time user_time |
NewerOlder