Skip to content

Instantly share code, notes, and snippets.

View shoaibi's full-sized avatar

Shoaibi shoaibi

View GitHub Profile
@shoaibi
shoaibi / is-port-accessible.sh
Created June 25, 2015 15:14
Test if a remote port is responding or not. Good to be used as part of cron/script that'd send notifications if a port becomes unresponsive
#!/bin/sh
# Usage: $0 {hostname} {port} {pathToScriptToExecuteIfPortIsNotAccessibleSayRestartApacheScript}
echo "" | nc $1 $2 && echo $? &>> /dev/null || $3
@shoaibi
shoaibi / .bash_custom.sh
Created June 25, 2015 15:12
My bash configuration containing overrides/additions
# find partition name for a given filename
findpart() { [ -e "$1" ] && df -P "$1" | awk '/^\/dev/ {print $1}' || echo "$1 not found"; }
# Verbose version of sleep
countdown()
{
secs=$1
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
@shoaibi
shoaibi / .bash_aliases.sh
Last active August 29, 2015 14:23
My bash aliases
~/.bash/aliases/apt
##################
# APT
##################
#alias apt-fast='~/scripts/apt-fast.sh'
#alias sagif='sudo apt-fast install -f'
#alias sagi='sudo apt-fast install'
#alias sagur='sudo apt-fast upgrade'
#alias sacs='sudo apt-cache search'
@shoaibi
shoaibi / carry-out-job-until-complete.sh
Created June 25, 2015 14:56
Keep retrying some job till it executes successfully
#!/bin/bash
# Keep retrying some job till it executes successfully
#
# I primarily use this script to download files from servers
# that break the connection after certain minutes. Combining
# this with aria2c makes a really awesome sure-fire way to
# download your files.
#
carryOutJob()
@shoaibi
shoaibi / block-steam-internet-access.sh
Created June 25, 2015 14:49
Block Steam's internet access using iptables
#!/bin/sh
# Block Steam's internet access using iptables
# Script must be run as a user with root (or one that has
# permissions to play with iptables)
#
#
# Why did i need it? Even when running in offline mode
# steam would keep trying to login and then once every
# while it'd end my dota bota match saying "Connection
# Lost".