Skip to content

Instantly share code, notes, and snippets.

View Navdevl's full-sized avatar
☄️
11.11

Naveen Honest Raj Navdevl

☄️
11.11
View GitHub Profile
@Navdevl
Navdevl / deploy.sh
Created July 19, 2024 09:24
Deploying applications using Dockerfile (with nearly zero downtime)
#!/bin/bash
# Function to check container health
check_container_health() {
local container=$1
local max_retries=10
local retry_interval=5
for i in $(seq 1 $max_retries); do
if [ "$(docker inspect --format='{{.State.Health.Status}}' $container)" == "healthy" ]; then
@brenogazzola
brenogazzola / migrate_im_to_vips.md
Last active April 25, 2026 11:39
Steps to migrate ImageMagick to Libvips

For apps built before the image_processing gem became the default, the migration will involve two steps:

  1. Migrating to the image processing syntax while still using ImageMagick;
  2. Switching to Vips and updating the compression options;

Migrate to the image processing syntax

Before changing from ImageMagick to Vips, it's better to first test the new syntax and ensure everything is still working.

1. Move everything that has to do with compression to a saver hash:

variant(format: :jpg, strip: true, quality: 80)
@leodutra
leodutra / unfollow-instagram.js
Created February 10, 2019 01:40
Instagram - auto unfollow
// open "following" on web browser
async function main() {
const buttons = document.querySelectorAll('button')
for (let button of buttons) {
if (button.textContent.trim().toLowerCase() === 'seguindo') {
button.click()
await wait(5000)
const unfollowBtns = document.querySelectorAll('button')
for (let x of unfollowBtns) {
if (x.textContent.trim().toLowerCase() === 'deixar de seguir') {
@jooeycheng
jooeycheng / ruby_generate_pubkey.rb
Last active May 5, 2023 01:03
Ruby OpenSSL::PKey::RSA generate RSA Public Key from Modulus and Exponent
# [A] OpenSSL::PKey::RSA has undocumented `e=' and `n=' methods
exponent = "10001"
modulus = "9201EBD5DC974FDE613A85AFF2728627FD2C227F18CF1C864FBBA3781908BB7BD72C818FC37D0B70EF8708705C623DF4A9427A051B3C8205631716AAAC3FCB76114D91036E0CAEFA454254D135A1A197C1706A55171D26A2CC3E9371B86A725458E82AB82C848AB03F4F0AF3127E7B2857C3B131D52B02F9A408F4635DA7121B5B4A53CEDE687D213F696D3116EB682A4CEFE6EDFC54D25B7C57D345F990BB5D8D0C92033639FAC27AD232D9D474896668572F494065BC7747FF4B809FE3084A5E947F72E59309EDEAA5F2D81027429BF4827FB62006F763AFB2153C4A959E579390679FFD7ADE1DFE627955628DC6F2669A321626D699A094FFF98243A7C105"
rsa = OpenSSL::PKey::RSA.new
e = exponent.to_i(16)
n = modulus.to_i(16)
rsa.e = OpenSSL::BN.new(e)
rsa.n = OpenSSL::BN.new(n)
@nertzy
nertzy / case_statement_builder.rb
Created November 5, 2010 19:30
Quick way to build a case statement in SQL using ActiveRecord
module CaseStatementBuilder
class << self
delegate :connection, :to => ActiveRecord::Base
def build(lhs, values_hash, default_value)
when_expressions = values_hash.sort.map do |rhs, value|
"WHEN #{lhs} = #{connection.quote(rhs)} THEN #{connection.quote(value)}"
end.join(" ")
"CASE #{when_expressions} ELSE #{connection.quote(default_value)} END"