Skip to content

Instantly share code, notes, and snippets.

View mos3abof's full-sized avatar

Mosab Ibrahim mos3abof

View GitHub Profile
@mos3abof
mos3abof / 100_countdown.c
Last active August 29, 2015 14:18
Count down from 100 to 1
/**
* A quick solution for the question in this blog post:
* http://www.thousandtyone.com/blog/EasierThanFizzBuzzWhyCantProgrammersPrint100To1.aspx
*
* Took me 30 seconds, without the comments.
*
* The problem:
* Print 100 to 1.
* You need to start with "for(int i=0;" and continue from there.
* You cannot write anything before "for(int i=0;".
@mos3abof
mos3abof / organize_movie_files.py
Created December 13, 2014 15:27
Removes any non-alphanumeric characters, chacnges cases to lower cases and spaces to dots.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#@author Mosab Ahmad <[email protected]>
import os
import re
MOVIES_PATH = '/home/mosab/Videos/youtube'
@mos3abof
mos3abof / pycharm.desktop
Created August 5, 2014 09:46
Pycharm Desktop Entry
[Desktop Entry]
Name=Pycharm 3.4.1
Comment=Python IDE
TryExec=/path/to/pycharm-community-3.4.1/bin/pycharm.sh
Exec=/path/to/pycharm-community-3.4.1/bin/pycharm.sh
Icon=/path/to/pycharm-community-3.4.1/bin/pycharm.png
Categories=Development;IDE;Python;
Terminal=false
Type=Application
StartupNotify=true
@mos3abof
mos3abof / tables_referencing_my_table.sql
Created August 4, 2014 13:19
List tables referencing 'my_table' in 'my_database' MySQL database
select
table_name
from
information_schema.KEY_COLUMN_USAGE
where
table_schema = 'my_database'
and referenced_table_name = 'my_table';
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))
@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 <[email protected]>
import datetime
delta = datetime.datetime(2014, 6, 1) - datetime.datetime.now()
days = delta.days
seconds = delta.seconds

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 / 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):
@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 / 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()