(Create a symlink pytest for py.test)
pytest [options] [file_or_dir] [file_or_dir] ...
Help:
def attach_dyn_prop(instance, prop_name, prop_fn): | |
"""Attach prop_fn to instance with name prop_name. | |
Assumes that prop_fn takes self as an argument. | |
Reference: https://stackoverflow.com/a/1355444/509706 | |
""" | |
class_name = instance.__class__.__name__ + 'Child' | |
child_class = type(class_name, (instance.__class__,), {prop_name: property(prop_fn)}) |
RUN ["apt-get", "update"] | |
RUN ["apt-get", "install", "-y", "zsh"] | |
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true | |
# docker exec -it my-app-container /bin/zsh |
import io | |
from flask import Flask, send_file | |
app = Flask(__name__) | |
@app.route('/logo.jpg') | |
def logo(): | |
"""Serves the logo image.""" | |
with open("logo.jpg", 'rb') as bites: |
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
// paulcode.com | |
// tidy-html5 config file (mine's named "tidy.conf") | |
// tidy documentation is here: http://tidy.sourceforge.net/#docs | |
// tidy-html5 documentation here: http://w3c.github.io/tidy-html5/quickref.html#drop-empty-elements | |
join-classes: no | |
logical-emphasis: no | |
drop-empty-elements: no | |
anchor-as-name: no | |
doctype: auto |
def get_count(q): | |
count_q = q.statement.with_only_columns([func.count()]).order_by(None) | |
count = q.session.execute(count_q).scalar() | |
return count | |
q = session.query(TestModel).filter(...).order_by(...) | |
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ... | |
print q.count() |
Having trouble installing the latest stable version of tmux?
I know, official package for your OS/distro is outdated and you just want the newest version of tmux.
Well, this script should save you some time with that.