Skip to content

Instantly share code, notes, and snippets.

View moonhouse's full-sized avatar

David Hall moonhouse

View GitHub Profile
javascript:(function() {
var csv = 'data:year,count%250A';
var bars = document.querySelectorAll('.bar.year');
bars.forEach(function(bar) {
var dataDate = bar.getAttribute('data-date');
var year = new Date(dataDate).getFullYear();
var count = bar.getAttribute('data-count');
csv += year + ',' + count + '%250A';
});
var a = document.createElement('a');
@moonhouse
moonhouse / random_google_meet_participant_list.js
Created February 13, 2023 08:31
Bookmarklet to list order of the current meeting in random order. List of participants needs to have been opened and then the chat window.
javascript:!function(){document.getElementById("bfTqV").value=" • "+Array.from(document.getElementsByClassName('GvcuGe')[0].children).map(function(a){return a.firstElementChild.getElementsByClassName("zWGUib")[0].innerText}).filter((v, i, a) => a.indexOf(v) === i).map(a => ({ sort: Math.random(), value: a })).sort((a, b) => a.sort - b.sort).map(a => a.value).join("\n • ");}();
@moonhouse
moonhouse / _readme.md
Created August 25, 2022 09:38 — forked from stecman/_readme.md
Brother P-Touch PT-P300BT bluetooth driver python

Controlling the Brother P-Touch Cube label maker from a computer

The Brother PTP300BT label maker is intended to be controlled using the official Brother P-Touch Design & Print iOS/Android app. The app has arbitrary limits on what you can print (1 text object and up to 3 preset icons), so I thought it would be a fun challenge to reverse engineer the protocol to print whatever I wanted.

Python code at the bottom if you want to skip the fine details.

Process

Intitially I had a quick peek at the Android APK to see if there was any useful information inside. The code that handles the communication with the printer in Print&Design turned out to be a native library, but the app clearly prepares a bitmap image and passes it to this native library for printing. Bitmaps are definitely something we can work with.

@moonhouse
moonhouse / convert_quickstatements_batch_to_quickstatements.py
Created July 5, 2021 16:21
Convert quickstatements from quickstatements.toolforge.org/api.php?action=get_commands_from_batch back into quickstatements
import json
import sys
data = json.loads(sys.stdin.read())['data']
fs = ""
s = ""
for prop in data:
statement = f"""{prop['json']['item']}\t{prop['json']['property']}\t{prop['json']['datavalue']['value']['language']}:"{prop['json']['datavalue']['value']['text']}"\t"""
if s != statement:
fs += statement
Det finns två andra punkter i betänkandet som jag skulle vilja betona.
Jag tycker att det finns två avgörande punkter.
Det är faktiskt ett mycket viktigt led i tryggandet av energiförsörjningen.
Vi bör inte missa detta tillfälle att låta det ske igen.
Jag är oroad över att det vetenskapliga arbetet bakom detta förslag är ofullständigt.
Det gläder mig att betänkandet betonar behovet av att involvera parlamentet i processen.
Nu har vi chansen att i praktiken förbättra villkoren för dessa djur.
Vi får inte bortse från antalet dödsfall bland människor.
Den turkiska regeringen har gjort avsevärda insatser på detta område.
Det är dags att se till att det implementeras ordentligt.
Kladd:
https://www.svd.se/arkiv/1996-01-28/20
https://www.svd.se/arkiv/1996-05-04/9
https://www.svd.se/arkiv/1996-08-29/9
https://www.svd.se/arkiv/1997-05-09/38
https://www.svd.se/arkiv/1997-08-30/46
Förvrängd scanning:
https://www.svd.se/arkiv/1986-05-15/27
Abydos 6 66
Adlerz 6 66
Afgöre 6 66
Ahrent 6 66
Alforn 6 66
Algols 6 66
Andnor 6 66
Anebys 6 66
Anubis 6 66
Behrns 6 66
<html><h1>Hello</h1></html>
@moonhouse
moonhouse / json_schema_to_bq_schema.py
Last active August 28, 2019 13:23
Convert JSON schema to BigQuery schema
import json
import sys
f = sys.argv[1]
bq_schema = []
def tree_to_schema(tree):
schema = []
properties = tree['properties']
for a in properties: