Skip to content

Instantly share code, notes, and snippets.

@shinenelson
shinenelson / multi-scp.sh
Created April 19, 2016 22:50
Multiple destination SCP - Copy file from one location to multiple machines in one go
#!/bin/bash
# This bash script copies a file from a specified file path
# and places it in the same path on each of the specified hosts
# The script requires at least 3 arguments :
# - Filepath
# - Filename
# - Host(s) to copy the file
@shinenelson
shinenelson / jenkins-remote-build-trigger.sh
Created May 27, 2016 23:55
This script triggers Jenkins builds remotely; provided you have the necessary configurations set on your Jenkins node
#!/bin/bash
# This script triggers Jenkins builds remotely
# provided you have the necessary configurations set on
# your Jenkins node
# This script takes in 3 variables (Jenkins URL, User's name and API Key),
# 2 arguments (job-name, authentication token)
# and assumes that you don't have to build with parameters
@shinenelson
shinenelson / map-mongo-attributes.rb
Last active January 4, 2017 10:41
Generate collection map (YAML) for MoSQL (mongoid => Postgres) from rails console
#!/usr/bin/env ruby
# This script traverses over the fields in a model
# of a rails application to map them to
# the corresponding schema type in Postgres.
# The output generated is in YAML format
# and can be used as the collection map for MoSQL.
puts "#{Mongoid.default_session.options[:database]}:" # Print the database the application is connected to
@shinenelson
shinenelson / epoch-duration.bash
Last active April 6, 2021 21:42
Calculate duration between 2 epoch timestamps passed as arguments
#!/bin/bash
# This script calculates the duration between
# 2 epoch timestamps passed as arguments to it
# This script accepts only epoch timestamps
# because only the epoch timestamps are complete.
# Other timestamps may cause confusions.
# However, support for formats supported by `date'
@shinenelson
shinenelson / nginx_status
Created December 18, 2017 03:09
A simple generic nginx_status configuration
server {
listen 80;
server_name _;
location = /status {
stub_status;
access_log off;
}
@shinenelson
shinenelson / Birthday-slackbot.py
Last active November 22, 2019 15:28
Slack Bot that wishes your team mates on their Birthdays
#!/usr/bin/env python
import os
from datetime import date
import json
try:
from urllib.request import urlopen
except ImportError:
#!/usr/bin/env awk
# not really necessary, but here for completness
# BEGIN {
# mem = 0;
# swap = 0;
# }
NR == 2 { mem = $4; }
NR == 3 { swap = $3; }
@shinenelson
shinenelson / Telegram-dialog-sort-by-unread.py
Last active August 5, 2022 16:20
sort telegram dialog list by unread count
#!/usr/bin/env python3
from sys import argv, exit # pylint: disable=redefined-builtin
from telethon.sync import TelegramClient
from telethon.utils import get_display_name
from telethon.tl.types import User
from telethon.tl.functions.messages import GetDialogFiltersRequest
# Telegram API Credentials
config = {
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Shine Nelson",
"label": "System Administrator / IT Consultant",
"image": "https://www.gravatar.com/avatar/388f1f06508faa9283639fc333bf9857?size=256",
"email": "[email protected]",
"url": "https://shinenelson.in",
"summary": "Shine enjoys experimenting with technology and building new technology for the betterment of humanity. His interest in technology piqued as a eighth grader from reading technology magazines his father would bring from work. He set his ambition to pursue Computer Science & Engineering. During his under-graduation course, he was introduced to GNU/Linux and subsequently Free, Libre and Open Source Software (FLOSS) which changed his life to a whole new world of experimentation and fun. Since then, he has never stopped compiling open source software and experimenting with new technology in general. He would categorize among the early