Skip to content

Instantly share code, notes, and snippets.

Avatar

René otech-nl

View GitHub Profile
@otech-nl
otech-nl / init.el
Last active February 15, 2017 09:14
My emacs init file
View init.el
;; ====================================
;; Packages
(setq repository-packages
'(
auto-complete
ac-html
feature-mode
markdown-mode
php-mode
@otech-nl
otech-nl / git.sh
Last active December 1, 2016 11:26
git tips
View git.sh
# extract a distributable archive, with changed files only (archive name derived from directory name and date):
alias git-diff="git diff --name-only HEAD^1 HEAD | zip ../${PWD##*/}-`date +%Y%m%d`-diff.zip -@"
# archive the current state:
alias git-archive="git archive --format=zip HEAD >../${PWD##*/}-`date +%Y%m%d`.zip"
# silence annoying CLRF warnings with:
git config --global core.autocrlf false
# remember credentials
@otech-nl
otech-nl / .bashrc
Last active November 23, 2016 13:44
python on MacOS
View .bashrc
# enforce UTF-8 even if defaultencoding says 'ascii'
export PYTHONIOENCODING=utf-8
# make sure pip only works in a virtualenv
export PIP_REQUIRE_VIRTUALENV=true
# unless...
gpip() {
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
@otech-nl
otech-nl / flask-ptvsd.py
Last active September 22, 2016 08:36
Remote debugging (e.g. using Vagrant) with Flask and Visual Studio Code
View flask-ptvsd.py
if app.debug:
if environ.get("WERKZEUG_RUN_MAIN") == "true": # check to prevent "Address already in use"
import ptvsd
ptvsd.enable_attach("my_secret")
@otech-nl
otech-nl / sqlalchemy-inspect.py
Last active July 18, 2016 12:48
Inspect a SQLAlchemy Model
View sqlalchemy-inspect.py
# http://docs.sqlalchemy.org/en/latest/faq/ormconfiguration.html#how-do-i-get-a-list-of-all-columns-relationships-mapped-attributes-etc-given-a-mapped-class
from sqlalchemy import inspect
from models import *
mapper = inspect(Task)
for f in 'attrs column_attrs relationships all_orm_descriptors columns'.split():
print '%s:'% f
for x in getattr(mapper, f):
print ' %s' % x
@otech-nl
otech-nl / top2000.py
Created March 22, 2016 15:58
This script takes the Radio 2 Top 2000 and analyses artist performance
View top2000.py
''' This script takes the Radio 2 Top 2000 (http://www.nporadio2.nl/top2000)
and analyses artist performance:
- count: number of occurences of artist in list
- score: number of points (#1 song gets 2000 point, #2 song gets 1999 etc.)
store input file as CSV with ;-delimiter in 'TOP-2000-2015.csv'
'''
import csv
import sys
@otech-nl
otech-nl / requirements.py
Created March 22, 2016 15:57
script to add level numbering to alias of EA requirements
View requirements.py
""" script to add level numbering to alias of EA requirements
get csv from EA with the query below:
select Object_ID, ParentID, Name, Alias, Version, Effort, Phase, TPos
from t_object where Object_Type="Requirement"
"""
import csv
import sys