Skip to content

Instantly share code, notes, and snippets.

View flavianh's full-sized avatar

Flavian Hautbois flavianh

View GitHub Profile
@flavianh
flavianh / gitconfig.ini
Created March 29, 2020 14:03 — forked from tdd/gitconfig.ini
Nice, useful global Git configuration
[user]
name = Flavian Hautbois
email = flavian@apricity.life
[color]
# Enable colors in color-supporting terminals
ui = auto
[alias]
# List available aliases
aliases = !git config --get-regexp alias | sed -re 's/alias\\.(\\S*)\\s(.*)$/\\1 = \\2/g'
# Command shortcuts
def catch_exceptions(logger):
"""Decorate a function with @catch_exceptions(logger) to log an exception raised by the decorated function."""
def _catch_exceptions(func):
@functools.wraps(func)
def wrapper_decorator(*args, **kwargs):
try:
value = func(*args, **kwargs)
except Exception as exc:
logger.exception({
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
javascript:function clickOnPrevious(e){$(".js-showPreviousButton").click(),e()}function clickOnNext(e){$(".js-showNextButton").click(),e()}function select(e,t){$(e).click(),t()}function getViews(e,t){console.log(`Getting views for article ${$(e).text()}`),$(".bargraph-bar").each((t,a)=>{var n=$(e).text(),s=a.__data__,c=dateToString(new Date(s.time)),o=Math.floor(s.value),i=views.find(e=>e.date===c);i?i[n]=o:views.push({date:dateToString(new Date(s.time)),[n]:o})}),t()}function dateToString(e){return e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate()}function download(e,t){var a=document.createElement("a");if(a.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(t)),a.setAttribute("download",e),document.createEvent){var n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),a.dispatchEvent(n)}else a.click()}function delay(e,t){console.log(`waiting ${e/1e3}`),setTimeout(()=>{t()},e)}function parseAndDownload(){var e=Papa.unparse(views);download("views-per-article-"+dateToString(n
title = Div(text='<h1 style="text-align: center">Kickstarter Dashboard</h1>')
# This looks better than the multiselect widget
select = CheckboxButtonGroup(labels=CATEGORIES)
select.on_click(filter_categories)
hover_usd_vs_date = HoverTool(tooltips=[
("Name", "@name"),
("State", "@state"),
])
sources_usd_vs_date = {state: ColumnDataSource({
'x': [],
'y': [],
'name': [],
'state': [],
}) for state in STATES}
source_num_categories = ColumnDataSource(data={
'categories': CATEGORIES
def filter_categories(indexes):
categories_filtered = [CATEGORIES[ind] for ind in indexes] if indexes != [] else CATEGORIES
update_num_categories_source(categories_filtered, force_categories=True)
update_usd_vs_date_source(categories_filtered, force_categories=True)
def update_usd_vs_date_source(categories=None, force_categories=False):
# To get the current state of the categories
if categories is None:
categories = source_num_categories.data['categories']
from bokeh.core.properties import value
from bokeh.events import Reset
from bokeh.events import SelectionGeometry
from bokeh.layouts import column
from bokeh.models import ColumnDataSource
from bokeh.models import HoverTool
from bokeh.models import NumeralTickFormatter
from bokeh.models.widgets import CheckboxButtonGroup
from bokeh.models.widgets import Div
from bokeh.plotting import figure
@flavianh
flavianh / dictionary.csv
Last active January 28, 2018 17:48
Kaggle dictionary
response value questionNum
Homme 1 Q1
Femme 2 Q1
Autre 3 Q1
Q1
Etats-Unis 1 Q3
Inde 2 Q3
Autre 3 Q3
Russie 4 Q3
Grande Bretagne 5 Q3
@flavianh
flavianh / how.csv
Last active January 12, 2018 23:24
Kaggle state of data science
We can't make this file beautiful and searchable because it's too large.
"Q76","Q5","Q54","Q57","Q58","Q47","Q8","Qemp","QfindingWork","Qlang","Q55"
"6,34,28","1","13","8,11,14,19","4,10,3,17,2","7,5,6","1","1","3","3","1,3,7"
,"2","1","1","4,7",,,"2",,,"1"
,"2","2","9,8,1,2,4","8,6,12",,,"2","2",,"1"
"23,6,22,13,32,12,29,11,15,21,10,1,2,17,42,3,8","3","1","6,8,11,12,10,2,5","1","3,2","1","1",,"1","4"
"9,4,11,1,2,5","1","1","9,11,1,7","10,19,3","1","1","1","6","1","5"
"4,1,3,5","1","1","1,2,3,7","5","4,1,6","1","1","1","2","1,4"
"9,22,13,12,10,2,7","1","2","9,6,1,5,7",,"4,1","1","1","7","3","1"
,"1","3","8,1,2,3,4","4,7,11",,"2","2","7",,"1,5,2,6"
"3","1","1","6,17,11,12,1,16,15,2,4","4,13,11","2","1","1","2",,"3"