Skip to content

Instantly share code, notes, and snippets.

View SpotlightKid's full-sized avatar

Christopher Arndt SpotlightKid

View GitHub Profile
import requests
import time
from selenium import webdriver
from PIL import Image
from io import BytesIO
url = "https://unsplash.com"
driver = webdriver.Firefox(executable_path=r'geckodriver.exe')
driver.get(url)
@laurivosandi
laurivosandi / uwebsockets.py
Created August 18, 2017 10:53
Websockets client for MicroPython
"""
Websockets client for micropython
Based very heavily on
https://github.com/aaugustin/websockets/blob/master/websockets/client.py
"""
import ubinascii as binascii
import urandom as random
import ure as re
@chrono-meter
chrono-meter / common_prefix.py
Created January 26, 2017 07:01
Python: Common prefix of pathlib.Path
import collections
import pathlib
def common_prefix(*paths):
"""Common prefix of given paths"""
counter = collections.Counter()
for path in paths:
assert isinstance(path, pathlib.Path)
counter.update([path])
@josephernest
josephernest / wavfile.py
Last active March 17, 2024 02:54
wavfile.py (enhanced)
# wavfile.py (Enhanced)
# Date: 20190213_2328 Joseph Ernest
#
# URL: https://gist.github.com/josephernest/3f22c5ed5dabf1815f16efa8fa53d476
# Source: scipy/io/wavfile.py
#
# Added:
# * read: also returns bitrate, cue markers + cue marker labels (sorted), loops, pitch
# See https://web.archive.org/web/20141226210234/http://www.sonicspot.com/guide/wavefiles.html#labl
# * read: 24 bit & 32 bit IEEE files support (inspired from wavio_weckesser.py from Warren Weckesser)
@dhilowitz
dhilowitz / wavecuepoint.c
Last active April 29, 2023 22:01 — forked from jimmcgowan/wavecuepoint.c
This code reads a .wav file and a text file containing marker locations (specified as frame indexes, one per line) and creates a new .wav file with embedded cue points for each location. The code is standard, portable C.
//
// wavecuepoint.c
// Created by Jim McGowan on 29/11/12.
// Turned into command-line utility by David Hilowitz on 19/11/16.
// jim@bleepsandpops.com
// jim@malkinware.com
//
// This function reads a .wav file and a text file containing marker locations (specified as frame indexes, one per line)
// and creates a new .wav file with embedded cue points for each location. The code is standard, portable C.
//
@ventosus
ventosus / Makefile
Last active January 4, 2019 23:58
LV2 discovery by plugin class
all: list
lv2_class: lv2_class.c
gcc -std=gnu99 -O3 -o $@ $< $(shell pkg-config --cflags --libs lilv-0)
list: lv2_class
./$< \
| sort \
| sed 's/,/\n/g' \
| zenity \
@SpotlightKid
SpotlightKid / namedtuple_defaultargs.py
Last active October 10, 2018 18:36
Python namedtuple with default attribute values
from collections import namedtuple, OrderedDict
from functools import partial
# important: pass (name, value) pairs as a tuple/sequence not as keyword args!
# otherwise, order will not be preserved.
fields = OrderedDict((('foo', "bar"), ('spamm', "eggs"), ('ham', None)))
T = partial(namedtuple("T", fields), **fields)
t1 = T()
print(t1)
t2 = T(ham="bacon")
@mdsaleemj
mdsaleemj / install_execstack_on_ubuntu.md
Created October 19, 2015 07:07
How to install execstack on Ubuntu and Arch Linux

Execstack is a great tool for learning and training on Linux. It is a program which sets, clears, or queries the executable stack flag of ELF binaries and shared libraries. When I was looking to install it I took me a bit to find which package to install it in.

You can install with :

Ubuntu

$ sudo apt-get install prelink

Arch Linux

@brantsch
brantsch / i3lock-wrapper.sh
Created October 4, 2015 08:16
Wrap i3lock to randomly select an image from a folder and automatically scale it to fit your monitor resolution.
#!/bin/bash
random_wallpaper="$(find $1 -maxdepth 1 -name *.png | shuf | head -1)"
actual_size="$(identify -format %wx%h $random_wallpaper)"
target_size=$(xrandr | head -n 1 | awk -e '{OFS=""; gsub("[ ,]+","",$10); print $8,"x",$10;}')
if [[ "$actual_size" != "$target_size" ]]; then
convert "$random_wallpaper" -background black -gravity center -scale $target_size -extent $target_size png:- | i3lock -i /proc/self/fd/0
else
i3lock -t -i "$random_wallpaper"
fi