Skip to content

Instantly share code, notes, and snippets.

devdave /
Created Dec 13, 2011
Flask HTML form array inputs
from flask import Flask
from flask import request
app = Flask(__name__)
#Normally this would be an external file like object, but here
#it's inlined
<title>Flask Form</title>
devdave /
Last active Apr 8, 2020
sqlalchemy alembic data migration example
"""Convert lat/long from float to int
Revision ID: b020841d98e4
Revises: 6e741a21efc8
Create Date: 2019-07-10 20:03:38.282042
Given a source table like
class GPS(Base):
# $--RMC, hhmmss.sss, x, llll.lll, a, yyyyy.yyy, a, x.x, u.u, xxxxxx,, , v * hh < CR > < LF >
devdave /
Last active Feb 1, 2020
Example code for having routed classes in Flask. These are different than View Classes or Blueprints as it allows exposing individual methods to the routing system
Example code
import typing as T
from flask import request, redirect
from ..lib.cls_endpoint import CLSEndpointFlask
devdave / Doctrin2Search.php
Created Jun 21, 2011
Semi-dynamic Doctrine2 search function
View Doctrin2Search.php
function searchCriteria($criteria){
$cleanCritera = array();
foreach($criteria as $key => $value){
if( isset( $this->_class->fieldNames[$key] ) && !empty($value) ){
$cleanCritera[$key] = $value;
devdave /
Last active Jul 6, 2019
non-blocking python subprocess
import subprocess
import threading
import queue
import os
import time
class Runner(object):
def __init__(self, cmd: []):
self.cmd = cmd
devdave /
Created Jun 4, 2019
Slimmed down twisted compatible reloader
A flask like reloader function for use with txweb
In user script it must follow the pattern
def main():
my main func that starts twisted
if __name__ == "__main__":
devdave / background.js
Created Oct 16, 2018 — forked from akirattii/background.js
Message passing of Chrome Extension example
View background.js
* onMessage from the extension or tab (a content script)
function(request, sender, sendResponse) {
if (request.cmd == "any command") {
sendResponse({ result: "any response from background" });
} else {
sendResponse({ result: "error", message: `Invalid 'cmd'` });
devdave / notes.txt
Created Sep 18, 2018
Virtualenvwrapper-win post project hook to make a komodo project file.
View notes.txt
I've been using Komodo IDE since the mid-90's but I AM NOT AN ACTIVE STATE EMPLOYEE. This is on your ownware with a I don't care license.
No warranty of the code is offered, read the code, and only install it if you understand what it does.
Pre-retirement, it was my in-house rule that all projects used virtualenv. It made it easier to `pip freeze > requirements.txt`
dependancies. Last thing I ever wanted to experience was having a "Oh my god everything is broken" call and spend an hour reverse
devdave /
Created Sep 14, 2018
N America cartopy blank using Natural earth for fill in
A demonstration of some of the built-in Natural Earth features found
in cartopy.
modified from caropy examples/
__tags__ = ['Lines and polygons']
devdave / run.js
Created Apr 9, 2018 — forked from ChuckJHardy/run.js
Express Server for ZeroMQ, and Angular.js
View run.js
'use strict';
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
path = require('path'),
io = require('').listen(server),
fs = require('fs'),
zmq = require('zmq'),