Skip to content

Instantly share code, notes, and snippets.

View mos3abof's full-sized avatar

Mosab Ibrahim mos3abof

View GitHub Profile
@mos3abof
mos3abof / most_shared_youtube_vids_egypt.py
Created November 28, 2012 21:24
This script parses the most shared videos on Youtube using standard video feed for the region Egypt (EG) and emails basic information about them to a predefined list of recipients using Gmail.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Important imports
import os, sys
# Append the python libs installed on dreamhost to the sys.path
sys.path.append(os.environ['HOME'] +'/lib/python')
# Import email stuff
@mos3abof
mos3abof / restart_apache_fabfile.py
Last active January 31, 2019 14:43
Poor Man's Guide for Monitoring a Website Using Python on Ubuntu and Restarting Apache when it is down. http://www.mos3abof.com/poor-man-website-python-monitor.html
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Import DateTime
from datetime import datetime, timedelta, date
# Import urllib
import urllib
# Importing utilities from Fabric
@mos3abof
mos3abof / apache2_default_page
Created March 14, 2013 13:12
Apache2 Default Page
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
@mos3abof
mos3abof / tower_of_hanoi.py
Created March 24, 2013 14:24
Classic puzzle "Tower of Hanoi" recursive solution in python
def hanoi(n, fr, to, spare):
'''(int, str, str, str)
Solve the classic puzzle Tower of Hanoi
>>> hanoi(1, "Middle", "Left", "Right")
- Move top ring in 'Middle' tower to the 'Left' tower
'''
def print_move(fr, to):
print "- Move top ring in '{}' tower to the '{}' tower".format(fr, to)
@mos3abof
mos3abof / traceroute_easter_egg.py
Created April 7, 2013 02:22
Printing the Easter Egg in "traceroute 216.81.59.173" in a human readable way :)
#!/usr/bin/python
import subprocess
command = ['traceroute', '216.81.59.173']
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
lines = []
while(True):
retcode = p.poll()
@mos3abof
mos3abof / pay_it_forward.py
Last active January 2, 2016 12:09
Plot the equation "y = 5 ** x" for the integer values between 1 and a million.
import math
from matplotlib import pyplot
figsize = (15, 5)
pyplot.figure(figsize=figsize)
pyplot.title('Paying it forward')
data = []
end = 1000000
@mos3abof
mos3abof / democratic_permutations.py
Last active January 4, 2016 08:29
Calculating different permutations of the democratic path we got in Egypt.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Calculating different permutations of the democratic path we got in Egypt.
from itertools import permutations
i = ['دستور', 'برلمان', 'رئاسة']
results = []
for a in permutations(i, 3):

Keybase proof

I hereby claim:

  • I am mos3abof on github.
  • I am mos3abof (https://keybase.io/mos3abof) on keybase.
  • I have a public key ASBlDut8UpMXWCqjKIconLKmTUGE628ZAKrdGkLDVRIftAo

To claim this, I am signing this object:

@mos3abof
mos3abof / complete_cure_device.py
Last active August 29, 2015 14:01
Egyptian Army claimed they invented a cure for AIDS and Hepatites C, and promised to start healing people June the first! Here is a count down!
#!/usr/bin/python
# -*- coding: utf-8 -*-
#@author Mosab Ahmad <mosab.ahmad@gmail.com>
import datetime
delta = datetime.datetime(2014, 6, 1) - datetime.datetime.now()
days = delta.days
seconds = delta.seconds
def ascii_to_binary(ascii_text):
binary_text = ''
for c in ascii_text:
binary_text += bin(ord(c))[2:].zfill(8)
return binary_text
def binary_to_ascii(binary_text):
return ''.join(chr(int(binary_text[i:i+8], 2)) for i in xrange(0, len(binary_text), 8))