Skip to content

Instantly share code, notes, and snippets.

View iolloyd's full-sized avatar
💭
Busy bee

Lloyd Moore iolloyd

💭
Busy bee
View GitHub Profile
@iolloyd
iolloyd / ezdl.sh
Last active November 1, 2023 20:18
Script to download from easynews
#!/bin/sh
USER=god
PASS=allyourbasearebelongtous
FILE=`echo "$1" | sed 's_\(https://\)\(.*\)\(secure\.\)\(.*\)\(/.*\)_\2\4\5_'`
FILE=`echo "$1" | sed 's_\(https://\)\(boost4-\)*\(.*\)\(secure\.\)\(.*\)\(/.*\)_\3\5\6_'`
CMD='curl -Y 12800 -y 5 -C - -O http://'$USER':'$PASS'@'$FILE
echo $CMD
@iolloyd
iolloyd / DupeFinder.py
Created June 25, 2012 06:36
Find duplicate mp3 files in a folder
import os
import re
import hashlib
def tagAll(dirname):
files = os.listdir(dirname)
files = [x for x in files if not os.path.isdir(dirname + '/' + x)]
tagged = {}
dupes = []
originals = []
@iolloyd
iolloyd / Spot the Hijack
Created September 2, 2012 20:09
Use Audio Hijack Pro to record Spotify tracks while you listen
* Script to record and tag spotify tracks, by Lloyd Moore *)
(* Make sure you are already recording in Audio Hijack Pro with a session called 'spotifySession' *)
tell application "Spotify"
set currentTrack to (current track)
set trackName to (name of currentTrack)
tell application "Audio Hijack Pro"
set theSession to my getSession()
end tell
repeat
@iolloyd
iolloyd / PHPivot.php
Last active May 25, 2016 10:35
Super simple strategy to pivot table like data
class Pivot {
protected $pivotedData;
public function __construct($data){
$this->pivotedData = $this->_pivot($data);
}
protected function pivot($data){
$pivoted = [];
@iolloyd
iolloyd / lastfile.sh
Created September 26, 2012 21:04
Shows last file changed in history
git show HEAD|grep diff|awk '{print $3;}'
@iolloyd
iolloyd / letterPressSolver.py
Created November 25, 2012 17:44
ios letterpress solver
"""
To use just type ... python letterPressSolver.py <25 letter string of grid> <favourite letters>
"""
class Solver():
def __init__(self, grid):
wordList = open('/usr/share/dict/words').readlines()
self.wordList = [x.lower().strip() for x in wordList]
self.grid = list(grid)
self.grid.sort()
@iolloyd
iolloyd / snn.ml
Created November 29, 2012 16:34
simple neural network
open Printf
type 'a io = { i: 'a; o: 'a }
@iolloyd
iolloyd / RomanToDecimal.scala
Created November 30, 2012 19:10
Roman numerals conversion to decimal in Scala
def numerals: List[char]): int = in match {
case 'i' :: 'v' :: xs => 4 + numerals(xs)
case 'i' :: 'X' :: xs => 9 + numerals(xs)
case 'i' :: xs => 1 + numerals(xs)
case 'v' :: xs => 5 + numerals(xs)
case 'X' :: 'L' :: xs => 40 + numerals(xs)
case 'X' :: 'c' :: xs => 90 + numerals(xs)
case 'X' :: xs => 10 + numerals(xs)
case 'L' :: xs => 50 + numerals(xs)
case 'c' :: 'd' :: xs => 400 + numerals(xs)
@iolloyd
iolloyd / flask.py
Last active August 27, 2019 19:19
Dynamically generating endpoints based on model in flask
def set_end_point(view_class, endpoint, url, pk='id', pk_type='int'):
view = view_class()
app.add_url_rule(url, defaults={id: None}, view_func=view.as_view, methods=['GET',])
app.add_url_rule(url, view_func=view.as_view, methods=['POST',])
url = '%s/<%s:%s>' % (url, pk_type, pk)
app.add_url_rule(url, view_func=view.as_view, methods=['GET', 'PUT', 'DELETE'])
def register_url(name):
def to_json(self, view='list_view'):
out = {}
for f in self.get_fields(view):
field_value = getattr(self, f)
if hasattr(f, 'to_json'):
out[f] = field_value.to_json(view) # relation object
elif hasattr(f, 'isoformat'):
out[f] = field_value.isoformat() # datetime object