Skip to content

Instantly share code, notes, and snippets.

@SgtPooki
SgtPooki / vanilla-observable.ts
Created Dec 16, 2021
Typescript version of a simple Observable. This was copied from https://stackoverflow.com/a/62002044/592760, translated to TypeScript, and improved.
View vanilla-observable.ts
/**
* Modified by Russell Dempsey on 2021 DEC 15
* @see https://stackoverflow.com/a/62002044/592760
*/
type Subscriber<T> = (value: T) => void;
class Observable<T> {
private subscribers = new Set<Subscriber<T>>();
constructor(private value: T) {}
@SgtPooki
SgtPooki / add_to_cart.user.js
Last active Nov 8, 2021 — forked from beporter/add_to_cart.user.js
Greasemonkey script to repeatedly refresh a given page, look for specific "Add to Cart" buttons, click them if present, and make a lot of noise on success.
View add_to_cart.user.js
// ==UserScript==
// @name Add Saved Items to Cart
// @namespace https://gist.github.com/beporter/ce76204bcba35d9edb66b395bb5e9305
// @version 0.5
// @description Repeatedly refresh a given "saved items" page (Amazon, Walmart, BestBuy), look for specific "Add to Cart" buttons, click them if present, and make a lot of noise on success.
// @author https://github.com/beporter
// @match https://www.amazon.com/gp/registry/wishlist/*
// @match https://www.amazon.com/hz/wishlist/ls/*
// @match https://www.bestbuy.com/cart
// @match https://www.bestbuy.com/site/customer/lists/manage/saveditems
View html-table-to-markdown-extra.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML Table to Markdown Extra Table</title>
<style type="text/css">
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;}
body { font-family: -apple-system, "Segoe UI", Arial, Helvetica, sans-serif; line-height: 1.5;
text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
textarea { width: 100%; height: 15em; }
@SgtPooki
SgtPooki / node-tar.js
Last active Jan 21, 2021 — forked from mafintosh/node-tar.js
tar-fs vs node-tar benchmarks
View node-tar.js
// does not work...
var tar = require('tar');
var fstream = require('fstream');
var input = `node_modules`;
var reader = fstream.Reader({type: "Directory", path: input});
var pack = tar.Pack();
reader.pipe(pack).pipe(tar.Extract({path: '/tmp/destination-node-tar'}));
View SketchSystems.spec
MyElement
Hover
HStill
HMoving
onMouseOut -> MouseOutside
onMouseMove -> HMoving
onMouseStop -> HStill
MouseOutside*
onMouseEnter -> HMoving
@SgtPooki
SgtPooki / findVersions.js
Created Aug 4, 2018
Find names and versions of root modules and typings in your project. This checks all package.json files (at the root level of the directories) and outputs the name and version found in the relevant package.json file
View findVersions.js
const glob = require('glob');
const globPromise = (string) => new Promise((resolve, reject) => {
glob(string, (error, result) => {
if (error) {
reject(error);
}
resolve(result);
});
});
@SgtPooki
SgtPooki / gist:b4e1d46d624ee0a0d0260d0819ae03c5
Created Aug 4, 2018
Find names and versions of root modules and typings in your project.
View gist:b4e1d46d624ee0a0d0260d0819ae03c5
const glob = require('glob');
const globPromise = (string) => new Promise((resolve, reject) => {
glob(string, (error, result) => {
if (error) {
reject(error);
}
resolve(result);
});
});
@SgtPooki
SgtPooki / userChrome.css
Created Jan 11, 2018
Tree Style Tab - top tab bar removal
View userChrome.css
#TabsToolbar {
visibility: collapse !important;
}
#main-window[tabsintitlebar]:not([sizemode="fullscreen"]) #TabsToolbar:not([collapsed="true"]) + #nav-bar:not(:-moz-lwtheme) {
background-clip: padding-box;
position: relative;
z-index: 1;
padding-left: 67px;
}
@SgtPooki
SgtPooki / getFreeOreillyBooks.js
Last active Jun 7, 2019
Script to automatically download free ebooks listed on oreilly
View getFreeOreillyBooks.js
/*
Just paste into your console.. or make a tampermonkey/greasemonkey script out of it.
Only tested in Chrome. Be careful.. three tabs are opened per book.
If a books image is not removed, you'll need to try to download that book yourself.
Use this script (enter into the console of your browser) on the following pages:
http://www.oreilly.com/programming/free/
http://www.oreilly.com/business/free/
View promiseDebounce.js
/*
Debounce promises.
Prevents multiple calls if the request is the same and either:
1. the promise has not resolved yet
2. a delay of {timeout} milliseconds has not passed since the last call
The call identity is dependent upon a key created with JSON.stringify(arguments)
*/
var debouncePromise = function debouncePromise(methodName, promise, throttleTimeout) {