Skip to content

Instantly share code, notes, and snippets.

View mos3abof's full-sized avatar

Mosab Ibrahim mos3abof

View GitHub Profile
#include <string>
#include <fstream>
int main() {
std::ifstream input_file("/etc/passwd");
if (input_file)
{
std::string line;
@mtayseer
mtayseer / compress_images.py
Created February 23, 2014 11:55
Given a directory, compress all images in it
import sys, os
from PIL import Image
files = os.listdir(sys.argv[1])
for i, f in enumerate(files):
fname = os.path.join(sys.argv[1], f)
im = Image.open(fname).save(fname)
print 'Compressing {} of {}'.format(i, len(files))
@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 / 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
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jamiew
jamiew / google_twunter_lol
Created July 28, 2011 20:34
All the dirty words from Google's "what do you love" project: http://www.wdyl.com/
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,