Skip to content

Instantly share code, notes, and snippets.

:shipit:

Joseph Redfern JosephRedfern

:shipit:
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
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)
@JosephRedfern
JosephRedfern / sync_ldap.py
Last active Oct 8, 2018
Sync LDAP users with Django users.
View sync_ldap.py
from django.core.management.base 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
JosephRedfern / trace.py
Created Oct 4, 2018
A (slow, badly written) Python implementation of https://tmcw.github.io/literate-raytracer/.
View trace.py
from PIL import Image
import tqdm
import math
import vector
height = 320
width = 240
scene = {}
@JosephRedfern
JosephRedfern / call_heirarchy.py
Created Apr 11, 2018
Short smali analyser to generate call hierarchy and inspect methods...
View call_heirarchy.py
import glob
from collections import defaultdict
classes = defaultdict(lambda: defaultdict(list))
class Klass:
def __init__(self, name, project):
self.name = name
self.project = project
@JosephRedfern
JosephRedfern / transmit.py
Created Sep 26, 2017
UDP Accelerometer data transmission
View transmit.py
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
View slow.py
# 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
JosephRedfern / evil.py
Created Sep 8, 2017
Slack Deleted Message logged
View evil.py
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:
try:
@JosephRedfern
JosephRedfern / screeny.py
Created Sep 6, 2017
Simple Screenshot API with Selenium, Python 3 and Flask
View screeny.py
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.