Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# This is an example script to force provision a UniFi network device using the controller API
# If you are running this externally then replace localhost with the hostname
baseurl=https://localhost:8443
# I would make a dedicated admin user for this
username=<username_here>
password=<password_here>
@jasonehines
jasonehines / printer.conf
Created August 12, 2021 01:34
Ender 3 Pro Creality 4.2.7 with bltouch - Klipper printer Configuration
# This file contains pin mappings for the Creality "v4.2.7" board. To
# use this config, during "make menuconfig" select the STM32F103 with
# a "28KiB bootloader" and serial (on USART1 PA10/PA9) communication.
# If you prefer a direct serial connection, in "make menuconfig"
# select "Enable extra low-level configuration options" and select
# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC
# cable used for the LCD module as follows:
# 3: Tx, 4: Rx, 9: GND, 10: VCC
@fauxpark
fauxpark / keymap.c
Last active March 26, 2023 20:48
rawhid in python
#include <string.h>
// This function is called when a packet is received on the raw HID interface.
// `length` will always be the size of the output (host to device) report in bytes - 32 in current QMK, but will eventually be raised to 64.
// Thus, if you wish to send variable length data, you should send the length along with the payload, splitting across multiple reports
// if needed, and handle the parsing yourself.
//
// In this simple example, we check that the first byte of the received data is the ASCII character 'A',
// in which case we respond with 'B' and toggle the backlight.
void raw_hid_receive(uint8_t *data, uint8_t length) {
@EyalAr
EyalAr / client.py
Created December 11, 2013 18:17
Demo code for my post about python's blocking stream reading functions.
from subprocess import Popen, PIPE
from time import sleep
# run the shell as a subprocess:
p = Popen(['python', 'shell.py'],
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# issue command:
p.stdin.write('command\n')
# let the shell output the result:
sleep(0.1)
@revolunet
revolunet / extractGifs.py
Created March 1, 2011 09:48
extract frames from animated gif using python+PIL
import os
from PIL import Image
def extractFrames(inGif, outFolder):
frame = Image.open(inGif)
nframes = 0
while frame:
frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF')
nframes += 1