Skip to content

Instantly share code, notes, and snippets.

View kmonsoor's full-sized avatar
:octocat:

Khaled Monsoor kmonsoor

:octocat:
View GitHub Profile
@kmonsoor
kmonsoor / pelican_new_MD_post_template.py
Last active December 21, 2015 00:40
Create a new MarkDown post for Pelican-generated blog
"""
author: Khaled Monsoor <k@kmonsoor.com>
modified: 09-Dec-2015
license: The MIT License
"""
import sys
from datetime import datetime
@ttsiodras
ttsiodras / hack.py
Last active August 21, 2017 09:48
I just did something that depending on your viewpoint on coding, is either an insult to God and humanity, or absolutely brilliant.
#
# I inherited a large code base, where hundreds of code paths end up
# calling "common_function_called_in_gazillion_places".
#
# And the need arose for this function to access the HTTP request's
# headers...
#
# What to do? Refactor all the places leading up to here? In a dynamically
# typed language, with no compiler to tell us the places to refactor?
#
@nirzaq
nirzaq / option.txt
Created April 24, 2018 10:07
Available Option
'abandoned',
'beach',
'bike',
'birthday',
'broken',
'breakfast',
'business',
'cake',
'car',
'cat',
@dgerod
dgerod / custom_run.py
Last active June 19, 2019 15:12
The %my_run command execute a script in IPython as %run does but searching the file in the user path in addition to the python path.
# =======================================================================================
# Startup file with magic functions: %my_run, %add_custom_path, %clean_custom_path and
# %show_custom_path, which runs stuff in the python path as well as user specified paths.
#
# The %my_run command executes a script as %run does but searching the script in
# the user path in addition to python path.
#
# ---------------------------------------------------------------------------------------
# This is a modification of the code done by Gaute Hope <gaute.hope@nersc.no> due to
# IPython issue 101
@rodricios
rodricios / summarize.py
Last active November 18, 2020 17:21
Flipboard's summarization algorithm, sort of
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pip install networkx distance pattern
In Flipboard's article[1], they kindly divulge their interpretation
of the summarization technique called LexRank[2].
# ~/.gitconfig from @boblet
# initially based on http://rails.wincent.com/wiki/Git_quickstart
[core]
excludesfile = /Users/oli/.gitignore
legacyheaders = false # >git 1.5
quotepath = false
# http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
pager = less -r
# if ↑ doesn’t work, try: pager = less -+$LESS -FRX
@nuhil
nuhil / js.md
Last active November 20, 2021 18:06
Javascript Handbook
@abernardobr
abernardobr / Install Graphics Magick on CentOS 7
Last active December 21, 2021 22:43
Install Graphics Magick on CentOS 7
# Get Graphics Magick
> cd /
> mkdir /dowload
> cd /download
> wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.gz
> tar -xzvf GraphicsMagick-LATEST.tar.gz
> cd GraphicsMagick-1.3.21 (or the lastest graphics magick)
# Install Graphics Magick
## Get libs
@kmonsoor
kmonsoor / parallel_rss_download.py
Last active February 5, 2022 20:30
Download contents by grabbing links from a given RSS-feed. Works over HTTP,FTP,HTTPS protocol transparently. Currently, works on Linux, Mac OSX, and possibly on other Unix as well. But, _NOT_ on Windows yet
#!/usr/bin/env python2.7
"""
Parallel RSS-Feed Downloader
----------------------------
Download contents by grabbing links from a given RSS-feed.
Works over HTTP,FTP,HTTPS protocol transparently.
Currently, works on Linux, Mac OSX, and possibly on other Unix as well.
But, _NOT_ on Windows * yet.
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()