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
// | |
// ViewController.swift | |
// CollectionView | |
// | |
// Created by Paul McKellar on 8/13/16. | |
// Copyright © 2016 Paul McKellar. All rights reserved. | |
// | |
import UIKit |
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
Mac Docker Notes | |
Install the toolkit: | |
https://www.docker.com/products/docker-toolbox | |
Docker Machine | |
- create a docker-machine (which is your OSX shim) | |
- docker-machine create --driver virtualbox default |
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
# list directories | |
dirs = `du -h`.split("\n") | |
# get empty ones | |
empty_dirs = dirs.select{|d| d.split("\t").first.strip == "0B" } | |
# get only names | |
dir_names = empty_dirs.map{|d| d.split("\t")[1] } | |
# delete them |
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
config.use_transactional_fixtures = true | |
config.before(:each, js: true) do | |
self.use_transactional_fixtures = false | |
ActiveRecord::Base.establish_connection | |
DatabaseCleaner.strategy = :truncation | |
DatabaseCleaner.start | |
end | |
config.after(:each, js: true) do |
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 change_encoding(encoding,collation) | |
connection = ActiveRecord::Base.connection | |
tables = connection.tables | |
dbname = connection.current_database | |
connection.execute <<-SQL | |
ALTER DATABASE #{dbname} CHARACTER SET #{encoding} COLLATE #{collation}; | |
SQL | |
tables.each do |tablename| | |
connection.execute <<-SQL |
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
gem 'devise' | |
rails generate devise:install | |
rails generate devise User | |
class User < ActiveRecord::Base | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable |
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 cp(path) | |
"active" if current_page?(path) | |
end | |
def tab_link_to(title, uri) | |
content_tag :li, class: cp(uri), role: :presentation do | |
link_to title, uri | |
end | |
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
module Tokenable | |
extend ActiveSupport::Concern | |
included do | |
before_validation :generate_token | |
validates :token, presence: true, uniqueness: true | |
end | |
protected |
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
PARAMETER_GROUP="utf8mysql56" # no weird chars | |
DB_FAMILY="mysql5.6" # version you are running | |
CRED_FILE="./aws/cred-file" | |
# create group | |
rds-create-db-parameter-group $PARAMETER_GROUP -f $DB_FAMILY -d utf8-mysql5.6 --aws-credential-file $CRED_FILE | |
# change params for group | |
rds-modify-db-parameter-group $PARAMETER_GROUP -f $DB_FAMILY --aws-credential-file $CRED_FILE --parameters="name=character_set_server, value=utf8, method=immediate" --parameters="name=collation_server, value=utf8_unicode_ci, method=immediate" |
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
databasename = "DBNAME" | |
ActiveRecord::Base.connection.tables.each do |table| | |
sql_string = "ALTER TABLE #{databasename}.#{table} CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;" | |
connection = ActiveRecord::Base.connection | |
connection.execute(sql_string) | |
end |