Skip to content

Instantly share code, notes, and snippets.

'''
Implementation of Fastfood (Le, Sarlos, and Smola, ICML 2013).
Primarily by @esc (Valentin Haenel) and felixmaximilian
from https://github.com/scikit-learn/scikit-learn/pull/3665.
Modified by @dougalsutherland.
FHT implementation was "inspired by" https://github.com/nbarbey/fht.
'''
@lucgiffon
lucgiffon / gist:f874c43a0c25ff89ac17611c41cefbb0
Created June 29, 2017 08:42 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
def mpl_layout(rows_cols, axis=0):
"""
Description:
------------
Prepare matplotlib layout for complexe layouts.
Exemple:
--------
If you have done 6 independant experiences with graphes but you want to show them all in one figure with 2 graphes on each row
and 3 rows of graphes. Moreover, you want to display the graphes by lines, eg: on each row, you want 2 consecutive experiences.
def singleton(cls):
"""
Simple singleton implementation.
Usage:
@singleton
class A:
pass
@lucgiffon
lucgiffon / dis_warns.py
Created April 27, 2017 13:59
piece pf cpde that disable warnings
def warn(*args, **kwargs):
pass
import warnings
warnings.warn = warn
@lucgiffon
lucgiffon / main.py
Last active April 18, 2017 21:23
Evolution du pourcentage de vote en fonction du pourcentage total de vote utile gagné par macron
from collections import OrderedDict
import numpy as np
import matplotlib.pyplot as plt
from pprint import pprint
# data source : https://fr.wikipedia.org/wiki/Liste_de_sondages_sur_l%27%C3%A9lection_pr%C3%A9sidentielle_fran%C3%A7aise_de_2017#Avril_2017
scores_fillon = [
19.5,
18.5,
21,
19,
@lucgiffon
lucgiffon / storebyext.sh
Last active April 14, 2017 21:46
Store the files in current directory with respect to their extensions if they have
search_dir='.'
for entry in "$search_dir"/*; do
# entry = la/bas/truc.zip
filename=$(basename "$entry")
# filename = truc.zip
extension=$([[ "$filename" = *.* ]] && echo "${filename##*.}" || echo '')
# extension = zip
re_nbr='^[0-9]+$'
if ! [[ $extension =~ $re_nbr ]] && ! [[ -z "$extension" ]] ; then
if ! [[ -d "$extension" ]] ; then