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' | |
require 'sqlite3' | |
require 'logger' | |
ActiveRecord::Base.logger = Logger.new('debug.log') | |
ActiveRecord::Base.configurations = YAML::load(IO.read('database.yml')) | |
ActiveRecord::Base.establish_connection('development') | |
class Schema < ActiveRecord::Migration | |
def change |
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
jstatd -J-Djava.security.policy=/usr/java/default/bin/jstatd.all.policy | |
# jstatd.all.policy has to be created with the following code: | |
# | |
# grant codebase "file:/usr/java/jdk1.7.0_09/lib/tools.jar" { | |
# permission java.security.AllPermission; | |
# }; |
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
# Custom bash prompt via kirsle.net/wizards/ps1.html | |
source /usr/share/git-core/contrib/completion/git-prompt.sh | |
export PS1="[\[$(tput setaf 5)\]\u\[$(tput setaf 2)\]@\h\[$(tput setaf 6)\]\[$(tput bold)\] \W\[$(tput sgr0)\]\$(__git_ps1)]\\$ \[$(tput sgr0)\]" |
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 Utils | |
class StringDecorator | |
def initialize(string) | |
@string = string | |
end | |
def =~(regex) | |
self.to_s =~ regex | |
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
echo $(docker-machine ip docker-vm) dockerhost | sudo tee -a /etc/hosts |
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
-- Arel | |
select("COUNT(*)").select("LOWER(name) AS name").group("LOWER(name)").having("COUNT(*) > 1") | |
-- SQL | |
SELECT COUNT(*), LOWER(name) AS name FROM "occupations" GROUP BY LOWER(name) HAVING COUNT(*) > 1 |
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
### Foreman alias | |
alias befstart="bundle exec foreman start" | |
alias befrun="bundle exec foreman run" | |
### docker machine | |
function dmdefault() { | |
if [[ "$@" = "" ]] | |
then | |
echo "default" | |
else |
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 BadCompanion < Green | |
has_many :companionships, as: :companion | |
has_many :greens, through: :companionships | |
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
class CreateCompanionships < ActiveRecord::Migration[6.0] | |
def change | |
create_table :companionships do |t| | |
t.references :green, null: false, foreign_key: {to_table: :greens} | |
t.string :companion_type | |
t.references :companion, null: false, foreign_key: {to_table: :greens} | |
t.timestamps | |
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
INSERT INTO "companionships" ("green_id", "companion_type", "companion_id", "created_at", "updated_at") | |
VALUES ($1, $2, $3, $4, $5) | |
RETURNING "id" [ | |
["green_id", 1], | |
-- this line should be GoodCompanion | |
["companion_type", "Green"], | |
["companion_id", 14], | |
["created_at", "2020-05-01 13:05:59.823802"], | |
["updated_at", "2020-05-01 13:05:59.823802"] | |
]; |