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
# e.g. see where Ruby is actually installed | |
readlink $(which ruby) |
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
TODO |
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
# GET | |
HTTParty.get('www.example.com') | |
# POST | |
HTTParty.post( | |
'www.example.com', | |
headers: { 'Content-Type' => 'application/json' }, | |
body: { | |
title: 'The Catcher in the Rye', | |
author: 'J. D. Salinger', |
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
before(:example) do | |
stub_const('ENV', ENV.to_hash.merge('FOO' => 'bar', 'BAZ' => 'blah')) | |
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
RUN apt-get update -qq && \ | |
apt-get install -y --no-install-recommends wait-for-it && \ | |
rm -rf /var/lib/apt/lists/* |
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
# Initialize | |
# | |
# @return [void] | |
def initialize | |
# Setup a simple logger for running locally (if full $logger not available) | |
$logger ||= Class.new do | |
# Print info message | |
# | |
# @param msg [String] Message to print | |
# @return [void] |
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
# Example 1 | |
docker compose run --entrypoint 'bash -c' --rm web 'bundle exec rails {db:create,db:migrate}' | |
# Example 2 | |
docker compose run --no-deps --rm web bundle install && docker compose build | |
# Example 3 | |
docker compose run --no-deps --rm -e GEM_HOME=/home/ruby/gems <SERVICE_NAME> bundle install |
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
# GET shards | |
num_shards_in_use = client.cluster.stats['indices']['shards']['total'] | |
# GET docs | |
response = client.search(index: 'index_name', q: '!2022-10-11 AND !2022-10-12 AND !2022-10-13', df: 'date', _source_includes: ['name', 'date']) | |
docs = response['hits']['hits'] | |
num_docs = response['hits']['total']['value'] | |
# GET indices | |
all_indices = client.indices.stats['indices'].map(&:first) |
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
# Max number of retries if error occurs while pruning index | |
MAX_NUM_RETRIES = 3 | |
# Number of seconds to wait between retries | |
RETRY_TIMEOUT_SECONDS = 5 | |
begin | |
retries ||= 0 | |
# Do something | |
rescue StandardError => e |
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 'open-uri' | |
url = 'https://www.google.com/' | |
file = URI.open(url) | |
contents = file.read | |
puts contents |