Skip to content

Instantly share code, notes, and snippets.

devdave / Speech Recognition.ahk
Created Jun 30, 2022 — forked from Uberi/Speech Recognition.ahk
Speech recognition with Microsoft's SAPI. A simple SpeechRecognizer class provides a quick and easy way to use speech recognition in your scripts. Inspired by some [prototype code]( made a long time ago.
View Speech Recognition.ahk
#Warn All
#Warn LocalSameAsGlobal, Off
Speech Recognition
A class providing access to Microsoft's SAPI. Requires the SAPI SDK.
devdave /
Created May 29, 2022 — forked from DarinM223/
Rust concept explanations

My explanation of the main concepts in Rust

There are three main concepts with Rust:

  1. Ownership (only one variable "owns" the data at one time, and the owner is in charge of deallocating)
  2. Borrowing (you can borrow a reference to an owned variable)
  3. Lifetimes (all data keeps track of when it will be destroyed)

These are fairly simple concepts, but they are often counter-intuitive to concepts in other languages, so I wanted to give a shot at

devdave / nde_winamp_format.txt
Created Apr 22, 2022
Winamp media library NDE (Nullsoft Database Engine) format
View nde_winamp_format.txt
Nullsoft Database Engine Format Specifications v1.0
1. Tables
devdave / gist:86caf21b18e2a9c35ad451bf4e3ff762
Created Sep 4, 2021 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
View gist:86caf21b18e2a9c35ad451bf4e3ff762
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()
devdave /
Created Aug 16, 2021 — forked from seanjensengrey/
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes.

Based on (dead) which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes
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 /
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 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'` });