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 doit | |
| yield | |
| end | |
| def do_retry | |
| doit do | |
| begin | |
| puts 'doing' | |
| yield | |
| puts 'done' |
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
| # Setup | |
| # 1) create a new volume based on a snapshot of your old volume | |
| # 2) attach the new volume to your ec2 instance | |
| # look at attached volumes | |
| fdisk -l | |
| # resize the volume | |
| resize2fs /dev/xvdf |
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
| bad_models = FlakyImage.select do |image| | |
| uri = URI.parse image.file.url | |
| Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| | |
| response = http.head uri.path | |
| response.code != "200" | |
| end | |
| end | |
| bad_models.count |
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
| finder = /"#\{([^}]+)\}"/ | |
| '"#{derp}"'.gsub finder, '\1' #=> derp | |
| # EL FIN |
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
| # METHOD 1: | |
| # use this when there's a reasonable number of subdirectories | |
| mv dir1/* dir2/* dir3/* ... DESTINATION | |
| # Then if there are conflicts... | |
| cp -Rn dir2/* DESTINATION | |
| cp -Rn dir3/* DESTINATION | |
| #METHOD 2: | |
| # use this when there are too many subdirectories for mv to handle as args at once |
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
| alias docker-rails-console="docker-compose run --service-ports web rails console" | |
| alias docker-run-web="docker-compose run --service-ports web" | |
| alias heroku-rails-console="heroku run rails console --app" | |
| findDockerInstanceExposedPort() { | |
| docker-compose ps $1 | grep $1 | sed -E 's/.*:([0-9]+)->.*/\1/g' | |
| } | |
| lesscsv() { | |
| OPTIND=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
| lesscsv() { | |
| OPTIND=1 | |
| delimiter="," | |
| theFile="" | |
| while getopts "d:f:" opt; do | |
| case $opt in | |
| "d") delimiter=$OPTARG;; | |
| "f") theFile=$OPTARG;; | |
| esac |
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
| namespace :dbrun do | |
| namespace :functions do | |
| app_root = Rails.application.config.root | |
| sql_functions_path = File.join(app_root, "db", "functions") | |
| sql_functions_glob_path = File.join(sql_functions_path, "*.sql") | |
| ActiveRecord::Base.configurations = YAML.load(File.read(File.join(app_root, 'config', 'database.yml'))) | |
| ActiveRecord::Base.establish_connection (ENV['ENV'] || 'development').to_sym | |
| Dir.glob(sql_functions_glob_path) do |file| |
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
| docker-compose ps $1 | grep $1 | sed -E 's/.*:([0-9]+)->.*/\1/g' |
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
| Function.prototype.variadic = function () { | |
| var self = this | |
| return function () { | |
| return self.apply(self, | |
| self.length == 1 ? | |
| [arguments] : |