Skip to content

Instantly share code, notes, and snippets.

View magnusnissel's full-sized avatar

Magnus Nissel magnusnissel

  • Wiesloch, Germany
View GitHub Profile
@magnusnissel
magnusnissel / kontrol.py
Created October 27, 2017 10:13 — forked from tolnem/kontrol.py
Reading midi input from nanoKontrol 2 in python, using python-rtmidi and jack-audio
#!/usr/bin/python
import rtmidi, time
buttons = {
58: 'track_left',
59: 'track_right',
46: 'cycle',
60: 'marker_set',
61: 'marker_left',
@magnusnissel
magnusnissel / flask-uWSGI-nginx.md
Created September 12, 2017 08:49 — forked from bluekvirus/flask-uWSGI-nginx.md
How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04+

How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04

@credit Yan Zhu (https://github.com/nina-zhu)

Introduction

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions, it can help you get your Python application or website off the ground. Flask includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server is required.

In this guide, we will demonstrate how to install and configure some components on Ubuntu 14.04 to support and serve Flask applications. We will configure the uWSGI application container server to interface with our applications. We will then set up Nginx to reverse proxy to uWSGI, giving us access to its security and performance features to serve our apps.

Prerequisites and Goals

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@magnusnissel
magnusnissel / lineups.py
Created July 21, 2017 19:02
Initial basic attempt at lineup parsing (from NBA play-by-play logs)
import os
import glob
import pandas as pd
def check_lineup(r):
a_cols = ["A1", "A2", "A3", "A4", "A5"]
h_cols = ["H1", "H2", "H3", "H4", "H5"]
a = [True for p in r[a_cols] if p != ""]
h = [True for p in r[h_cols] if p != ""]
def compare_on_dataset(data, target_variable=None, lr=0.001, patience=150):
from IPython.display import display
df = (
pd.read_csv(data)
# Rename columns to lowercase and underscores
.pipe(lambda d: d.rename(columns={
k: v for k, v in zip(
@magnusnissel
magnusnissel / nba-twitter-lists.py
Last active October 4, 2016 13:57
Creating the NBA Big List
import tweepy
import os
import sys
import datetime
import pandas as pd
import glob
import time
TWITTER_LIST_DIR ="PATH/TO/THE/LIST/FOLDER"
@magnusnissel
magnusnissel / dataframe_as_image.R
Last active August 10, 2016 13:46
A small helper function around webshot and knitr::kable to save the HTML representation of a dataframe as an image file (.png)
#This function depends on the knitr and webshot packages, uncomment lines 2-6 below if you need to install them first
#install.packages("knitr")
#install.packages("devtools")
#library(devtools)
#devtools::install_github("wch/webshot")
#webshot::install_phantomjs()
#Feel free to move the library() calls for knitr and webshot outside the function.
@magnusnissel
magnusnissel / tweet_dumper.py
Created February 19, 2016 13:08 — forked from yanofsky/LICENSE
A script to download all of a user's tweets into a csv
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
#Twitter API credentials
consumer_key = ""
consumer_secret = ""
access_key = ""
@magnusnissel
magnusnissel / guess_syllables.py
Created August 19, 2015 12:28
A Python 3 functions that tries to guess the number of syllables in an English token
import re
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@magnusnissel
magnusnissel / labmt_scorer.py
Last active August 29, 2015 14:25
A simple class to score text with LabMT and pandas based on the code at http://neuro.imm.dtu.dk/wiki/LabMT
import pandas as pd
import re
class LabMTScorer():
""" A simple class to score text with LabMT and pandas,
based on the example provided by Finn Årup Nielsen
at http://neuro.imm.dtu.dk/wiki/LabMT """