Skip to content

Instantly share code, notes, and snippets.

View LeoMcA's full-sized avatar

Leo McArdle LeoMcA

View GitHub Profile
@LeoMcA
LeoMcA / discourse-category-statistics.sql
Last active July 2, 2018 09:34
Get notification level statistics for a Discourse category
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
LeoMcA / setup-local-remotes.sh
Created June 7, 2017 07:51
Setup git remotes for easy pushing like you're fetching
#!/bin/sh
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
LeoMcA / migrate_bucket.rb
Last active January 24, 2017 11:29
Mozilla Discourse: migrate images from old bucket to new
PostUpload.all.each do |post_upload|
Jobs.enqueue(:pull_hotlinked_images, post_id: post_upload.post.id) unless post_upload.post.nil?
end
- git clone https://github.com/LeoMcA/discourse-auth0-mozilla.git
- cd discourse-auth0-mozilla
- git checkout 2de31ec2442c4dabf4fc2561b6413b4651af65d4
- cd ../
.category-mozillians-nda {
.d-header {
background: #5a166f;
.title:after {
content: 'NDA';
color: #fff;
font-weight: bold;
font-size: 28px;
position: relative;
https://github.com/LeoMcA/namati-user-card-profile-theme
@LeoMcA
LeoMcA / gist:bc31922229cf39a7f9a6
Last active August 29, 2015 14:22
Hash/checksum generation in client side JS
function createHexHash (algo, arrayBuffer, callback) {
if (Object.prototype.toString.call(arrayBuffer) == '[object String]') {
var encoder = new TextEncoder('utf-8')
arrayBuffer = encoder.encode(arrayBuffer)
}
crypto.subtle.digest(algo, arrayBuffer).then(function (hash) {
var hex = ""
var array = new Uint8Array(hash)
for (var i = 0; i < array.byteLength; i++) {
var byte = array[i]
@LeoMcA
LeoMcA / phpbb3.rb
Created May 22, 2015 20:24
AMO forum Discourse import script
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
class ImportScripts::PhpBB3 < ImportScripts::Base
ARCHIVE_ID = 0
INTRODUCTION_ID = 22
PHPBB_DB = "phpbb"
BATCH_SIZE = 1000
This file has been truncated, but you can view the full file.
{
"ECIDsToParties": {
"INDPT": "Independent",
"PP85": "UK Independence Party (UKIP)",
"PP90": "Liberal Democrats",
"PP52": "Conservative Party",
"PP804": "Trade Unionist and Socialist Coalition",
"PP77": "Plaid Cymru - The Party of Wales",
"PP73": "Socialist Labour Party",
@LeoMcA
LeoMcA / testcase.js
Created April 29, 2015 19:12
Test Case to show node-webrtc failing to send large arraybuffers
var webrtc = require('wrtc');
var RTCPeerConnection = webrtc.RTCPeerConnection;
var RTCSessionDescription = webrtc.RTCSessionDescription;
var RTCIceCandidate = webrtc.RTCIceCandidate;
var pc1 = new RTCPeerConnection();
var pc2 = new RTCPeerConnection();
pc1.onicecandidate = function(candidate) {