Skip to content

Instantly share code, notes, and snippets.

@nijotz
nijotz / syntax.js
Last active May 22, 2020
Screw it, we're re-writing it in Rust
View syntax.js
/* * * * * * * * * * * * * * * * * * * * * *
* First try
*/
let {skip, secret} = getTestSecret('LICENSE')
tap.test('first test', {skip}, (t) => {
//...
})
// Doesn't like the leading brace, thinks it's a code block
{skip, secret} = getTestSecret('OTHER_LICENSE')
@nijotz
nijotz / gist:716b99b8d28d03cf5f2e3e80adfd3a34
Created Nov 7, 2019
Block YouTube recommendations at the end of the video and on the side
View gist:716b99b8d28d03cf5f2e3e80adfd3a34
! 7/4/2019 https://www.youtube.com
www.youtube.com##ytd-compact-video-renderer > #dismissable
www.youtube.com##ytd-compact-radio-renderer > #dismissable
www.youtube.com##.ytp-endscreen-content
View promises.js
// cleaner output, but same results without
const Promise = require('bluebird');
// What is the best way to run async functions
// * in parallel
// * fail fast
// * not have unhandled promises
// * single failure path (try/catch)
// ?
View lol-promises.js
function sleepReject(time, msg) {
return new Promise((resolve, reject) => {
setTimeout(() => reject(msg || 'reject'), time);
});
}
async function test() {
try {
let valuePromises1 = [1000, 2000, 3000].map(x => sleepReject(x));
let valuePromises2 = [4000, 5000].map(x => sleepReject(x));
View promises.js
function sleepReject(time, msg) {
return new Promise((resolve, reject) => {
setTimeout(() => reject(msg || 'reject'), time);
});
}
async function test() {
try {
let valuePromises1 = [1000, 2000, 3000].map(x => sleepReject(x));
View promises.js
function sleepReject(time, msg) {
return new Promise((resolve, reject) => {
setTimeout(() => reject(msg || 'reject'), time);
});
}
async function test() {
try {
let valuePromises1 = [1000, 2000, 3000].map(x => sleepReject(x));
let valuePromises2 = [4000, 5000].map(x => sleepReject(x));
View promises.js
async function test() {
var p1 = new Promise((resolve, reject) => {
setTimeout(() => reject('one'), 1000);
});
var p2 = new Promise((resolve, reject) => {
setTimeout(() => reject('two'), 2000);
});
var p3 = new Promise((resolve, reject) => {
setTimeout(() => reject('three'), 3000);
});
@nijotz
nijotz / ublockfilter.txt
Created Jul 10, 2019
purge temptations from youtube
View ublockfilter.txt
! 7/1/2019 https://www.youtube.com
www.youtube.com###dismissable
www.youtube.com##.ytp-endscreen-content
www.youtube.com##ytd-compact-playlist-renderer.ytd-watch-next-secondary-results-renderer.style-scope
www.youtube.com##.use-ellipsis.ytd-watch-next-secondary-results-renderer.style-scope
View gist:145784abbd0b58ae5d7efa94f1aae087
python: stdout/stderr (slack): Traceback (most recent call last):
python: stdout/stderr (slack): File "/home/nick/.weechat/python/wee_slack.py", line 133, in wrapper
python: stdout/stderr (slack): return f(data, current_buffer, *args, **kwargs)
python: stdout/stderr (slack): File "/home/nick/.weechat/python/wee_slack.py", line 144, in wrapper
python: stdout/stderr (slack): return f(*decode_from_utf8(args), **decode_from_utf8(kwargs))
python: stdout/stderr (slack): File "/home/nick/.weechat/python/wee_slack.py", line 3868, in command_thread
python: stdout/stderr (slack): msg = get_msg_from_id(channel, args)
python: stdout/stderr (slack): File "/home/nick/.weechat/python/wee_slack.py", line 3854, in get_msg_from_id
python: stdout/stderr (slack): return channel.hashed_messages.get(msg_id)
python: stdout/stderr (slack): AttributeError: 'SlackTeam' object has no attribute 'hashed_messages'
@nijotz
nijotz / DiscoStrobe.ino
Created Aug 13, 2016 — forked from kriegsman/DiscoStrobe.ino
DiscoStrobe - Flashing rainbow lights that zoom back and forth to a beat
View DiscoStrobe.ino
#include "FastLED.h"
// DiscoStrobe
// *Flashing* rainbow lights that zoom back and forth to a beat.
// See your doctor before using this code if you have certain neurological conditions.
//
// Mark Kriegsman, July 2015
#if FASTLED_VERSION < 3001000