Skip to content

Instantly share code, notes, and snippets.

View haseebr's full-sized avatar

Haseeb ur Rahman haseebr

View GitHub Profile
@haseebr
haseebr / Send-TextPlivo.ps1
Last active August 29, 2015 14:23
Send a SMS via Plivo API and Powershell
$PlivoCredentials = Import-CliXml -Path plivo.key
$PlivoJson = @{'src' = '<source>'; 'dst' = '<destination"'; 'text' = '<text'} | ConvertTo-Json
$PlivoUri = "https://api.plivo.com/v1/Account/<Key>/Message/"
Invoke-WebRequest -Method Post
-Uri $PlivoUri
-Body $PlivoJson
-Credential $PlivoCredentials
-ContentType "application/json"
#1/usr/bin/python
from subprocess import call, check_output
import re
import cStringIO
regex = '\s*(\d*)\s(.*)'
ip = check_output('/bin/netstat -ntu | awk \'{print $5}\' | cut -d: -f1 | sort | uniq -c | sort -n', shell = True)
time = str(check_output('date'))
@haseebr
haseebr / show_redirects.py
Created December 9, 2014 10:46
Answer to a Quora Question
import requests
requests.packages.urllib3.disable_warnings() # To disable ugly warnings
url = 'http://bit.ly/1vIaXHA'
def show_redirects(url): # Recursive Function
r = requests.get(url, verify = False, allow_redirects = False)
if r.status_code == 301: # If url redirects, print the destination url and follow it.
print 'redirecting to ', r.headers['location'], '...'
show_redirects(r.headers['location'])
show_redirects(url)