Skip to content

Instantly share code, notes, and snippets.

View WillsB3's full-sized avatar

Wills Bithrey WillsB3

View GitHub Profile
/**
* This file can be used to reformat the output of https://www.npmjs.com/package/diff-package-lock
* so that the diff can be displayed with diff syntax highlighting in a GitHub
* PR.
*
* How do I use this?
* 1. Download this script to your local machine
* 2. Run `npx diff-package-lock main`
* 3. Copy and paste the output into a new file: package-diff.txt (required as
* diff-package-lock doesn't let us disable colorization of its output).
  1. Install BackgroundMusic
  2. Set your default output device to Background Music in MacOS Sound settings
  3. In the MacOS built in screen recorder (cmd+shift+5) select "Options" and select "Background Music" under "Microphone"
  4. Start your recording
@WillsB3
WillsB3 / django-translation-patch.py
Last active April 6, 2020 08:24
Django patch to help with testing that content is correctly marked up for translation
# django/utils/translation/trans_real.py
#
# Add the following to the end of the `do_translate` method (~line 316 in Django 1.11.27), just after the eol_message assignment.
#
# This replaces characters within content marked up for translation with `#`. The idea is that, with this
# patch applied, you can browse the site and look for any copy that has not been replaced with `#`. Any
# copy you find will not yet have been marked up for translation.
import re
return re.sub(r'[^ ]', r'#', message)
@WillsB3
WillsB3 / sample.js
Created September 14, 2017 08:23
Custom exception creation and usage in JavaScript
// From http://eloquentjavascript.net/08_error.html
// Error definition
function InputError(message) {
this.message = message;
this.stack = (new Error()).stack;
}
InputError.prototype = Object.create(Error.prototype);
InputError.prototype.name = "InputError";
@WillsB3
WillsB3 / README.md
Last active January 20, 2023 21:11
USwitch Mobile Phone Data Scraper Snippet

USwitch Mobile Phone Data Scraper Snippet

Description

Find the best Pay Montly deals for the iPhone 6SE in the UK. See an example sheet created using this script on http://www.uswitch.com/mobiles/deals/apple_iphone_se_64gb_rose_gold/ for the 64GB Rose Gold 6SE: https://docs.google.com/spreadsheets/d/1WICZ8bqps4Pwb-QRcLr7scEP5zd7CgtYTeRF82hZflw/edit#gid=883967046.

How to use:

  1. Go to a USwitch search results page (such as http://www.uswitch.com/mobiles/deals/apple_iphone_se_64gb_rose_gold/). Click "Load More" until no more results are offered.
  2. Add this Javascript as a Dev Tools snippet, or just copy & paste it into your Dev Tools console and execute it to get a the data in a tab separated string.
var parsedDeals = [];
var csv = '';
var dealRows = $('.table-row');
var fields = ['network', 'duration', 'monthly', 'upfront', 'data', 'mins', 'texts', 'cashback', 'url'];
fields.forEach(function(f, i, a) {
csv += f + '\t';
});
csv += '\n';
@WillsB3
WillsB3 / Analysing CSS3 Animation Performance in the IOS Simulator
Last active December 12, 2015 06:39
Run this from your terminal to have GPU composited layers drawn red. Great for debugging CSS3 animations and ensuring they are being rendered by the GPU. Tested on iOS Simulator 6.0 (Earlier Versions stored the Simulator outside of XCode.app)
iOS Simulator (iPhone/iPad)
CA_COLOR_OPAQUE=1 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator
Safari (Mac OSX)
CA_COLOR_OPAQUE=1 /Applications/Safari.app/Contents/MacOS/Safari