Skip to content

Instantly share code, notes, and snippets.

View retrohacker's full-sized avatar

William Blankenship retrohacker

View GitHub Profile
#!/bin/bash
RED="\033[41m \033[0m"
GREEN="\033[42m \033[0m"
GAP=" "
birthdate="[ENTER DATE HERE]"
name="[ENTER NAME HERE]"
life_expectancy=65
@retrohacker
retrohacker / Template.js
Created January 17, 2023 20:45
Frontend framework
class Template {
constructor(id, mount) {
if (id) {
this.fragment = document.getElementById(id).content.cloneNode(true);
}
this.mount = mount;
this.eventHandlers = {};
this.children = {};
}
async addChild(name, child) {
@retrohacker
retrohacker / main.js
Last active June 2, 2022 18:19
Handling dynamic content with greasemonkey
// ==UserScript==
// @name Apply rules to dynamically loaded content
// @version 1
// @grant none
// ==/UserScript==
// Create a new mutation observer
const observer = new window.MutationObserver(() => {
// Apply your rules here
@retrohacker
retrohacker / index.test.js
Created July 21, 2020 20:16
power-assert with tape output
const test = require('ava')
test('Should render power-assert', async t => {
const three = 3;
const x = [1,2,3]
t.assert(x.length > three, 'rendering power-assert')
})
@retrohacker
retrohacker / index.js
Created February 6, 2020 18:00
Modify a tarball's header content
const fs = require('fs');
const Header = require('tar/lib/header');
const fd = fs.openSync('./service.tar', 'r+');
const childProcess = require('child_process');
const args = require('yargs')
.option('u', {
alias: 'user',
demandOption: true,
describe: 'the user to set permission bits to',
@retrohacker
retrohacker / compress.sh
Last active August 21, 2019 00:54
Using patch files for storing the npm registry
#!/bin/bash
# Remove anything that may have been left over by a previous run
rm -rf patch orig new
mkdir patch
for TARBALL in `ls - | node semver-sort.js`
do
tar -xzf "./-/${TARBALL}"
@retrohacker
retrohacker / solarized_mocha
Created January 24, 2019 21:53
Make all mocha dependencies in your project solarized friendly
#!/bin/bash
# Save this in your path as `solarized_mocha` and then run `solarized_mocha` in the root of your project
find . -name mocha -type d | xargs -I{} sed -i 's|\(.*:\) 90|\1 92|g' {}/mocha.js {}/lib/reporters/base.js
@retrohacker
retrohacker / async-order.js
Last active April 17, 2017 21:38
async-order
function loadFile() { // 1
fs.readFile('./foobar.txt', 'utf8', saveFile); // 5
}
function saveFile(e, contents) { // 2
if(e) { // 6
// Stop executing function, we encountered an error
return console.error(e); // 7
} // 8
fs.saveFile('./buzzbazz.txt', 'utf8', done); // 9
@retrohacker
retrohacker / config.json
Created March 30, 2017 18:01
storj-fuse
{
"privateKey": "[PRIVATE_KEY]",
"publicKey": "[PUBLIC_KEY]",
"encryptionKey": "[ENCRYPTION_KEY]"
}
### Keybase proof
I hereby claim:
* I am retrohacker on github.
* I am retrohacker (https://keybase.io/retrohacker) on keybase.
* I have a public key ASBV4vwsEVtKRg2DmXkhKUZ1KUOsyCNIdwsOSgs2xdfV1Ao
To claim this, I am signing this object: