Skip to content

Instantly share code, notes, and snippets.

Avatar

Chad chadmiller

View GitHub Profile
View 08-2-redux
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 / bitwarden-copy-items-from-org-to-personal-folder
Created Mar 1, 2021
An itermediate step that almost lets you effectively un-share Bitwarden items shared to an Organization
View bitwarden-copy-items-from-org-to-personal-folder
#!/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"
View trips
#!/usr/bin/env python3
from collections import namedtuple
Trip = namedtuple("Trip", "name expenses lodgingcost bagcost")
def prompt(message):
return input(message + " => ").strip()
View generate_middle_c
#!/bin/bash
""":"
# Run a pulseaudio wrapper. Fancy ugly hack.
exec padsp -d python3 "$0" "$@"
"""
import struct
import numpy
from scipy import signal
View ayan-url-example.py
#!/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 Nov 5, 2017
xps13 touchpad xinput setup
View .xsessionrc
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" \
View gist:d948eb0922de19c62bb4d2788ba2d4ff
$ 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
View message_wrapping.py
#!/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
View gist:03cd6e86051c3ed656a2daff91e6bf61
### 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
View mdupont-cgv-coord-extract
xscale, yscale = [7957825782578148e-20,4393119311931213e-20]
xtranslate, ytranslate = [-81.658611,28.346828]
for arc in arcs:
xd, yd = arc.pop(0)
print([(((x+xd)*xscale+xtranslate), ((y+yd)*yscale+ytranslate)) for x, y in arc])