Skip to content

Instantly share code, notes, and snippets.

View JosephRedfern's full-sized avatar

Joseph Redfern JosephRedfern

View GitHub Profile
@JosephRedfern
JosephRedfern / gist:d9f277461cfaa9349dd6757677cc66b0
Created December 11, 2020 21:50
contents of /dev/ on macOS Big Sur (11.0.1) on M1 MacBook Pro
aes_0
afsc_type5
apfs-raw-device.2.0
auditpipe
auditsessions
autofs
autofs_control
autofs_homedirmounter
autofs_notrigger
autofs_nowait
@JosephRedfern
JosephRedfern / lsusb
Created November 5, 2020 17:25
lsusb -v for Hiievpu "2K" webcam from Amazon
v4l2 video modes and lsusb details for https://www.amazon.co.uk/Microphone-Hiievpu-Suitable-Streaming-Conferencing/dp/B08H1L41KF
@JosephRedfern
JosephRedfern / requirements.txt
Created July 4, 2020 09:25
BBC6Music Spotify Playlist Updater (via @BBC6MusicBot)
python-twitter==3.5
spotipy==2.13.0
tqdm==4.47.0
# basic whitelisting for socket.socket.connect.
import socket
CONNECTION_WHITELIST = [('localhost', 80)]
unguarded_connect = socket.socket.connect
def guarded_connect(self, *args, **kwargs):
con = args[0]
import importlib
import sys
import argparse
import subprocess
import logging
import inspect
try:
from pip._internal.cli.main import main as pipmain # sorry
except ImportError:
import imaplib
import re
import random
from email.parser import BytesHeaderParser
from typing import List
import tqdm
from flask import Flask
import RPi.GPIO as GPIO
channel = 21
# GPIO setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.OUT)
app = Flask(__name__)
@JosephRedfern
JosephRedfern / get_tracks.py
Created September 7, 2019 08:50
Scrape BBC Sounds and update a spotify playlist with the tracks found. Requires spotipy library.
import requests
from bs4 import BeautifulSoup
import json
import spotipy
import spotipy.util
"""
Various constants -- the secrets should be moved to a .env file. SPOTIFY_SCOPES too broad, should be reduced.
"""
import numpy as np
from matplotlib import pyplot as plt
from tqdm import tqdm
board = np.zeros((255, 255))
board[127][127] = 1
board[127][128] = 1
board[128][127] = 1
board[128][128] = 1
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
from django.conf import settings
import ldap
class Command(BaseCommand):
help = 'Add a specific user from LDAP'
def add_arguments(self, parser):
parser.add_argument('user_id', nargs='+', type=str)