Skip to content

Instantly share code, notes, and snippets.

View LeoMcA's full-sized avatar

Leo McArdle LeoMcA

View GitHub Profile
@LeoMcA
LeoMcA / index.ts
Last active February 8, 2023 14:25
imagemin incorrect types minimal test-case
import imagemin from "imagemin";
console.log(imagemin([""]));
@LeoMcA
LeoMcA / debug-python
Created June 22, 2022 16:40
debug any python app in vscode
#!/bin/bash
python -m debugpy --listen 5678 --wait-for-client "$@"

UK Mobile Network Features

Last updated October 2021

Provider Tube WiFi VoLTE VoWiFi [RootMetrics Score (2021 H1)][rootmetrics]
EE [Y][ee-tube] [Y][ee-volte] [Y][ee-vowifi] 1
BT [Y][bt-tube] [Y][bt-volte] [Y][bt-vowifi] 1 (EE)
Virgin [Y][virgin-tube] [Y][virgin-volte] [Y][virgin-vowifi] 2 (Vodafone)
O2 [Y][o2-tube] [Y][o2-volte-vowifi]* [Y][o2-volte-vowifi]* 3
@LeoMcA
LeoMcA / search_for_deleted_files.sh
Last active July 8, 2021 15:02
Search for references in a codebase to files that have been modified/deleted in git. Requires ripgrep.
git diff --diff-filter=D --name-only HEAD | grep -o '[^/]*$' | while read line ; do rg -i "$line" . ; done
@LeoMcA
LeoMcA / nightly.desktop
Last active May 11, 2020 16:25
Firefox Nightly .desktop file
[Desktop Entry]
Version=1.0
Name=Nightly
GenericName=Web Browser
Comment=Browse the Web
Exec=/home/leo/.local/bin/nightly -P default-nightly %u
Icon=/home/leo/.local/share/nightly/browser/chrome/icons/default/default128.png
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
@LeoMcA
LeoMcA / mozilla.rake
Last active September 4, 2019 11:12
Migrate references to one s3 bucket to another on Discourse
# frozen_string_literal: true
# paste this file into /var/www/discourse/lib/tasks/mozilla.rake
# then run it with: rake mozilla:rebake_posts_with_upload["example.s3.dualstack.us-west-2.amazonaws.com"]
require "db_helper"
require "file_store/s3_store"
task "mozilla:rebake_posts_with_upload", [:s3_host] => :environment do |t, args|
s3_host = args[:s3_host]
@LeoMcA
LeoMcA / netflix-zoom.js
Created August 31, 2019 09:20
Zoom letterboxed Netflix content on an ultrawide display
// paste in console, give aspect ratio as the argument, here 2.2 is the aspect ratio of the source material
(x => document.querySelector(".VideoContainer video").style.height = `${x * 9 / 16 * 100}%`)(2.2)
@LeoMcA
LeoMcA / uk-eu-election-2019-result.js
Created May 26, 2019 22:53
Scrapes UK EU Election Data from BBC website, and adds up Leave and Remain (and Labour) votes
const fetch = require("node-fetch")
const cheerio = require("cheerio")
const url = "https://www.bbc.co.uk/news/topics/crjeqkdevwvt/the-uks-european-elections-2019"
var leave = [{ name: "Leave", value: 0 }]
var remain = [{ name: "Remain", value: 0 }]
var lexit = [{ name: "???", value: 0 }]
var other = [{ name: "Other", value: 0 }]
@LeoMcA
LeoMcA / decrypt.rb
Created January 13, 2019 19:58
decrypt rails session cookie (kinda)
require 'cgi'
require 'active_support'
require 'json'
# def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secret_key_base)
# cookie = CGI::unescape(cookie)
# # salt = 'authenticated encrypted cookie'
# salt = Rails.application.config.action_dispatch.encrypted_signed_cookie_salt
# encrypted_cookie_cipher = 'aes-256-gcm'
# serializer = ActiveSupport::MessageEncryptor::NullSerializer
@LeoMcA
LeoMcA / reverse_and_collate.sh
Created April 14, 2019 15:22
Collate two pdfs into one, with the second one reversed
#!/bin/sh
A= B= ; qpdf --empty --collate --pages $A $B z-1 -- out.pdf