Skip to content

Instantly share code, notes, and snippets.

@JunilJacob
JunilJacob / bash_strict_mode.md
Created January 23, 2024 07:11 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

##Working configuration to accomplish 0-downtime deploy with unicorn 5.x and systemd on centos 7

The scope is to accomplish a 0-downtime reload of a unicorn service managed by Systemd on a Centos 7 distro.

The examples and assumptions that i found on the bogomips's unicorn repo seems not working for centos 7.

Below a working configuration tested on Centos 7 and unicorn 5.1

Any advice/remark will be appreciated

@JunilJacob
JunilJacob / with_retries.rb
Created June 27, 2022 18:45 — forked from cainlevy/with_retries.rb
with_retries{} helper to easily catch and retry exceptions in Ruby
module Retriable
# This will catch any exception and retry twice (three tries total):
# with_retries { ... }
#
# This will catch any exception and retry four times (five tries total):
# with_retries(:limit => 5) { ... }
#
# This will catch a specific exception and retry once (two tries total):
# with_retries(Some::Error, :limit => 2) { ... }
#
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@JunilJacob
JunilJacob / totp_2fa.rb
Created May 31, 2019 09:54 — forked from Nitrino/totp_2fa.rb
Rails mixin module for Two Factor Authentication (TOTP)
module OneTimePassword
# Concern containing logic and methods for OTP authentication.
# Is used Time-based One-time Password Algorithm(TOTP)
# https://tools.ietf.org/html/rfc6238
extend ActiveSupport::Concern
OTP_DIGITS = 6
OTP_NUMBER_OF_BACKUP_CODES = 10
OTP_BACKUP_CODE_LENGTH = 12
@JunilJacob
JunilJacob / clean_git_tags.sh
Created June 17, 2017 21:31 — forked from awilliams/clean_git_tags.sh
Delete multiple grepable tags from git
#!/bin/bash
for i in $( git tag -l | grep staging ); do
echo Tag: $i
#git tag -d $i
#git push origin :refs/tags/$i
done