Skip to content

Instantly share code, notes, and snippets.


Joseph Redfern JosephRedfern

Block or report user

Report or block JosephRedfern

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
JosephRedfern /
Created Sep 7, 2019
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 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)
JosephRedfern /
Last active Oct 8, 2018
Sync LDAP users with Django users.
from import BaseCommand, CommandError
from django.contrib.auth.models import User
import ldap
class Command(BaseCommand):
help = 'Syncs LDAP users with Django DB'
def handle(self, *args, **options):
l = ldap.initialize(settings.AUTH_LDAP_SERVER_URI)
JosephRedfern /
Created Oct 4, 2018
A (slow, badly written) Python implementation of
from PIL import Image
import tqdm
import math
import vector
height = 320
width = 240
scene = {}
JosephRedfern /
Created Apr 11, 2018
Short smali analyser to generate call hierarchy and inspect methods...
import glob
from collections import defaultdict
classes = defaultdict(lambda: defaultdict(list))
class Klass:
def __init__(self, name, project): = name
self.project = project
JosephRedfern /
Created Sep 26, 2017
UDP Accelerometer data transmission
import socket
from pyvmu import vmu931, messages
class VMUTransmit(object):
def __init__(self, ip, port, device="/dev/tty.usbmodem1411", euler=True, accelerometer=True, quaternion=True):
self.__device = device
self.__euler = euler
self.__accelerometer = accelerometer
# frames is a list of mdarrays
new_image = np.zeros(frames[n].shape, dtype=frames[n].dtype)
for ny, y in tqdm(enumerate(flow)):
for nx, flow in enumerate(y):
x_flow, y_flow = flow
new_x = int(nx+x_flow*flow_scaling)
new_y = int(ny+y_flow*flow_scaling)
JosephRedfern /
Created Sep 8, 2017
Slack Deleted Message logged
from slackclient import SlackClient
from datetime import datetime
import time
slack_token = 'xoxb-token-goes-here'
sc = SlackClient(slack_token)
if sc.rtm_connect():
while True:
JosephRedfern /
Created Sep 6, 2017
Simple Screenshot API with Selenium, Python 3 and Flask
from flask import Flask, request, Response, abort, send_from_directory
from selenium import webdriver
import sqlite3
import uuid
app = Flask(__name__)
conn = sqlite3.connect("screenshots.sqlite")
c = conn.cursor()
You can’t perform that action at this time.