Skip to content

Instantly share code, notes, and snippets.

Avatar

Samuel John samueljohn

View GitHub Profile
@pbugnion
pbugnion / ipython_notebook_in_git.md
Last active Jun 4, 2021
Keeping IPython notebooks under Git version control
View ipython_notebook_in_git.md

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

@senko
senko / maybe.py
Last active Mar 19, 2021
A Pythonic implementation of the Maybe monad
View maybe.py
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@mblondel
mblondel / matrix_sketch.py
Last active Feb 13, 2019
Frequent directions algorithm for matrix sketching.
View matrix_sketch.py
# (C) Mathieu Blondel, November 2013
# License: BSD 3 clause
import numpy as np
from scipy.linalg import svd
def frequent_directions(A, ell, verbose=False):
"""
Return the sketch of matrix A.