Skip to content

Instantly share code, notes, and snippets.

View kootenpv's full-sized avatar

Pascal van Kooten kootenpv

  • Van Kooten AI Solutions / ex-mgnr
  • Utrecht, Netherlands
View GitHub Profile
import pandas as pd
import seaborn as sns
data = pd.read_json("results.jsonl", lines=True)
sns.heatmap(data.pivot("astroid", "pylint", "testpd.py"))
@kootenpv
kootenpv / model_view.py
Last active March 31, 2018 19:59
MyModelView including a search limited to a field using syntax like `username:kootenpv`
# Authors: Leonid R. and Pascal van Kooten
from flask_admin.contrib.sqla import ModelView
from flask_admin.contrib.sqla import tools
from sqlalchemy import or_
from sqlalchemy.sql.expression import cast
from sqlalchemy import Unicode
class MyModelView(ModelView):
# modifies existing _apply_search
@kootenpv
kootenpv / README.md
Last active April 15, 2022 18:40
Advanced Automatic Brightness on Macbook running Arch Linux

Compile screensy:

gcc -O3 -I/usr/include/cairo/ -lX11 -lcairo screensy.cpp -o screensy

I have to run to be able to write brightness changes:

sudo setpci -v -H1 -s 00:01.00 BRIDGE_CONTROL=0

Then run:

@kootenpv
kootenpv / auto_brightness.py
Created May 11, 2017 08:38
Auto brightness hack for OSX
# add keyboard brightness
import time
from datetime import datetime
SLEEP_TIME = 0.5
def write(n):
with open("/sys/class/backlight/gmux_backlight/brightness", "w") as f:
#print("new", n)
@kootenpv
kootenpv / github_orgy.py
Last active December 13, 2017 07:55
As it is impossible to find out about new repos created by an org, this awkwardly named script exists.
""" github_orgy -- monitor github organizations for new repos.
Usage:
python3.5 github_orgy.py deepmind tensorflow facebookresearch google watson-developer-cloud
Or with cron:
@hourly /usr/bin/python github_orgy.py deepmind tensorflow facebookresearch google watson-developer-cloud
"""
import time
import os
@kootenpv
kootenpv / evolutionary_search.py
Created April 14, 2017 08:31
evolutionary_search.py
# -*- coding: utf-8 -*-
import warnings
import numpy as np
import random
from deap import base, creator, tools, algorithms
from multiprocessing import Pool
from sklearn.base import clone, is_classifier
from sklearn.model_selection import check_cv
from sklearn.grid_search import BaseSearchCV
from sklearn.metrics.scorer import check_scoring
import sys
import time
def err(*args):
sys.stderr.write(', '.join([str(arg) for arg in args]) + "\n")
def move_to_dir(old, new):
if old[0] < new[0]:
def move_to_dir(old, new):
if old[0] < new[0]:
return "RIGHT"
if old[1] < new[1]:
return "DOWN"
if old[0] > new[0]:
return "LEFT"
return "UP"
def move_to_dir(old, new):
"""Converts using e.g. old position (1,1) and new position (2, 1) to a direction (RIGHT)"""
if old[0] < new[0]:
return "RIGHT"
if old[1] < new[1]:
return "DOWN"
if old[0] > new[0]:
return "LEFT"
return "UP"
@kootenpv
kootenpv / re.scanner_crash.py
Created July 30, 2016 17:00
malloc: *** error in re for Python 3.5
import re
def fn():
scanner = re.Scanner([
(r'([0-9]{2}):([0-9]{2}):([0-9]{2})', lambda y, x: x),
(r'.', lambda y, x: x)
])
return scanner.scan("10:10:10")
# This works on Python 2.7, but not on Python 3.5