Skip to content

Instantly share code, notes, and snippets.


Leo McArdle LeoMcA

View GitHub Profile
LeoMcA / mozilla.rake
Last active Sep 4, 2019
Migrate references to one s3 bucket to another on Discourse
View mozilla.rake
# 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[""]
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 / netflix-zoom.js
Created Aug 31, 2019
Zoom letterboxed Netflix content on an ultrawide display
View netflix-zoom.js
// 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 / uk-eu-election-2019-result.js
Created May 26, 2019
Scrapes UK EU Election Data from BBC website, and adds up Leave and Remain (and Labour) votes
View uk-eu-election-2019-result.js
const fetch = require("node-fetch")
const cheerio = require("cheerio")
const url = ""
var leave = [{ name: "Leave", value: 0 }]
var remain = [{ name: "Remain", value: 0 }]
var lexit = [{ name: "???", value: 0 }]
var other = [{ name: "Other", value: 0 }]
LeoMcA /
Created Apr 14, 2019
Collate two pdfs into one, with the second one reversed
A= B= ; qpdf --empty --collate --pages $A $B z-1 -- out.pdf
LeoMcA / decrypt.rb
Created Jan 13, 2019
decrypt rails session cookie (kinda)
View decrypt.rb
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 / nightly.desktop
Last active May 11, 2020
Firefox Nightly .desktop file
View nightly.desktop
[Desktop Entry]
GenericName=Web Browser
Comment=Browse the Web
Exec=/home/leo/.local/bin/nightly -P default-nightly %u
LeoMcA / discourse-category-statistics.sql
Last active Jul 2, 2018
Get notification level statistics for a Discourse category
View discourse-category-statistics.sql
SELECT replace(replace(replace(replace(replace(cast(notification_level AS varchar), '0', 'muted'), '1', 'regular'), '2', 'tracking'), '3', 'watching'), '4', 'watching first post') AS notification_level, count(*) FROM category_users WHERE category_id=(SELECT id FROM categories WHERE slug='development' AND parent_category_id=(SELECT id FROM categories WHERE slug='add-ons' AND parent_category_id IS NULL)) GROUP BY notification_level;
LeoMcA /
Created Jun 7, 2017
Setup git remotes for easy pushing like you're fetching
echo "What should this computer be called?"
read this_name
echo "What should the other computer be called?"
read that_name
echo "What's the hostname of the other computer?"
read that_hostname
echo "What's the path to the respository on this computer?"
read this_path
LeoMcA / migrate_bucket.rb
Last active Jan 24, 2017
Mozilla Discourse: migrate images from old bucket to new
View migrate_bucket.rb
PostUpload.all.each do |post_upload|
Jobs.enqueue(:pull_hotlinked_images, post_id: unless
View gist:0e92073d37c23c695c5d9b66f80f171a
- git clone
- cd discourse-auth0-mozilla
- git checkout 2de31ec2442c4dabf4fc2561b6413b4651af65d4
- cd ../