# In your Gemfile
gem "localhost"
# Then, depending on your desired server
gem "falcon"
gem "puma"
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
| # Install ARM Homebrew to /opt/homebrew | |
| # 安装ARM版本的Homebrew 到 /opt/homebrew | |
| mkdir /opt/homebrew | |
| sudo chown -R $(whoami) /opt/homebrew | |
| curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /opt/homebrew | |
| # Install x86 Homebrew | |
| arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
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 | |
| ADDED_OR_MODIFIED = /A|AM|^M/.freeze | |
| if ARGV == ["install"] | |
| exec "ln", "-sf", __FILE__, ".git/hooks/pre-commit" | |
| else | |
| raise unless ARGV == [] | |
| 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
| #!/bin/bash | |
| # Put it into '.git/hooks/prepare-commit-msg' | |
| if [ -z "$BRANCHES_TO_SKIP" ]; then | |
| BRANCHES_TO_SKIP=(master development) | |
| fi | |
| BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
| BRANCH_NAME="${BRANCH_NAME##*/}" |
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 'capybara/firebug' | |
| # Disable Webmock if needed. | |
| WebMock.disable_net_connect!(allow_localhost: true) | |
| # Same thing for VCR if it has been imported somewhere. | |
| VCR.configure do |c| | |
| c.ignore_localhost = true | |
| end | |
| ENV['NO_PROXY'] = ENV['no_proxy'] = '127.0.0.1' |
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 Flatten | |
| def self.call(input_array) | |
| memo = Array.new | |
| flatten(input_array, memo) | |
| end | |
| def self.flatten(array, memo) | |
| array.each do |element| | |
| if element.kind_of?(Array) |
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 just a cheat sheet: | |
| # On production | |
| sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
| # On local | |
| scp -C production:~/database.sql.gz | |
| dropdb database && createdb database | |
| gunzip < database.sql.gz | psql database |
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
| ## http://stackoverflow.com/questions/7145256 | |
| module FactoryGirl | |
| module Strategy | |
| class Find | |
| def association(runner) | |
| runner.run | |
| end | |
| def result(evaluation) | |
| build_class(evaluation).where(get_overrides(evaluation)).first |