Skip to content

Instantly share code, notes, and snippets.


Nisanth Chunduru nisanth074

View GitHub Profile
nisanth074 / gist:d341ab22dede19e572d0e8152393e93a
Created Jun 8, 2021 — forked from ryanbriones/gist:246599
send email to gmail (STARTTLS) using ruby >=1.8.7
View gist:d341ab22dede19e572d0e8152393e93a
# send email using STARTTLS; Net::SMTP#enable_starttls requires ruby >=1.8.7
# this hack is needed for rails <2.3; apparently >=2.3 has something for this already
ActionMailer::Base.class_eval do
def perform_delivery_smtp(mail)
destinations = mail.destinations
smtp =[:address], smtp_settings[:port])
nisanth074 / redis-server
Last active Mar 7, 2019
Redis init script
View redis-server
#! /bin/sh
# Provides: redis-server
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
nisanth074 / bounce_events.rb
Last active Oct 31, 2018
Missing "smtp_id" key
View bounce_events.rb
"_json" => [{
"email" => "",
"timestamp" => 1540907117,
"status" => "4.3.0",
"reason" => "maildrop: maildir over quota.",
"sg_message_id" => "kxRB0RumSp6z8tkmLZnUMQ.filter0176p3mdw1-22850-5BD1C50F-7C.0",
"sg_event_id" => "QcLgvoOaRWCXLZ72J-lf1g",
"type" => "blocked",
"event" => "bounce"

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

nisanth074 / strip_photo_metadata.rb
Created Oct 1, 2017
Strip location information and additional metadata from your photos using ruby
View strip_photo_metadata.rb
# Install imagemagick first
# brew install imagemagick
require "shellwords"
photos_dir = "ENV['Home']/Downloads/Photos to Upload"
Dir["#{photos_dir}/**/*"].each do |file_path|
system("mogrify -strip #{Shellwords.shellescape(file_path)}")
nisanth074 /
Last active Sep 30, 2017
Clone and restore a physical server's harddisk

Clone a server's harddisk

Login to Hetzner's web interface and activate the Rescue System for the server whose disk you wish to clone.

Ssh into the Rescue System (Replace in the command below with the actual ip address of the server)

ssh -o HostKeyAlias=hetzner-rescue. root@
nisanth074 / decode_session_cookie.rb
Created Aug 30, 2017
Decode Session Cookie in Rails 3
View decode_session_cookie.rb
nisanth074 / 176_9_149_227_interfaces
Created Aug 22, 2017
Missing IPv6 Configuration
View 176_9_149_227_interfaces
root@Ubuntu-1604-xenial-64-minimal ~ # cat /etc/network/interfaces
### Hetzner Online GmbH installimage
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
iface lo inet6 loopback
auto eth0
nisanth074 / edid-decode source URL
Created Jul 27, 2017 — forked from OneSadCookie/edid-decode source URL
EDID decoding on the Mac, to find out what resolutions and rates the Mac is seeing reported.
View edid-decode source URL
compile with:
gcc edid-decode.c -o edid-decode
get EDID from IORegistryExplorer (mine, an old 24" Apple Cinema Display, is attached).
Convert to binary with this command:
ruby -e '"edid", "wb").write("edid.txt") { |s| ("0x"+s).to_i(16) }.inject("", "<<"))'
nisanth074 /
Last active Jul 26, 2017
zsh function to quick convert an issue to a pull request


issuetopr 1256

to convert issue 1256 to a pull request.

Copy the function issuetopr to your .bashrc or .zshrc to start using it.