Skip to content

Instantly share code, notes, and snippets.

@fredley
fredley / gpx2svg.py
Last active November 21, 2022 13:50
import gpxpy
from haversine import haversine
from pyproj import Transformer
import sys
from svgpathtools import Path, Line
import svgwrite
fnames = sys.argv[1:]
if not fnames:
@fredley
fredley / day-15.go
Created December 19, 2018 11:27
AoC Day 15
package main
import (
"fmt"
"github.com/beefsack/go-astar"
"io/ioutil"
"math"
"sort"
"strings"
)
  • Install gatt and test it works with sudo gattctl --discover: https://github.com/getsenic/gatt-python
  • Get the mac of your Turn Touch using gattctl and update monitor.py appropriately (remember to unpair your tt from everything else first!)
  • simply run sudo python3 monitor.py. Press some buttons and if everything is set up correctly, you will see it respond!
@fredley
fredley / recipes.py
Created May 17, 2016 09:13
BBC recipe archive tool
"""
Save a copy of all BBC recipes as JSON files.
Instructions:
Run this file with Python 3 in an environment with BeautifulSoup4 and requests:
virtualenv -p python3 env
source env/bin/activate
pip install requests beautifulsoup4
@fredley
fredley / topic.user.js
Last active August 29, 2015 14:16
Chat Topic Change Diffs
// ==UserScript==
// @name Room Topic Diff
// @description Whenever the room topic is changed, displays what it was before
// @author fredley
// @version 1.0.0
// @include *://chat.meta.stackoverflow.com/rooms/*
// @include *://chat.meta.stackexchange.com/rooms/*
// @include *://chat.stackexchange.com/rooms/*
// @include *://chat.stackoverflow.com/rooms/*
// @include *://chat.askubuntu.com/rooms/*
@fredley
fredley / upload.user.js
Created March 4, 2015 18:56
Drag+Drop image uploader for SE chat
// ==UserScript==
// @name Chat Image Upload
// @description Drag and Drop upload images
// @author fredley
// @version 1.0.0
// @include *://chat.meta.stackoverflow.com/rooms/*
// @include *://chat.meta.stackexchange.com/rooms/*
// @include *://chat.stackexchange.com/rooms/*
// @include *://chat.stackoverflow.com/rooms/*
// @include *://chat.askubuntu.com/rooms/*
// ==UserScript==
// @name It's Never Friday
// @description Detects links to Rebecca Black's Friday
// @version 1.0.0
// @include *://chat.meta.stackoverflow.com/rooms/*
// @include *://chat.meta.stackexchange.com/rooms/*
// @include *://chat.stackexchange.com/rooms/*
// @include *://chat.stackoverflow.com/rooms/*
// @include *://chat.askubuntu.com/rooms/*
// @run-at document-end
// ==UserScript==
// @name It's Never Friday
// @description Detects links to Rebecca Black's Friday
// @version 1.0.0
// @include *://chat.meta.stackoverflow.com/rooms/*
// @include *://chat.meta.stackexchange.com/rooms/*
// @include *://chat.stackexchange.com/rooms/*
// @include *://chat.stackoverflow.com/rooms/*
// @include *://chat.askubuntu.com/rooms/*
// @run-at document-end
var decode = function(save){
return LZString.decompressFromBase64(save.split("|")[1].substring(16));
}
var encode = function(json){
return btoa("1.0.19") + "|" + btoa("SAVE HAX0R3D") + LZString.compressToBase64(json);
}
@fredley
fredley / gist:d63b2b9bb195d2b5494a
Last active August 29, 2015 14:10
badges.user.js
// ==UserScript==
// @name Badge Popups
// @description YAY BADGES
// @version 1.0
// @include *//meta.stackexchange.com/users/*
// @run-at document-end
// ==/UserScript==
var init = function($){
if($('.people-helped').length == 0) return;