Skip to content

Instantly share code, notes, and snippets.

View daanzu's full-sized avatar

David Zurow daanzu

View GitHub Profile
@todbot
todbot / udp_recv_code.py
Last active October 22, 2023 13:30
UDP sender and receiver in CircuitPython
# udp_recv_code.py -- receive UDP messages from any receiver, can be another CircuitPython device
# 24 Aug 2022 - @todbot / Tod Kurt
# cribbing from code at https://github.com/adafruit/circuitpython/blob/main/tests/circuitpython-manual/socketpool/datagram/ntp.py
import time, wifi, socketpool
from secrets import secrets
print("Connecting to WiFi...")
wifi.radio.connect(ssid=secrets['ssid'],password=secrets['password'])
print("my IP addr:", wifi.radio.ipv4_address)
pool = socketpool.SocketPool(wifi.radio)
@idelem
idelem / titleUrlMarkdownClip.js
Last active March 12, 2024 02:01 — forked from bradleybossard/titleUrlMarkdownClip.js
Bookmarklet to copy current page title and url in Markdown format to clipboard, like [title](url) - Usual for posting links to resources in README.md files
javascript:(function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
from __future__ import print_function, unicode_literals
from ctypes import windll
from dragonfly import (ActionBase, Choice, Grammar, IntegerRef, Key,
MappingRule, Mouse, Pause, Repeat)
from dragonfly.actions.keyboard import Keyboard, KeySymbols
KEYBOARD = Keyboard()
from dragonfly import *
import nsformat
dictation_length = [] # for "scratch that" purposes
input_state = None
""" Note: if you pass in the input state into the function using the function action rather than just accessing it
from within the function using the fact that it is in global scope, the input state will not be updated
when you run the dictation command multiple times
To see what I mean note that in contrast to the approach here, the approach taken
at the following link does not update the state after each dictation utterance
------------------
Grammar(chrome): 3 rules (1 exported, 0 imported):
- ChromeRule(chrome) 1571
- Alternative(...) 1570
- Compound('[<click_by_voice_options>] <numbers>') 376
- Sequence(...) 375
- Optional(...) 18
- Choice(..., name='click_by_voice_options') 17
- Compound('click') 2 (+ 1 trivial direct child)
- Compound('copy') 2 (+ 1 trivial direct child)
#
# This file is a command-module for Dragonfly.
# (c) Copyright 2008 by Christo Butcher
# Licensed under the LGPL, see <http://www.gnu.org/licenses/>
#
"""
Command-module for Chrome
"""
@vadimkantorov
vadimkantorov / split_audio_by_silence.py
Last active September 5, 2023 19:16
Python script using webrtcvad for splitting an audio file into voice segments
# Usage: python3 split_audio_by_silence.py -i input_audio.m4a -o segments
# will save segments in mp3 format into the segments directory
# based on https://github.com/mozilla/DeepSpeech/tree/master/examples/vad_transcriber
# Dependencies: webrtcvad
import os
import argparse
import collections
import subprocess
import webrtcvad
@caspark
caspark / complexity.py
Created April 19, 2019 14:52
Dragonfly grammar visualizer & complexity debugging helpers
# to get started, try `print get_grammar_complexity_tree(some_grammar, threshold=5)`.
# If you don't get any interesting output, turn up the threshold (max depth visualized) to something like 7 or 10 :)
class ComplexityNode(object):
def __init__(self, item):
self.item = item
self.children = []
self.total_descendents = 1
@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@awni
awni / ctc_decoder.py
Last active April 18, 2024 19:14
Example CTC Decoder in Python
"""
Author: Awni Hannun
This is an example CTC decoder written in Python. The code is
intended to be a simple example and is not designed to be
especially efficient.
The algorithm is a prefix beam search for a model trained
with the CTC loss function.