Skip to content

Instantly share code, notes, and snippets.

@caderek
caderek / liches-countdown.js
Last active September 29, 2021 18:32
Lichess time trouble countdown script for Tampermonkey
// ==UserScript==
// @name Lichess time trouble countdown helper
// @namespace https://lichess.org/
// @version 0.1
// @description Liches time trouble countdown util
// @author You
// @match https://lichess.org/*
// @icon https://www.google.com/s2/favicons?domain=lichess.org
// @grant none
// ==/UserScript==
@caderek
caderek / bench.mjs
Last active September 29, 2021 20:07
Manipulating the array - JS benchmark
import b from "benny"
import cloneDeep from "clone-deep"
const testData = new Array(3000).fill(null).map((val, i) => ({
if: i,
currDate: Math.round(Math.random() * 1e10),
name: Math.round(Math.random() * 1e10).toString(16),
someString: Math.round(Math.random() * 1e10).toString(16),
foo: "foo",
bar: "bar",
# Adds Gnome/Cosmic shortcuts for:
# - switching between workspaces with Super+<number>
# - moving apps to workspaces with Super+Shift+<number>
gsettings set org.gnome.mutter dynamic-workspaces false
gsettings set org.gnome.desktop.wm.preferences num-workspaces 10
gsettings set org.gnome.shell.keybindings switch-to-application-1 []
gsettings set org.gnome.shell.keybindings switch-to-application-2 []
gsettings set org.gnome.shell.keybindings switch-to-application-3 []
gsettings set org.gnome.shell.keybindings switch-to-application-4 []
gsettings set org.gnome.shell.keybindings switch-to-application-5 []
@caderek
caderek / gnome-shell.css
Last active October 28, 2021 15:59
Custom styles for Nordic Darker Gnome theme (missing styles)
/* Add this to file .themes/<theme name>/gnome-shell/gnome-shell.css */
.cosmic-dock #dock {
border: 1px solid #0e1114;
border-radius: 11px !important;
background-color: #1d2128;
}
.cosmic-dock .app-well-app:hover .overview-icon,
.cosmic-dock .app-well-app:focus .overview-icon,
@caderek
caderek / bench.mjs
Last active November 19, 2021 02:28
Class vs factory function (Crockford style) performance
import v8 from "v8"
import vm from "vm"
import b from "benny"
v8.setFlagsFromString("--expose-gc")
const gc = vm.runInNewContext("gc")
const niceBytes = (bytes) => {
bytes = Number(bytes)
@caderek
caderek / Duck_class1.js
Last active November 23, 2021 01:35
Object composition - class part 1
class Swimmable {
swim() {
console.log("Swam 1 meter")
}
}
class Quackable {
quack() {
console.log("Quack!")
}
@caderek
caderek / Duck_class2.js
Last active November 23, 2021 01:35
Object composition - class part 2
class Swimmable {
constructor() {
this.speed = 1
}
swim() {
console.log(`Swam ${this.speed} meter(s)`)
}
}
@caderek
caderek / Duck_factory1.js
Last active November 23, 2021 01:35
Object composition - factory part 1
const Swimmable = () => ({
swim() {
console.log("Swam 1 meter")
},
})
const Quackable = () => ({
quack() {
console.log("Quack!")
},
@caderek
caderek / Duck_factory2.js
Last active November 23, 2021 01:34
Object composition - factory part 2
const Swimmable = () => ({
speed: 1,
swim() {
console.log(`Swam ${this.speed} meter(s)`)
},
})
const Quackable = () => ({
speed: 1,
quack() {
@caderek
caderek / run.js
Created December 4, 2021 17:43
Aocrunner test input formatting
run({
part1: {
tests: [
{
input: `forward 5
down 5
forward 8
up 3
down 8
forward 2`,