Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Abdallah Deeb abdallah

🏠
Working from home
View GitHub Profile
@abdallah
abdallah / netstat_count_ips.sh
Created Nov 7, 2011
Netstat to to find number of connections from each IP
View netstat_count_ips.sh
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
# found @ http://midnight-cafe.co.uk/linux-commands/netstat-to-find-number-of-connections-from-each-ip/
@abdallah
abdallah / NatGeoWallpaperDownloader.py
Created Jun 27, 2012
NatGeo Wallpaper Downloader
View NatGeoWallpaperDownloader.py
#!/usr/bin/python
# NatGeo Wallpaper Downloader
# version: 0.1.2
# author: Abdallah Deeb <abdallah.deeb@gmail.com>
# description: Simply python script to download
# and set the gnome wallpaper from the
# National Geographic "Photo of the day" page
# source: http://photography.nationalgeographic.com/photography/photo-of-the-day/
import urllib2, urllib, os, re
from gi.repository import Gio
@abdallah
abdallah / smtptest.py
Created Jul 26, 2012
Simple SMTP tester script
View smtptest.py
import smtplib
import argparse
import sys
parser = argparse.ArgumentParser(description='SMTP Tester', add_help=True)
parser.add_argument('-s', '--server', dest='server', action='store',
help='Server Name or IP')
parser.add_argument('-u', '--username', dest='username', action='store',
help='username - try with and without the @')
parser.add_argument('-p', '--password', dest='password', action='store',
@abdallah
abdallah / reinstallvps.sh
Created Jul 26, 2012
Re-install VPS at RimuHosting
View reinstallvps.sh
#!/bin/bash
APIKEY=0000000000000000000000000
VPSOID=00000000
VPSNAME=test01.vps
# more info on this per http://apidocs.rimuhosting.com/jaxbdocs/com/rimuhosting/rs/order/OSDPrepUtils.NewVPSRequest.html
# & instantiation_options: http://apidocs.rimuhosting.com/jaxbdocs/com/rimuhosting/rs/order/OSDPrepUtils.InstantiationData.html
create_vps() {
echo Installing ${VPSNAME} ...
curl -X POST \
@abdallah
abdallah / checkmodule.sh
Created Jul 31, 2012
Check if a module is compiled in to the kernel
View checkmodule.sh
#!/bin/bash
zgrep $1 /proc/config.gz
@abdallah
abdallah / restartvps.sh
Created Aug 8, 2012
Reboot RimuHosting VPS
View restartvps.sh
#!/bin/bash
APIKEY=00000000000000000000000000
VPSOID=0000000
VPSNAME=whatever
curl -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: rimuhosting apikey=$APIKEY" -X PUT -d ‘{"reboot_request": {"running_state": "RESTARTING"}}’ https://rimuhosting.com/r/orders/order-$VPSOID-$VPSNAME/vps/running-state
View guess_dns_zone.py
import dns.zone
import dns.resolver
domain_name = 'rimuhosting.com' # --- CHANGE THIS
dns_server = 'ns1.rimuhosting.com'
def guess_zone(domain_name):
soa_answer = dns.resolver.query(domain_name, 'SOA')
soa_rr = soa_answer.rrset[0]
ns_answer = dns.resolver.query(domain_name, 'NS')
@abdallah
abdallah / rimudns.py
Created Sep 18, 2012
RimuHosting/Zonomi DNS API
View rimudns.py
# See https://rimuhosting.com/dns/dyndns.jsp for more information
# or https://zonomi.com/app/dns/dyndns.jsp
# Tests
#
# from rimudns import RimuDNS
#
# api_key = '4ad62e78ac5595f662004b0f01c1a723'
# dns = DNS(api_key)
#
# dns.change_ip('192.168.59.133', '192.168.59.132')
@abdallah
abdallah / installmaven.sh
Last active Dec 14, 2015
Install latest maven
View installmaven.sh
#!/bin/sh
URL="http://apache.mirrors.hoobly.com/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz"
INSTALLATION_DIR=/usr/local/maven
if [ -d $INSTALLATION_DIR ]; then
mv $INSTALLATION_DIR $INSTALLATION_DIR.$(date +"%Y%m%d")
fi
mkdir $INSTALLATION_DIR
wget -O- $URL | tar zx --strip-components=1 -C $INSTALLATION_DIR
cat << _EOF_ > /etc/profile.d/maven.sh
#!/bin/bash
@abdallah
abdallah / tellmewhenurdone.sh
Last active Dec 14, 2015
Email me when a long running process is finished
View tellmewhenurdone.sh
PROCESS=$1
SLEEP_TIME=60
EMAIL_ADDRESS=abdallah@example.com
while [ -n "$(pidof $PROCESS)" ]; do sleep $SLEEP_TIME; done; echo "Finished ..." | mail -s "Work finished" $EMAIL_ADDRESS