Skip to content

Instantly share code, notes, and snippets.

View prcutler's full-sized avatar

Paul Cutler prcutler

View GitHub Profile
@sandyjmacdonald
sandyjmacdonald / code.py
Last active May 26, 2023 12:46
MIDI CC knob controller example for Raspberry Pi Pico
import time
import board
import usb_midi
import adafruit_midi
from analogio import AnalogIn
from adafruit_midi.control_change import ControlChange
# MIDI CC knob controller example for Raspberry Pi Pico
@eddiewebb
eddiewebb / readme.md
Last active February 12, 2024 08:46
Hugo JS Searching with Fuse.js
@vjousse
vjousse / sqlalchemy_conftest.py
Created February 20, 2018 14:35 — forked from kissgyorgy/sqlalchemy_conftest.py
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope='session')
def engine():
return create_engine('postgresql://localhost/test_database)
@480
480 / gist:3b41f449686a089f34edb45d00672f28
Last active April 11, 2024 23:56
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings

MacOS X + oh my zsh + powerline fonts + visual studio code (vscode) terminal settings

Thank you everybody, Your comments makes it better

Install oh my zsh

http://ohmyz.sh/

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@johnwargo
johnwargo / relay-test.py
Last active January 15, 2024 22:00
Simple Python app for controlling a relay through an GPIO Zero Output device
#!/usr/bin/python
# A simple Python application for controlling a relay board from a Raspberry Pi
# The application uses the GPIO Zero library (https://gpiozero.readthedocs.io/en/stable/)
# The relay is connected to one of the Pi's GPIO ports, then is defined as an Output device
# in GPIO Zero: https://gpiozero.readthedocs.io/en/stable/api_output.html#outputdevice
import sys
import time
@savetheclocktower
savetheclocktower / README.md
Last active April 29, 2024 03:03
Using a rotary encoder as a volume control for the Raspberry Pi

Using a rotary encoder as a volume control

On my RetroPie machine I wanted a hardware volume knob — the games I play use a handful of emulators, and there's no unified software interface for controlling the volume. The speakers I got for my cabinet are great, but don't have their own hardware volume knob. So with a bunch of googling and trial and error, I figured out what I need to pull this off: a rotary encoder and a daemon that listens for the signals it sends.

Rotary encoder

A rotary encoder is like the standard potentiometer (i.e., analog volume knob) we all know, except (a) you can keep turning it in either direction for as long as you want, and thus (b) it talks to the RPi differently than a potentiometer would.

I picked up this one from Adafruit, but there are plenty others available. This rotary encoder also lets you push the knob in and treats that like a button press, so I figured that would be useful for toggling mute on and off.

@devStepsize
devStepsize / slack_webhook_post.py
Last active August 7, 2023 09:28
POST a JSON payload to a Slack Incoming Webhook using Python requests
'''
This is an example of how to send data to Slack webhooks in Python with the
requests module.
Detailed documentation of Slack Incoming Webhooks:
https://api.slack.com/incoming-webhooks
'''
import json
import requests
@sebz
sebz / grunt-hugo-lunrjs.md
Last active April 29, 2024 16:44
hugo + gruntjs + lunrjs = <3 search
@Zearin
Zearin / python_decorator_guide.md
Last active March 30, 2024 12:28
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].