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
** Find commmonly accessed tables and their use of indexes: | |
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct; | |
Returns output like: | |
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct | |
----------------------+--------------+---------------+------------------------ | |
schema_migrations | 817 | 0 | 0.00000000000000000000 | |
user_device_photos | 349 | 0 | 0.00000000000000000000 |
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
# Usage: | |
# | |
# validates :array_column, array: { length: { is: 20 }, allow_blank: true } | |
# validates :array_column, array: { numericality: true } | |
# | |
# It also supports sliced validation | |
# | |
# validates :array_column, array: { presence: true, slice: 0..2 } | |
class ArrayValidator < ActiveModel::EachValidator |
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
SELECT motor_symptoms.description, profiles_motor_symptoms.id FROM motor_symptoms LEFT OUTER JOIN profiles_motor_symptoms ON motor_symptoms.id=profiles_motor_symptoms.motor_symptom_id WHERE profiles_motor_symptoms.profile_id=11; | |
SELECT description, profiles_motor_symptoms.id FROM motor_symptoms LEFT OUTER JOIN profiles_motor_symptoms ON profiles_motor_symptoms.motor_symptom_id=motor_symptoms.id; |
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
<!doctype html> | |
<html class="no-js"> | |
<head> | |
<style> | |
a:hover { | |
color: green; | |
} | |
li.active { | |
color: red; |
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
module Builder | |
def collection_otherable_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block) | |
SimpleForm::Tags::CollectionCheckBoxes.new(@object_name, method, @template, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options)).render(&block) | |
end | |
def collection_nested_versionable(method, collection, value_method, text_method, options = {}, html_options = {}, &block) | |
SimpleForm::Tags::CollectionCheckBoxes.new(@object_name, method, @template, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options)).render(&block) | |
end | |
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
curl -o `date +"%Y%m%d%H%M%S"_BACKUPFILENAME.dump `heroku pgbackups:url --app APPNAME` | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U PGUSERNAME -d LOCALDBNAME BACKUPFILENAME.dump |
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
namespace :db do | |
require "sequel" | |
Sequel.extension :migration | |
DB = Sequel.connect(ENV['DATABASE_URL']) | |
desc "Prints current schema version" | |
task :version do | |
version = if DB.tables.include?(:schema_info) | |
DB[:schema_info].first[:version] | |
end || 0 |
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 "net/http" | |
require "openssl" | |
cert_store = OpenSSL::X509::Store.new | |
cert_store.add_file 'certs/AddTrustExternalCARoot.crt' | |
cert_store.add_file 'certs/COMODORSAAddTrustCA.crt' | |
http = Net::HTTP.new('ume.michaeljfox.org', 8097) | |
#http = Net::HTTP.new('173.193.29.12', 11121) |
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
ActiveRecord::Base.connection.tables.each do |table| | |
ActiveRecord::Base.connection.reset_pk_sequence!(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
// | |
// mixin for bullet proof font declaration syntax | |
// pulled from: http://pivotallabs.com/bulletproof-font-face-syntax-with-sass/ | |
// | |
// font-path is a rails helper which can be replaced with your font directory path | |
// when not using rails | |
// | |
@mixin declare-font-face($font-family, $font-filename, $font-weight: normal, $font-style: normal, $font-stretch: normal) { | |
@font-face { | |
font-family: '#{$font-family}'; |
NewerOlder