Skip to content

Instantly share code, notes, and snippets.

@Rob--W
Rob--W / .screen.sh
Created March 24, 2014 11:29
Go to current directory when you open screen or a new tab in screen.
#!/bin/bash
# The file where the PWD is going to be shared with other (new) tabs.
STY_SHARED_PWD="/tmp/.screenpwd-$STY"
if [ -e "$STY_SHARED_PWD" ] ; then
# If the file exists, then another session had already set the
# environment, so read the most recent PWD and go to the directory.
STY_PWD="$(</tmp/.screenpwd-$STY)"
# Provided that it's not empty.
[ -n "$STY_PWD" ] && cd "$STY_PWD"
fi
@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
@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 <rob@robwu.nl> (https://robwu.nl)
* Public domain - all rights waived.
*/
function isPDFJSExtensionInstalled(callback) {
@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. 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 / 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 <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 / 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 / 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 / webkitNotifications-shim.js
Last active April 27, 2020 01:12
Full implementation of webkitNotifications API for Firefox 22+.
// ==UserScript==
// @name webkitNotifications shim for Firefox 22+
// @namespace https://github.com/Rob--w/
// @author Rob Wu <gwnRob@gmail.com>
// @description Enable desktop notifications on Firefox 22+ for websites which use the webkitNotification API.
// @include *
// @version 1.0.2
// @grant none
// ==/UserScript==
@Rob--W
Rob--W / README.md
Last active August 8, 2020 03:02
Analysis of WOT 20151208
@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