Skip to content

Instantly share code, notes, and snippets.

View chadmiller's full-sized avatar

Chad chadmiller

View GitHub Profile
### database api, via HTTP(s), REST
## GET only
/api/1/get_directories
# out, text/json: { "Foo Foo": "long description", "Street Art": "Temporary and Semipermanent art" }
## GET only
/api/1/get_points_by_place/(\d+)/(\d+)/(\w+)
# retrieves JSON of closest 1000 items
#!/usr/bin/env python3
import doctest
import string
def break_into_chunks(message, allowance, characters_that_count_for_one, characters_that_count_for_two):
cursor = 0
allotted = 0
@chadmiller
chadmiller / gist:d948eb0922de19c62bb4d2788ba2d4ff
Created November 5, 2017 03:13
xps13 xinput touchpad properties
$ xinput list-props 11
Device 'DLL075B:01 06CB:76AF Touchpad':
Device Enabled (137): 1
Coordinate Transformation Matrix (139): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (260): 1
Device Accel Constant Deceleration (261): 2.500000
Device Accel Adaptive Deceleration (262): 1.000000
Device Accel Velocity Scaling (263): 12.500000
Synaptics Edges (264): 48, 1167, 36, 507
Synaptics Finger (265): 25, 30, 0
@chadmiller
chadmiller / ayan-url-example.py
Last active June 10, 2018 21:14
OH HAI AYAN
#!/usr/bin/env python3
from urllib import request, error as urlliberror
from bs4 import BeautifulSoup as BS
import multiprocessing
from contextlib import suppress
def get_title(url):
with suppress(urlliberror.HTTPError):
page = request.urlopen(url)
@chadmiller
chadmiller / .xsessionrc
Created November 5, 2017 03:14
xps13 touchpad xinput setup
xinput set-prop "DLL075B:01 06CB:76AF Touchpad" "Synaptics Tap Time" 0
xinput set-prop "DLL075B:01 06CB:76AF Touchpad" "Synaptics Palm Detection" 1
xinput set-prop "DLL075B:01 06CB:76AF Touchpad" "Synaptics Click Action" 1 3 2
xinput set-prop "DLL075B:01 06CB:76AF Touchpad" "Synaptics Scrolling Distance" -27 -27
height=$((680-1))
width=$((1216-1))
to_edge=0
xinput set-prop "DLL075B:01 06CB:76AF Touchpad" "Synaptics Soft Button Areas" \
#!/bin/bash
""":"
# Run a pulseaudio wrapper. Fancy ugly hack.
exec padsp -d python3 "$0" "$@"
"""
import struct
import numpy
from scipy import signal
#!/usr/bin/env python3
from collections import namedtuple
Trip = namedtuple("Trip", "name expenses lodgingcost bagcost")
def prompt(message):
return input(message + " => ").strip()
@chadmiller
chadmiller / bitwarden-copy-items-from-org-to-personal-folder
Created March 1, 2021 23:00
An itermediate step that almost lets you effectively un-share Bitwarden items shared to an Organization
#!/bin/bash
# One can not currently un-share shared items to an organization in Bitwarden.
#
# A workaround is to copy them back to yourself, and then remove them from the organization.
#
# Here's a simple, dumb script that creates a personal folder, and copies org items to it.
#
# You need the bitwarden command-line (CLI) tool, and to have previously run "bw login"
def get_wires(possibilities, of_length, after_removing, is_strict_subset=False):
found = list(wires for wires in possibilities if len(wires - after_removing) == of_length)
if is_strict_subset:
found = list(wires for wires in found if len(after_removing - wires) == 0)
possibilities.remove(found[0]) # remove from future consideration
return found[0]
def decipher_samples(samples):
"""
@chadmiller
chadmiller / getnifs.py
Last active February 26, 2022 17:00 — forked from provegard/getnifs.py
#!/usr/bin/python
# Based on https://gist.github.com/provegard/1536682, which was
# Based on getifaddrs.py from pydlnadms [http://code.google.com/p/pydlnadms/].
# Only tested on Linux!
from socket import AF_INET, AF_INET6, inet_ntop
from ctypes import (
Structure, Union, POINTER,
pointer, get_errno, cast,