Skip to content

Instantly share code, notes, and snippets.

@pawl
pawl / new_django.sh
Created Jan 23, 2020
starting a new django project
View new_django.sh
cd ~
mkdir mysite
virtualenv .venv -p `which python3`
source .venv/bin/activate
pip install django
django-admin startproject mysite
cd mysite
python manage.py startapp myapp
@pawl
pawl / webdav.conf
Last active Jul 5, 2021
Installing nginx webdav server on ubuntu 20.04
View webdav.conf
server {
listen 80;
listen [::]:80;
root /var/dav/webdav_root;
# dav allowed method
dav_methods PUT DELETE MKCOL COPY MOVE;
# Allow current scope perform specified DAV method
dav_ext_methods PROPFIND OPTIONS;
@pawl
pawl / readme.md
Last active Jul 8, 2021
test to see if psycogreen is necessary to run sqlalchemy + gevent + psycopg2 concurrently
View readme.md

This is a test to see if psycogreen is necessary to run sqlalchemy + gevent + psycopg2 concurrently.

benchmark command (concurrency of 10)

ab -n 10 -c 10 127.0.0.1:8080/wait

psychopg2 - sync worker (expecting concurrency of 2)

gunicorn -b 127.0.0.1:8080 -w 2 test:app

@pawl
pawl / pingpong.thrift
Last active Mar 21, 2017
demonstrates issue with thrift service swallowing TTransportException
View pingpong.thrift
service PingPong {
string ping(),
}
@pawl
pawl / empty_in.py
Created Mar 18, 2017
sqlalchemy empty list in_() issue
View empty_in.py
# demonstrates the issue fixed in: https://bitbucket.org/zzzeek/sqlalchemy/issues/3907
from sqlalchemy import create_engine, Column, Integer
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql://root@localhost/test?charset=utf8mb4',
convert_unicode=True,
echo=True)
session = scoped_session(sessionmaker(autocommit=False,
@pawl
pawl / in_loading.py
Last active Dec 28, 2017
Example of a custom "IN()" relationship loading strategy in sqlalchemy
View in_loading.py
from collections import defaultdict
from sqlalchemy import create_engine, Column, ForeignKey, Integer
from sqlalchemy.orm import relationship, scoped_session, sessionmaker
from sqlalchemy.orm.attributes import set_committed_value
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql://root@localhost/test?charset=utf8mb4',
convert_unicode=True,
echo=True)
@pawl
pawl / subquery_nested_loading.py
Created Mar 15, 2017
example of subquery loading using temporary tables and filesort
View subquery_nested_loading.py
from sqlalchemy import create_engine, Column, ForeignKey, Integer
from sqlalchemy.orm import relationship, scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql://root@localhost/test?charset=utf8mb4',
convert_unicode=True,
echo=True)
session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
@pawl
pawl / already_in_session_test.py
Last active Mar 15, 2017
tests whether sqlalchemy automatically uses relations loaded into session
View already_in_session_test.py
from sqlalchemy import create_engine, Column, ForeignKey, Integer
from sqlalchemy.orm import relationship, scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql://root@localhost/test?charset=utf8mb4',
convert_unicode=True,
echo=True)
session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
View in_loading.py
from sqlalchemy import create_engine, Column, ForeignKey, Integer, TEXT
from sqlalchemy.orm import relationship, scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql://root@localhost/test?charset=utf8mb4',
convert_unicode=True,
echo=True)
session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))