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 | |
# Trap sigterm and sleep before passing signal to child for $SIGNAL_TIMEOUT seconds | |
# this is to address a shutdown issue with traefik: https://docs.traefik.io/user-guide/marathon/#shutdown | |
cmd=${*} | |
# default to 10 seconds | |
SIGNAL_TIMEOUT=${SIGNAL_TIMEOUT:-10} | |
log() { |
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 MyWorker | |
include Sidekiq::Worker | |
sidekiq_options unique_for: 10.minutes | |
def perform(...) | |
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
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
var FORMAT_ONELINE = 'One-line'; | |
var FORMAT_MULTILINE = 'Multi-line'; | |
var FORMAT_PRETTY = 'Pretty'; | |
var LANGUAGE_JS = 'JavaScript'; | |
var LANGUAGE_PYTHON = 'Python'; |
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 run -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=localhost --env ADVERTISED_PORT=9092 spotify/kafka | |
docker run -it --rm spotify/kafka /bin/bash | |
$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list 172.17.0.2:9092 --topic test | |
docker run -it --rm spotify/kafka /bin/bash | |
$KAFKA_HOME/bin/kafka-console-consumer.sh --zookeeper 172.17.0.2:2181 --topic test |
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
# frozen_string_literal: true | |
module ErrorResponses | |
def rails_respond_without_detailed_exceptions | |
env_config = Rails.application.env_config | |
original_show_exceptions = env_config['action_dispatch.show_exceptions'] | |
original_show_detailed_exceptions = env_config['action_dispatch.show_detailed_exceptions'] | |
env_config['action_dispatch.show_exceptions'] = true | |
env_config['action_dispatch.show_detailed_exceptions'] = false | |
yield | |
ensure |
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 'rails_helper' | |
RSpec.describe 'My API' do | |
let(:request) do | |
lambda do | |
get '/my_api/value-cannot-be-routed-due-to-route-constraints' | |
end | |
end | |
context 'when action_dispatch.show_exceptions is false (default behavior on test env)' 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
Rails.application.configure do | |
# Settings specified here will take precedence over those in config/application.rb. | |
... | |
# Raise exceptions instead of rendering exception templates. | |
config.action_dispatch.show_exceptions = true | |
... | |
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
Gem::Version.new('0.3.2') < Gem::Version.new('0.10.1') | |
=> true | |
Gem::Version.new('0.3.0') == Gem::Version.new('0.3') | |
=> true |
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
v1 = '0.3.0' | |
v2 = '0.3' | |
a1 = v1.split('.').map{|v| v.to_i} | |
a2 = v2.split('.').map{|v| v.to_i} | |
(a1 <=> a2) == 0 # v1 == v2 | |
=> false | |
(a1 <=> a2) > 0 # v1 > v2 | |
=> true |
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
v1 = '0.3.2' | |
v2 = '0.10.1' | |
a1 = v1.split('.').map{|v| v.to_i} | |
a2 = v2.split('.').map{|v| v.to_i} | |
(a1 <=> a2) < 0 # v1 < v2 | |
=> true | |
(a1 <=> a2) > 0 # v1 > v2 | |
=> false |