Skip to content

Instantly share code, notes, and snippets.

@Rob--W
Rob--W / mozilla-gecko-git-setup-with-mercurial-bundles.md
Last active October 22, 2020 16:56
Tutorial to walk through the creation of a Git repository for Firefox/Gecko development, initialized from a git bundle.

The git-cinnabar wiki explains how to set up a repository for Firefox development in Mozilla: A git workflow for Gecko development. The first step of that tutorial, git clone hg::https://hg.mozilla.org/mozilla-unified gecko may fail if your internet connection is unreliable. Mercurial Bundles are an alternative but take 3 hours to initialize. Git bundles for Mozilla development are also available and a recommended alternative.

This tutorial walks you through the creation of a gecko repository for Firefox/Gecko development, initialized using a Git Bundle. Commands are shown on the lines starting with $, and the output is shown for reference. You can copy and paste the command in the shell.

You need at least 10 GB of free disk space for this. On October 22nd, 2020: 3.2GB for the bundle, 7GB for the repository, and a bit more f

@Rob--W
Rob--W / manifest.json
Created August 2, 2019 15:20
Dummy extension to prevent elision of "http" / "file" / subdomains from the omnibox in Chrome. Use this instead of the "Suspicious Site Reporter".
// This is a dummy extension that prevents elision of "http" / "file" / subdomains
// from the omnibox by impersonating the "Suspicious Site Reporter" extension.
// Do not use this if you use the "Suspicious Site Reporter" extension.
//
// Usage:
// 1. Create a directory, e.g. "prevent-elision-in-locationbar"
// 2. Put the content of this file as "manifest.json" in that directory.
// 3. Visit chrome://extensions, choose the "Load Unpacked" button and select the directory.
// (OR use the --load-extension=path/to/prevent-elision-in-locationbar flag to load the extension)
// Result:
@Rob--W
Rob--W / detect-menus-viewTypes.js
Created October 14, 2018 10:15
Feature-detect availability of viewTypes property in browser.menus API
// Example: How to feature-detect a new property (viewTypes) in the menus API
// Feature introduced in Firefox 64.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1416839
// // Minimal usage example:
// let menuCreateParams = {
// title: "some menu item meant for the sidebar",
// viewTypes: ["sidebar"],
// };
// if (!supportsMenuViewTypes()) {
@Rob--W
Rob--W / contextMenus-context-usages.txt
Created July 27, 2018 21:06
Usage of "contexts" in the contextMenus / menus API in public add-ons at addons.mozilla.org
$ ### This is a rough estimate of the values of the "contexts" array in extensions,
$ ### presumably used as values in the contextMenus/menus.create/update API.
$ ### First, we check whether the number of reported occurrences is significant,
$ ### by checking the number of "contexts:" strings that are not followed by an array.
$ ### As the first checks show, only 10% of the matches are not arrays,
$ ### (so they are variables, expressions or not part of the menus API).
$ ### The other 90% are arrays, and significant.
$ ### LIMITATIONS
@Rob--W
Rob--W / vim8_0_1272_force_rundo.diff
Created November 16, 2017 18:21
Patch to allow vim to use any undo file. Usage: Create a file with many blank lines and use :rundo! path/to/undo/file . Then use u or r to undo/redo
commit 4775e38f78c7990306fd67fa1145433bb4779722
Author: Rob Wu <[email protected]>
Date: Thu Nov 16 12:50:10 2017 +0100
Add :rundo! support
Based on https://groups.google.com/d/msg/vim_use/pOia0eB8ZWo/FmIQ4lUOPDIJ
Written for https://github.com/vim/vim/archive/v8.0.1272.tar.gz
@Rob--W
Rob--W / escaopeHTMLTag.js
Created November 14, 2016 16:39
Example of safe HTML escaping using template literals
/* Example:
var someUnsafeStr = '<img>';
var result = escapeHTMLTag`<input value="${someUnsafeStr}">`;
console.log(result); // <input value="&lt;img&gt;">
// Questions? rob {at} robwu.nl
// */
function escapeHTML(str) {
// Note: string cast using String; may throw if `str` is non-serializable, e.g. a Symbol.
@Rob--W
Rob--W / README.md
Last active August 8, 2020 03:02
Analysis of WOT 20151208
@Rob--W
Rob--W / npm-download-only.sh
Created December 9, 2015 11:40
Downloads and extracts specific npm package without dependencies or hooks.
#!/bin/bash
# Downloads and extracts specific npm package without dependencies or hooks.
# Usage:
# npm-download-only [package1] [package2] ...
# where package can be a specific version (e.g. [email protected]) or package.
#
# Written on 9 dec 2015 by Rob Wu (https://robwu.nl)
for arg in "$@"
do
@Rob--W
Rob--W / detect-pdfjs-chromium.js
Created September 17, 2014 13:39
Detect whether PDF.js extension is installed in Google Chrome, Chromium or Opera.
/**
* Detects whether the PDF.js Chromium extension is installed in the browser.
* Example: isPDFJSExtensionInstalled(function(result) { alert('Is PDF.js installed? ' + result);});
*
* @param {function(boolean)} callback - Called when the detection completed.
*
* Author: Rob Wu <[email protected]> (https://robwu.nl)
* Public domain - all rights waived.
*/
function isPDFJSExtensionInstalled(callback) {
@Rob--W
Rob--W / .hgrc
Last active August 29, 2015 14:04
"git commit -v" for hg (Mecurial) (appends the diff of the changeset to the hg message)
[ui]
# Usage: Assuming that you've saved hgeditor as ~/.mercurial/hgeditor
editor = ~/.mercurial/hgeditor