Skip to content

Instantly share code, notes, and snippets.

View kheffah's full-sized avatar

Mohamed Amgad Tageldin kheffah

View GitHub Profile
@kheffah
kheffah / constrained_agglomerative_clustering.py
Last active May 12, 2020 03:11
Agglomerative clustering with preventing certain leafs from being clumped together in the same node.
import matplotlib.pylab as plt
import numpy as np
from scipy.cluster.hierarchy import dendrogram
from sklearn.cluster import AgglomerativeClustering
class ConstrainedAgglomerativeClustering(object):
def __init__(
self, linkage_thresh, linkage='complete',
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kheffah
kheffah / .screenrc
Created November 10, 2019 02:03 — forked from joaopizani/.screenrc
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
@kheffah
kheffah / beautiful_idiomatic_python.md
Created February 26, 2017 19:42 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: