Skip to content

Instantly share code, notes, and snippets.

@Rob--W
Rob--W / mozilla-gecko-git-setup-with-mercurial-bundles.md
Created Oct 15, 2020
Tutorial to walk through the creation of a Git repository for Firefox/Gecko development, initialized from a Mercurial bundle.
View mozilla-gecko-git-setup-with-mercurial-bundles.md

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. If you have trouble with that step, an alternative is to use Mercurial Bundles once, to initialize the repository.

This tutorial walks you through the creation of a gecko repository for Firefox/Gecko development, initialized using Mercurial Bundles. 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 14th, 2020: 1.2GB for the bundle, 7GB for the repository, and a bit more for dependencies and creating an [ar

@Rob--W
Rob--W / manifest.json
Created Aug 2, 2019
Dummy extension to prevent elision of "http" / "file" / subdomains from the omnibox in Chrome. Use this instead of the "Suspicious Site Reporter".
View manifest.json
// 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 Oct 14, 2018
Feature-detect availability of viewTypes property in browser.menus API
View detect-menus-viewTypes.js
// 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 Jul 27, 2018
Usage of "contexts" in the contextMenus / menus API in public add-ons at addons.mozilla.org
View contextMenus-context-usages.txt
$ ### 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 Nov 16, 2017
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
View vim8_0_1272_force_rundo.diff
commit 4775e38f78c7990306fd67fa1145433bb4779722
Author: Rob Wu <rob@robwu.nl>
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 Nov 14, 2016
Example of safe HTML escaping using template literals
View escaopeHTMLTag.js
/* 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 Aug 8, 2020
Analysis of WOT 20151208
View README.md
@Rob--W
Rob--W / npm-download-only.sh
Created Dec 9, 2015
Downloads and extracts specific npm package without dependencies or hooks.
View npm-download-only.sh
#!/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. package@1.0.0) 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 Sep 17, 2014
Detect whether PDF.js extension is installed in Google Chrome, Chromium or Opera.
View detect-pdfjs-chromium.js
/**
* 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 <rob@robwu.nl> (https://robwu.nl)
* Public domain - all rights waived.
*/
function isPDFJSExtensionInstalled(callback) {
@Rob--W
Rob--W / .hgrc
Last active Aug 29, 2015
"git commit -v" for hg (Mecurial) (appends the diff of the changeset to the hg message)
View .hgrc
[ui]
# Usage: Assuming that you've saved hgeditor as ~/.mercurial/hgeditor
editor = ~/.mercurial/hgeditor
You can’t perform that action at this time.