Skip to content

Instantly share code, notes, and snippets.

View chrisvoncsefalvay's full-sized avatar
🥼
doing science & still alive ;)

Chris von Csefalvay chrisvoncsefalvay

🥼
doing science & still alive ;)
View GitHub Profile
@chrisvoncsefalvay
chrisvoncsefalvay / with_sql_session.py
Created October 26, 2019 01:39 — forked from danallison/with_sql_session.py
Connect to Postgresql locally or through SSH tunnel
from sshtunnel import SSHTunnelForwarder
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from functools import wraps
# secrets.py contains credentials, etc.
import secrets
def get_engine_for_port(port):
return create_engine('postgresql://{user}:{password}@{host}:{port}/{db}'.format(

Configuring Nginx to serve SSL content is straight forward, once you have your certificate and key ready:

server { 
    listen 443 default ssl;
    root /path/to/source;
    server_name mydomain;

    ssl_certificate      /path/to/cert;
    ssl_certificate_key  /path/to/key;
@chrisvoncsefalvay
chrisvoncsefalvay / nginx.conf
Created November 6, 2017 11:57 — forked from lciolecki/nginx.conf
Nginx config for django rest framework + angular application
server {
listen 80;
listen 443 ssl;
server_name your-domain.com;
charset utf-8;
client_max_body_size 32M;
root /project/static;
index index.html;
@chrisvoncsefalvay
chrisvoncsefalvay / pipeline.py
Created May 24, 2017 18:53 — forked from sampsyo/pipeline.py
multithreaded pipelines for Python coroutines
"""Simple but robust implementation of generator/coroutine-based
pipelines in Python. The pipelines may be run either sequentially
(single-threaded) or in parallel (one thread per pipeline stage).
This implementation supports pipeline bubbles (indications that the
processing for a certain item should abort). To use them, yield the
BUBBLE constant from any stage coroutine except the last.
In the parallel case, the implementation transparently handles thread
shutdown when the processing is complete and when a stage raises an
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test