Skip to content

Instantly share code, notes, and snippets.

View SpotlightKid's full-sized avatar

Christopher Arndt SpotlightKid

View GitHub Profile
@SpotlightKid
SpotlightKid / delay.lua
Created January 21, 2015 22:37
Simple delay with feedback for ProtoplugFX
--[[
name: Simple Delay
description: Simple delay with feedback
author: carndt
--]]
require "include/protoplug"
-- Delay line state
local buf, buflen, writepos, sr
@SpotlightKid
SpotlightKid / jsonify_date.py
Last active August 29, 2015 14:15
Datetime support for JSON en-/decoding.
"""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
"""
@SpotlightKid
SpotlightKid / jsonify.py
Created March 11, 2015 19:30
JSON en-/decoder with support for datetime/date and custom object instances.
# -*- 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
@SpotlightKid
SpotlightKid / getimports.py
Created April 7, 2015 11:41
List names of all imports in all Python files given on command line.
#!/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)
@SpotlightKid
SpotlightKid / ecs_example.py
Last active November 19, 2015 10:41
Example of plumbing needed to use the ecs package
#!/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."""
@SpotlightKid
SpotlightKid / udpserver.py
Last active November 23, 2015 15:21
A simple single-connection, blocking UDP echo server, which listens on IPv4 and IP6 simultaneously
#!/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
@SpotlightKid
SpotlightKid / bobp-python.md
Last active December 2, 2015 20:39 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is always better than functionality." - Pieter Hintjens
@SpotlightKid
SpotlightKid / parse_requirements.py
Last active December 2, 2015 21:11
Read Python dependencies from requirements file and strip off version numbers.
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