Skip to content

Instantly share code, notes, and snippets.

@JosephRedfern
JosephRedfern / gist:d9f277461cfaa9349dd6757677cc66b0
Created Dec 11, 2020
contents of /dev/ on macOS Big Sur (11.0.1) on M1 MacBook Pro
View gist:d9f277461cfaa9349dd6757677cc66b0
aes_0
afsc_type5
apfs-raw-device.2.0
auditpipe
auditsessions
autofs
autofs_control
autofs_homedirmounter
autofs_notrigger
autofs_nowait
@JosephRedfern
JosephRedfern / lsusb
Created Nov 5, 2020
lsusb -v for Hiievpu "2K" webcam from Amazon
View lsusb
v4l2 video modes and lsusb details for https://www.amazon.co.uk/Microphone-Hiievpu-Suitable-Streaming-Conferencing/dp/B08H1L41KF
@JosephRedfern
JosephRedfern / requirements.txt
Created Jul 4, 2020
BBC6Music Spotify Playlist Updater (via @BBC6MusicBot)
View requirements.txt
python-twitter==3.5
spotipy==2.13.0
tqdm==4.47.0
View whitelisted_socket_guard.py
# 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]
View unrequired.py
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:
View email_header_miner.py
import imaplib
import re
import random
from email.parser import BytesHeaderParser
from typing import List
import tqdm
View gate.py
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 Sep 7, 2019
Scrape BBC Sounds and update a spotify playlist with the tracks found. Requires spotipy library.
View get_tracks.py
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.
"""
View nbgol.py
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
View add_user.py
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)