Skip to content

Instantly share code, notes, and snippets.

View mahmoudhossam's full-sized avatar
🏗️

Mahmoud Hanafy mahmoudhossam

🏗️
  • Berlin, Germany
  • 12:46 (UTC +02:00)
View GitHub Profile
def roman_numeral_to_int(string):
symbols = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000
}
rofi usage:
rofi [-options ...]
Command line only options:
-no-config Do not load configuration, use default values.
-v,-version Print the version number and exit.
-dmenu Start in dmenu mode.
-display [string] X server to contact.
${DISPLAY}
-h,-help This help message.
@mahmoudhossam
mahmoudhossam / Swap ESC and CAPS.ahk
Last active September 4, 2017 10:04
AutoHotkey script to swap Escape and Caps Lock
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
$Capslock::Esc
$Esc::Capslock
@mahmoudhossam
mahmoudhossam / test.conf
Created July 28, 2017 01:18
example nginx config
upstream django {
server 127.0.0.1:9000; # for a web port socket (we'll use this first)
}
import requests
def unshorten(url):
try:
r = requests.head(url, allow_redirects=True)
except:
return r.url
return r.url

Keybase proof

I hereby claim:

  • I am mahmoudhossam on github.
  • I am mahmoudhossam (https://keybase.io/mahmoudhossam) on keybase.
  • I have a public key whose fingerprint is BB0D 2F43 0DC4 1C98 A9FF B60B D93B B4FD 958B BDC3

To claim this, I am signing this object:

@mahmoudhossam
mahmoudhossam / scrape.py
Last active February 19, 2019 07:06
Scraping Rotten Tomatoes
from pyquery import PyQuery as pq
import requests
import psycopg2 as pg
def get_title(element):
return element.cssselect('.media-heading a')[0].text
def get_rating(element):
el = element.cssselect("div[style='color:#F1870A']")[0]
@mahmoudhossam
mahmoudhossam / LearningSQLExample.sql
Last active December 17, 2018 00:40
"Learning SQL" example file converted to PostgreSQL.
/* begin table creation */
create table department
(department_id serial primary key,
name varchar(20) not null
);
create table branch
(branch_id serial primary key,
name varchar(20) not null,
@mahmoudhossam
mahmoudhossam / response.md
Last active December 18, 2015 17:09
How I think Java code should be written and why.

This is in response to this article.

Braces

In the 21st century where 2k monitors exist, saving a line of code here or there really isnt a valid argument. Especially when source files can most of the time fit all on one screen. Code folding also exists in many good IDEs.

2k monitors do exist, but not everybody has them. I have a single 20" monitor with a resolution of 1600*900.

Saving a line of code here and there does count for something when you're looking at a ~9000 line monstrosity like this.

@mahmoudhossam
mahmoudhossam / insertion_sort.py
Created February 8, 2013 16:48
Insertion sort in Python.
def insertion_sort(seq):
j = 1
for i in range(1, len(seq)):
j = i
while j > 0 and seq[j] < seq[j-1]:
seq[j], seq[j-1] = seq[j-1], seq[j]
j -= 1
return seq