Skip to content

Instantly share code, notes, and snippets.

Avatar

Cauterite Cauterite

  • Australia
View GitHub Profile
View aaa
DOMParser error detection test suite
userAgent: "Mozilla/5.0 (Android 7.1.2; Mobile; rv:66.0) Gecko/66.0 Firefox/66.0"
running 2606 tests
2606/2606 tests passed
View parseArrayIndex.js
const chAt = ``.charCodeAt;
const parseArrayIndex = function(s) {
/* assumes s is a string
if s is a valid index, returns parseInt(s)
otherwise returns some negative integer
s is valid if:
/^(0|[1-9][0-9]*)$/.test(s) && 0 <= parseInt(s) <= 0x7fffffff
@Cauterite
Cauterite / ext-all-debug.js
Created Nov 12, 2017
ext-all-debug.js (Deluge Web UI)
View ext-all-debug.js
This file has been truncated, but you can view the full file.
/**
* @class Ext.DomHelper
* Utility class for working with DOM and/or Templates. It transparently supports using HTML fragments or DOM.<br>
* This is an example, where an unordered list with 5 children items is appended to an existing element with id 'my-div':<br>
<pre><code>
var dh = Ext.DomHelper;
var list = dh.append('my-div', {
id: 'my-ul', tag: 'ul', cls: 'my-list', children: [
{tag: 'li', id: 'item0', html: 'List Item 0'},
View js-var-redeclare.js
(() => {
var f, g;
var x = 1;
f = () => x;
var x = 2;
g = () => x;
console.log(`f(): ${f()}`); // 2
console.log(`g(): ${g()}`); // 2
})();
View https-proxy-pac-uri
data:application/x-ns-proxy-autoconfig,function%20FindProxyForURL()%20{return%20"HTTPS%20example.com:3128;";}
View stackoverflow-44086843.js
$(`.form_datetime`).on(`dp.change`, X =>
$(`#epoch-start-time`).val(X.date.unix()));
View debian-multi-nic-setup.txt
--------------------------------------------------------------------------------
my ASUS P5Q-Premium, running Debian 8.8, has four ethernet ports. i only need to
use one at a time.
the labels "eth0", "eth1", etc. are assigned to these ports in seemingly random
order, and whether the numbering starts at 0 or 1 seems to be determined by the
presence of some other random PCI device present on the board, so it's hard to
know which eth# you're plugging the cable into.
View powershell-variable-capture-is-broken.ps1
set-strictmode -version 'latest'
$erroractionpreference = 'stop'
function main() {
$a = 'foo'
$f = {
$g = {$a}.getnewclosure()
& $g # "variable '$a' cannot be retrieved because it has not been set."
}.getnewclosure()
& $f
View powershell-dynamic-scoping-is-super-lame.ps1
function a($f) {& $f}
function main() {
$f = {write-host 'success'}
a {& $f} # stack-overflow
a {& $f}.getnewclosure() # okay
}
[void] (main)
View checkhealth-task-control.ps1
# ------------------------------------------------------------------------------
# Leopard Systems ? (2017)
# contributors: Adam Laing
# note: requires powershell 2.0 or later
set-strictmode -version 'latest'
$erroractionpreference = 'stop'