Skip to content

Instantly share code, notes, and snippets.

@metaquanta
metaquanta / embed_wikipedia_midis.js
Created September 16, 2018 21:34
Inline Wikipedia's midis
// ==UserScript==
// @name Wikipedia: embed midi
// @namespace mqScripts
// @match *://*.wikipedia.org/*
// @grant none
// @require https://code.jquery.com/jquery-3.3.1.slim.min.js
// ==/UserScript==
// Requires that your browser knows what to do with midi audio tags.
// eg MIDI Player https://chrome.google.com/webstore/detail/midi-player/khppfbnjbaampmeeiocjhcodkklkcfjf
//
@metaquanta
metaquanta / bash_aliases
Last active November 25, 2020 07:52
Shell foo
# for each line of cmd1, pass it to cmd2.
# cmd1 | each cmd2 %
alias each="xargs -I% -d '\\n'"
# print the sizes of dirs(!) and files in cwd.
alias lsz="du -d 1 -h"
# this'll format /proc/xxx/cmdline as expected.
alias strs='strings -s \ -1'
# like `open` on a mac
alias open=xdg-open
@metaquanta
metaquanta / openwrt_rescue.ttl
Last active November 24, 2018 15:48
Rescue TPL 3600
# Good stuff here: https://wiki.openwrt.org/toh/tp-link/tl-wdr4300
# (p3,5,7,9 on JTAG are GPIOs?)
J1: 1,2,3 (not 4) -> raspi: 10,8,6
minicom -D /dev/ttyAMA0 -b 115200
type: 'tpl<enter>' when uboot is preparing to load
# server should be 192.168.1.100
# see that with printenv
@metaquanta
metaquanta / list_foreign_packages.sh
Last active November 16, 2017 21:27
List packages that don't belong in your distro.
#!/bin/bash
PACKAGE_LIST="dpkg-query -W -f='${binary:Package}\n'" # List all debs
#PACKAGE_LIST=apt-mark showmanual # List only requested/manually installed debs
# Unknown origin debs get 100.
#PRIORITY=100
# I have some preferences to set some repos to other priorities in (100-200)
PRIORITY="1.."
$PACKAGE_LIST | \
xargs apt-cache policy | \
grep -B 4 " \*\*\*.*${PRIORITY}$" | \
@metaquanta
metaquanta / Cura end.gcode
Created September 29, 2017 18:00
MP Select Mini Slicer Settings
M104 S0 ;extruder heater off
G91 ;relative positioning
G1 E-1 F300 ;retract the filament ... to release some of the pressure.
G1 Z+5 E-1 F{travel_speed} ;move Z up a bit and retract filament /just/ a little more.
G90 ;absolute positioning
G0 X0 Y110 ; Present the result!
M84 ;steppers off
M106 S0 ; Fan off.
@metaquanta
metaquanta / Pi ⟷ Mini UART connection.md
Last active August 19, 2023 18:28
MP Select Mini USART Interface

MP Select Mini

The serial cable (that ordinarily connects to the LCD controller) has four wires: Red, White, Green, Black.

  • Red ➙ Ground
  • White ➙ TX USART1 - pin 42
  • Green ➙ RX USART1 - pin 43
  • Black ➙ +3.3V (yup, they're backwards)

†: on the STM32 processor

@metaquanta
metaquanta / authorize_crd.sh
Last active February 16, 2023 04:30
Setup Chromoting/CRD/Chrome Remote Desktop from the command line.
#!/bin/sh
# This assumes the package is installed.
# wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
# sudo apt install ./chrome-remote-desktop_current_amd64.deb
# # And maybe
# wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# sudo apt install ./google-chrome-stable_current_amd64.deb
# # Fix the likely missing dependencies.
# sudo apt --fix-broken install
@metaquanta
metaquanta / bdf2json.js
Last active July 9, 2017 05:41
A script that turns a BDF bitmap font into a dictionary of bitmaps
#!/usr/bin/env node
const regrep = require('stream-replace');
/* Stream in, stream out.
The output will look something like this:
{ "${code_0}": ["${hex^0_0}", ..., "${hex^0_n}"],
"${code_1}": [...],
....
@metaquanta
metaquanta / pixelizeFonts.js
Last active July 8, 2017 09:22
Change the fonts when a window is moved between Hi/Low DPI monitors. Cr DevTools Snippet
function _buildFontSwitcher({document, fontFunc, selectors = [], aliases = [], bangImportant = false}) {
// This is basically a closure around a style tag.
// build that style tag.
const el = document.createElement("style");
document.head.appendChild(el);
const _buildAlias = (fn, an) => `
@font-face {
font-family: ${an};
@metaquanta
metaquanta / loadSearchEngines.js
Last active July 6, 2017 09:06
load chrome search engines snippet (WiP/RIP/old Chrome only)
(function() {
const mySearchEngines =
{
'domain': SEARCH_DOMAIN,
'engines': [
{
'keyword': 'maps.google.com',
'name': 'Maps',
'url': 'https://www.google.com/maps/search/%s',
},