Skip to content

Instantly share code, notes, and snippets.

@Rob--W
Rob--W / installChrome.vbs
Created June 6, 2012 15:20
VB script to automate the installation, configuration and launch of Google Chrome
' Author: Rob W <gwnRob@gmail.com>
' License: Creative Commons 3.0 with attribution
' http://creativecommons.org/licenses/by/3.0/
'
' My own use case:
' For browser-testing purposes, I've set up a Win XP Virtual Machine
' (http://stackoverflow.com/q/10541225). My Chrome installers are
' located in a virtual share, at \\VBOXSRV\WinShared\WinXPDev\Chrome\
' When I need to test an old Chrome version, I launch this script, which
' automatically installs and configures Chrome.
@Rob--W
Rob--W / .bashrc
Last active July 1, 2022 14:52
upto / jd to quickly navigate between directories in bash.
# Based on http://unix.stackexchange.com/questions/14303/bash-cd-up-until-in-certain-folder/14311#14311
# Jump to closest matching parent directory
upto () {
if [ -z "$1" ]; then
return
fi
local upto=$@
cd "${PWD/\/$upto\/*//$upto}"
}
# Auto-completion
@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 / dl-chrome.sh
Created January 23, 2014 12:03
Download a particular version of Google Chrome from Old Apps
#!/bin/sh
# @author Rob Wu <gwnRob@gmail.com> (https://robwu.nl)
version=$1
if [[ "${version}" != *"."* ]] ; then
echo "Repeat the command with an exact version:"
suffix="[0-9.]*"
# Version not specified in $1
[ -z $version ] && suffix="[0-9][0-9.]+"
curl -s http://www.oldapps.com/google_chrome.php | grep -oP "google_chrome.php\?old_chrome=[0-9]+\">[A-Za-z ]+\K${version}${suffix}( [A-Za-z()]+)?" -m 10
elif [ -e "${version}_chrome_installer.exe" ] ; then
@Rob--W
Rob--W / background.js
Created March 20, 2014 00:05
Implementation example of writable response bodies for Chromium extensions (API draft).
/**
* Implementation example of writable response bodies.
* Based on the draft of the Streams API (19 March 2014)
* https://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm
* Design document for response body reading/writing:
* https://docs.google.com/document/d/1iE6M-YSmPtMOsec7pR-ILWveQie8JQQXTm15JKEcUT8
*/
/* globals chrome, ByteStream, URL, XMLHttpRequest */
'use strict';
@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 / html5-formdata-polyfilll.js
Created May 27, 2014 22:07
FormData polyfill for Web Workers.
/*
* FormData for XMLHttpRequest 2 - Polyfill for Web Worker
* (c) 2014 Rob Wu <rob@robwu.nl>
* License: MIT
* - append(name, value[, filename])
* - XMLHttpRequest.prototype.send(object FormData)
*
* Specification: http://www.w3.org/TR/XMLHttpRequest/#formdata
* http://www.w3.org/TR/XMLHttpRequest/#the-send-method
* The .append() implementation also accepts Uint8Array and ArrayBuffer objects
@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