Skip to content

Instantly share code, notes, and snippets.

View hughrawlinson's full-sized avatar
⛸️
Drop your GitHub Pro sub until GitHub Drops ICE

Hugh Rawlinson hughrawlinson

⛸️
Drop your GitHub Pro sub until GitHub Drops ICE
View GitHub Profile
@hughrawlinson
hughrawlinson / linear_regression.js
Created September 15, 2018 15:07
Overcommented File Explaining and Implementing Linear Regression
// This may or may not help you understand what's going
// on in week one of the Stanford Machine Learning course
// particulary if you're coming from Javascript programming.
// The lecture deals with linear regression. You may remember
// a concept called "line of best fit" from middle school.
// A refresher: you have a set of points with x and y co-ordinates
// and you have to draw a straight line through them. It doesn't
// have to intersect all (or any) of the points, but it does need
// to represent the general layout of your dataset. The idea is

Spotify OAuth Scripts

Requirements

  • jq
  • Your own Spotify Client ID and Client Secret

Creds Storage

Store your Client ID in ~/.config/spotify_client_creds.json. It should look like:

@hughrawlinson
hughrawlinson / silly.tee ex tee
Last active August 7, 2017 18:43
What? Me? I'm not doing silly things with a computer. You're doing silly things with a computer.
MediaElementAudioSource outputs zeroes due to CORS access restrictions for data:audio/wav;base64,UklGRiRwEgBXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQBwEgDs/+//9P/x//b/8P/u//j/+v8AAAIACgACAAgABQAGAAMA/v/8//3/9v/2//L/9f/y//L/7v/w//L/+P8HAAsAFAAVABoAEAANAAcAAAACAAUADQAIAAsA///5//X/9//3//f/AAAEAAgABwABAP3/+v/7//v//f8BAAMABgADAAEA/P8AAAIAAQAJAAkACwAOAAgADQAEAAwABwAMAA0ADgAOAAkAEwANABMACgAJAAgAAQABAAAA+//9//3/+/8BAAYABQADAAIAAwACAAcAAwAMAAsACAALAAwABAAEAPr///////z/+v/8//j/+v/w//D/6f/v/+v/7//3//v/+//8//b////7/wEAAAAFAAMABAD9/wMA+v/2//X/9/////z/AwD7/wUA/P8CAAMABQAMAA8ACQAMAAoAAwD9//b/8f/t//H/6P/s/+//9v/8////9//+//n/AgD//wUABQAOAAwADwAHAAYA+f8AAPf/+//6/wAA+f8AAPn/AAD7/wEA+f/+//3/AQAAAP///f/6/wEA+v8AAPv//f/+//7//P/0//b/+//+//z////6//j/+f/1/wIAAgANAAoAEQAMAAYABAD//wEA9v/6//j/+f/7//r/+/8BAPz/AwD+/wEA/f/8/wQA//8HAAYADQARABAADwANABEACwAPAAkACgAAAP3/AAD7//v/+//8//r/AQD//wcABQAJAAUACQAHAAEA/P/2//v/8//6//L/9//1//b/8f/0/+//9//3/wAA/P8EAP//AgAEAAoAFAAUABQAEwAOAA4ABAAGAPr/AAD7/wIA//8CAPz/AgD+/wAAAwAGAAoADAAOABAAFgAQABAACgAGAP/
def one_two_three():
if (one_two() == 1):
if (one_two() == 1):
return 1
else:
return 2
else:
if (one_two() == 1):
return 3
else:
@hughrawlinson
hughrawlinson / nonpythonic.py
Created June 25, 2017 12:50
🚨 extremely unpythonic python alert 🚨
import re
def is_valid_IP(strng):
t = re.compile("^\d+$")
try:
return (lambda m: len(m) is 4 and reduce(lambda acc, el: acc and el, [True] + m))(map(lambda x: (lambda x: x < 256 and x >= 0)(int(x)) and (x[0] is not '0' if len(x) > 1 else True) and t.match(x) is not None, strng.split('.')))
except Exception:
return False
request = requests.post(
"https://accounts.spotify.com/api/token",
data = json.dumps({
"grant_type": "client_credentials"
}),
headers = {
"Authorization": "Basic " + str(
base64.b64encode(
(config.config["spotify"]["client_id"] +
":" + config.config["spotify"]["client_secret"]
@hughrawlinson
hughrawlinson / languages.md
Last active January 31, 2017 14:12
Languages I type in

Here are the languages I've typed in over the years.

   1 Arduino
   1 CoffeeScript
   1 Go
   1 Rust
   1 TeX
   2 ChucK
 2 Clojure
@hughrawlinson
hughrawlinson / send_all_drafts.py
Last active February 13, 2017 19:53
Send all your gmail drafts
#!/usr/bin/python
from __future__ import print_function
import httplib2
import os
import base64
import sys
from apiclient import discovery
from oauth2client import client
from oauth2client import tools
@hughrawlinson
hughrawlinson / spotify_platform_oauth.sh
Last active January 28, 2024 02:49
Authenticate and get an oauth token for your Spotify app from the command line
#!/bin/bash
# spotify_platform_oauth.sh
#
# A script to quickly and easily generate Spotify oauth tokens given a client
# id, secret, and scope. Will authenticate a user via the browser.
# The app must have "http://localhost:8082/' as a redirect_uri
# spotify_client_creds.json should contain a spotify client id and secret pair
@hughrawlinson
hughrawlinson / solver.js
Last active May 14, 2017 16:44
Naive 2048 Solver
var a = (keyCode)=>{
var keyEvent = document.createEvent("Events");
keyEvent.initEvent("keydown", true, true);
keyEvent.keyCode = keyCode;
keyEvent.which = keyCode;
document.body.dispatchEvent(keyEvent);
}
const LEFT = 37;
const UP = 38;