A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is always better than functionality." - Pieter Hintjens
--[[ | |
name: Simple Delay | |
description: Simple delay with feedback | |
author: carndt | |
--]] | |
require "include/protoplug" | |
-- Delay line state | |
local buf, buflen, writepos, sr |
"""Datetime support for JSON en-/decoding. | |
Example usage:: | |
>>> dumps({'timestamp': datetime.datetime.now()}) | |
'{"timestamp": "2015-02-11T13:44:41.504885"}' | |
See also http://stackoverflow.com/questions/455580/json-datetime-between-python-and-javascript/3235787#3235787 | |
""" |
# -*- coding: utf-8 -*- | |
# | |
# jsonify.py | |
# | |
"""JSON en-/decoder with support for datetime/date and custom object instances. | |
Encodes/decodes date/datetime instances to/from ISO-8601 format or, if the | |
python-dateutil_ package is installed, any format that ``dateutil.parser`` | |
understands. |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""Flask extension to use walrus.Database from your Flask app. | |
Example usage:: | |
from flask import Flask, render_template | |
from flask_walrus import WalrusDatabase | |
from walrus.models import Model, TextField |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""List names of all imports in all Python files given on command line.""" | |
import sys | |
import ast | |
NODE_TYPES = (ast.Import, ast.ImportFrom) |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import time | |
from ecs import Component, Entity, EntityManager, System, SystemManager | |
class MovementSystem(System): | |
"""Movement system to update position of Movable components.""" |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# udpserver.py | |
# | |
"""A minimal test UDP (echo) server supporting IPv4 and IPv6.""" | |
import argparse | |
import logging | |
import socket |
def parse_requirements(requirements, ignore=('setuptools',)): | |
"""Read dependencies from file and strip off version numbers.""" | |
with open(requirements) as f: | |
packages = set() | |
for line in f: | |
line = line.strip() | |
if line.startswith(('#', '-r', '--')): | |
continue | |
if '#egg=' in line: | |
pkg = line.split('#egg=')[1] |
#!/bin/sh | |
# Inits a project made with the django-cms-boilerplate | |
# Requires virtualenvwrapper and pip | |
# Create virtualenv if no active | |
if [ "$VIRTUAL_ENV" == "" ]; then | |
echo "Creating virtualenv... Name?" | |
read venvname | |
source virtualenvwrapper.sh | |
mkvirtualenv --no-site-packages $venvname | |
workon $venvname |