Skip to content

Instantly share code, notes, and snippets.

@nisanth074
nisanth074 / redis-server
Last active Mar 7, 2019
Redis init script
View redis-server
#! /bin/sh
### BEGIN INIT INFO
# 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
nisanth074 / bounce_events.rb
Last active Oct 31, 2018
Missing "smtp_id" key
View bounce_events.rb
{
"_json" => [{
"email" => "lovis@tinybuddy.se",
"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"
View better-ssh-authorized-keys-management.md

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
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)}")
end
@nisanth074
nisanth074 / clone_and_restore_server_harddisk.md
Last active Sep 30, 2017
Clone and restore a physical server's harddisk
View clone_and_restore_server_harddisk.md

Clone a server's harddisk

Login to Hetzner's web interface https://robot.your-server.de/ and activate the Rescue System for the server whose disk you wish to clone.

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

ssh -o HostKeyAlias=hetzner-rescue.1.2.3.4 root@1.2.3.4
@nisanth074
nisanth074 / decode_session_cookie.rb
Created Aug 30, 2017
Decode Session Cookie in Rails 3
View decode_session_cookie.rb
@nisanth074
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
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
http://cgit.freedesktop.org/xorg/app/edid-decode/plain/edid-decode.c
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 'File.open("edid", "wb").write(File.read("edid.txt").split.map { |s| ("0x"+s).to_i(16) }.inject("", "<<"))'
@nisanth074
nisanth074 / README.md
Last active Jul 26, 2017
zsh function to quick convert an issue to a pull request
View README.md

Run

issuetopr 1256

to convert issue 1256 to a pull request.

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

@nisanth074
nisanth074 / magicbell.io
Last active Jul 7, 2017
Example nginx configuration file for phusion passenger open source
View magicbell.io
server {
listen 443;
root /home/rails/apps/magicbell_site/current/public;
server_name magicbell.io;
# Use certificates we purchased from https://www.ssl2buy.com
ssl on;
ssl_certificate /etc/nginx/certs/magicbell.io/magicbell.io.crt;
ssl_certificate_key /etc/nginx/certs/magicbell.io/magicbell.io.key;