Skip to content

Instantly share code, notes, and snippets.

View svidgen's full-sized avatar
🤔
Analysis paralysis perpetualysis.

Jon Wire svidgen

🤔
Analysis paralysis perpetualysis.
View GitHub Profile
@svidgen
svidgen / .bashrc
Last active August 29, 2021 16:13
multiline pixelbook (bash) prompt
if [ "$color_prompt" = yes ]; then
# this one should be active. it is ...
# <blue>directory</blue><br /><green>user@host</green>$
PS1='\n\[\033[00;34m\]\w\[\033[00m\]\n${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
@svidgen
svidgen / observe.js
Last active May 6, 2021 03:52
example of the new observe/infect/curse implementation i'll be using in my DOM lib
/*
* Infects an object with a multi-cast property and method "mirroring".
*
* ```
* observe(source, ['property_a', 'property_b', 'method_a']).mirror(target);
* ```
*
* The `target` object will be invoked with the same calls/values as those
* made against the `source` on the listed properties and methods -- or
* ALL enumerable properties and methods if non are given.

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@svidgen
svidgen / example.js
Last active May 1, 2021 02:51
Watch for removal of a node from the document body
var node = document.createElement('div');
node.innerHTML = "you know. hwhatever";
document.body.insertBefore(node, document.body.firstElementChild);
var subnode1 = document.createElement('div');
subnode1.innerHTML = "you know. hwhatever again (1)";
node.appendChild(subnode1);
var subnode2 = document.createElement('div');
subnode2.innerHTML = "you know. hwhatever again (2)";
@svidgen
svidgen / __overload.js
Last active April 4, 2021 00:43
Function overloading in JavaScript
var overload = function(...overloads) {
const f = function(...args) {
let constructorArray = args.map(arg => arg.constructor);
let implIndex = f.overloads.findIndex(sig => {
return constructorArray.length === sig.length &&
constructorArray.every((o,i) => o === sig[i])
;
}) + 1;
if (implIndex > 0 && typeof(f.overloads[implIndex]) === 'function') {
return f.overloads[implIndex].apply({}, args);
@svidgen
svidgen / README.md
Last active May 25, 2021 18:27
copy page link with optional text selection

Install

  1. Copy the minified bookmarklet code.
  2. Add a page/link to your bookmarks toolbar.
  3. Paste the code.
  4. Save.
  5. Profit.

Basic Usage

from copy import deepcopy
def insert_dict_leaves(source, additions):
rv = deepcopy(source)
for k, v in additions.items():
if not (k in rv and isinstance(rv[k], dict)):
rv[k] = v
elif isinstance(v, dict):
rv[k] = insert_dict_leaves(rv[k], v)
else:
def map_dict_leafs(d, f):
rv = {}
for k, v in d.items():
if isinstance(v, dict):
rv[k] = map_dict_leafs(v, f)
else:
rv[k] = f(v)
return rv