Skip to content

Instantly share code, notes, and snippets.

View ryanbateman's full-sized avatar
🥑
avocado

Ryan Bateman ryanbateman

🥑
avocado
  • London, United Kingdom
View GitHub Profile
@ryanbateman
ryanbateman / index.html
Last active September 23, 2023 16:50
An in-browser, MQTT topic visualisation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MQTT Topic tree visualisation experiment</title>
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
<style>
.node-label {
max-width: 15px; /* You can adjust this value as needed */
@ryanbateman
ryanbateman / main.py
Last active April 12, 2024 08:14 — forked from wiseman/main.py
Print the 10 closest spacecraft/satellites.
import requests
import requests_cache
import math
import ephem
import os
import json
import paho.mqtt.client as mqtt
import datetime
observer = ephem.Observer()
@ryanbateman
ryanbateman / ddg.R
Created January 20, 2022 09:59
R script for visualising play store review keywords over time
library(jsonlite)
library(dplyr)
require(ggplot2)
library(data.table)
library(lubridate)
library(dplyr)
library(tidyr)
library(reshape2)
library(data.table)
@ryanbateman
ryanbateman / ddg.ipyb
Created January 20, 2022 09:55
DDG Jupyter notebook for exporation
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "235a092e",
"metadata": {
"scrolled": true
},
"outputs": [],
Assumptions:
All interactions with the service is over SMS
There is no other interaction with any other users other than the updated temperatures or names
No phone numbers will be sent over SMS _ever_
All data sent over the service is low-stakes, low security information (?!) - names, temperatures and associations - that people would be fine publicly sharing if it came to it (because it is, to some extent, public as described)
Basic rules:
A USER is a phone number, desired name, and their most recent UPDATE
An UPDATE is the temperature and time a USER took it
A USER creates an UPDATE by sending their temperature to the service
@ryanbateman
ryanbateman / pihole.1m.py
Last active September 1, 2021 02:06
An extension to the bitbar Pihole plugin to add a sparkline showing the last 3 hours worth of ads blocked
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# <bitbar.title>Pi-hole status</bitbar.title>
# <bitbar.version>v3.1</bitbar.version>
# <bitbar.author>Felipe Martin</bitbar.author>
# <bitbar.author.github>fmartingr</bitbar.author.github>
# <bitbar.author>Siim Ots</bitbar.author>
# <bitbar.author.github>siimots</bitbar.author.github>
# <bitbar.author>Ryan Bateman</bitbar.author>
# <bitbar.author.github>ryanbateman</bitbar.author.github>
@ryanbateman
ryanbateman / trees.R
Created November 6, 2019 16:40
NYC Tree Census 2015
require("ggplot2")
require("viridis")
require("colorBrewer")
require("randomcoloR")
trees <- read.csv("trees.csv")
trees$health <- factor(trees$health)
trees$spc_common <- factor(trees$spc_common)
colours <- sample(grDevices::colors()[grep('gr(a|e)y', grDevices::colors(), invert = T)], length(trees$spc_common))
@ryanbateman
ryanbateman / carbonra.r
Created February 4, 2019 08:01
A short script which shows how to calculate carbon cost of a flight, given data from Monzo's API using Monzor (the R library I wrote)
library(monzor)
library(geosphere)
library(ggrepel)
library(ggmap)
# For the purposes of this demo, I picked the relevant transcation by hand. Using Monzo's callbacks, this would be automated in live code
getFlight <- function() {
getTransaction(transactionId = "tx_0000AAAAA5i3BqkXSPAAAA")
}
@ryanbateman
ryanbateman / NoText.user.js
Last active December 12, 2017 16:31
A simple greasemonkey script to make all text on a website invisible
// ==UserScript==
// @name NoText
// @version 0.2
// @namespace com.everythinginthesky
// @description Makes the web bearable
// @author @rynbtmn
// @match *://*/*
// ==/UserScript==
function addGlobalStyle(css) {
@ryanbateman
ryanbateman / monzo_auth_example.R
Last active November 19, 2017 19:24
How to auth against Monzo's API in R
library(httr)
library(jsonlite)
# OAuth settings for Monzo:
# https://monzo.com/docs/#authentication
monzo <- oauth_endpoint(
authorize = "https://auth.getmondo.co.uk/",
access = "https://api.monzo.com/oauth2/token")
# You need to set up your own Monzo 'app' to play with the API