Skip to content

Instantly share code, notes, and snippets.

View mozfreddyb's full-sized avatar

Frederik Braun mozfreddyb

View GitHub Profile
@mozfreddyb
mozfreddyb / csmlogparser.py
Last active January 27, 2021 14:44
parse entries from MOZ_LOG CSMLog entries
#!/usr/bin/env python3
import yaml
import sys
from functools import reduce
def lines_into_blocks():
consume_into_block = False
block = []
@mozfreddyb
mozfreddyb / foo.js
Last active February 22, 2021 12:37
turn searchfox results object into audit spreadsheet
/* This script can be run on a searchfox.org results page as it is.
* the results.normal from line 9 is already in global scope and can be iterated as it is
* Note that this "results.normal" does /not/ include occurences in tests or generated code.
* Use other properties of the "results" object instead, if you need these.
*/
// objkey is something like "Uses (searchterm)"
objkey = Object.keys(results.normal)[0];
occs = results.normal[objkey];
t = [];
@mozfreddyb
mozfreddyb / add-ca-cert.js
Created July 10, 2017 12:09
privileged JS for Firefox to add a certificate as a trusted CA
if (typeof Cc == "undefined") { Cc = Components.classes; }
if (typeof Cu == "undefined") { Cu = Components.utils; }
if (typeof Ci == "undefined") { Ci = Components.interfaces; }
const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
const nsIX509Cert = Ci.nsIX509Cert;
const nsIX509CertDB = Ci.nsIX509CertDB;
const certdb = Cc[nsX509CertDB].getService(nsIX509CertDB);
let certstring = `-----BEGIN CERTIFICATE-----
@mozfreddyb
mozfreddyb / vimdiff.md
Last active December 13, 2022 11:57 — forked from mattratleph/vimdiff.md
vimdiff cheat sheet

vimdiff cheat sheet

git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@mozfreddyb
mozfreddyb / random_string.js
Created April 15, 2016 09:32
generate random strings, e.g., for passwords
/*
in one line for bookmarkletts:
javascript:!function(){"use strict";function r(){var r=new Uint8Array(n);window.crypto.getRandomValues(r);var r=Array.apply([],r);return r=r.filter(function(r){return r>32&&127>r}),String.fromCharCode.apply(String,r)}for(var n=50,t=20,a=r();a.length<t;)a+=r();prompt("",a)}();
*/
(function() {
"use strict";
var MAXLEN=50; /* tweak this */
var MINLEN=20;
function genString() {