Skip to content

Instantly share code, notes, and snippets.

const splitAt = (s, n) => [s.slice(0, n), s.slice(n + 1)];
@slikts
slikts / maxSubArray.js
Last active September 16, 2019 11:59
const reverse = xs => [...xs].reverse()
const times = (length, f) => Array.from({
length
}, f)
const flat = xs => xs.reduce((a, b) => a.concat(b), [])
const sum = ns => ns.reduce((a, b) => a + b)
const findPositiveIndex = ns => ns.findIndex(n => n > 0)
const trimNegative = ns => ns.slice(findPositiveIndex(ns), ns.length - findPositiveIndex(reverse(ns)))
#!/bin/bash
#
# Author: Peter Maloney
# License: GPLv2
backed_up=false
now=$(date +%s)
file=/etc/ssh/sshd_config
support_applications=()
pubkeyonly=false
@slikts
slikts / Linuxifying Windows.md
Last active September 4, 2023 07:30
Linuxifying Windows

nelabs.dev

Linuxifying Windows for development

This guide is for 'linuxing-up' Windows as a development environment; it focuses on setting up [WSL], an Ubuntu Hyper-V virtual machine, [wsltty] (a nice terminal emulator) and various tweaks.

Rationale

@slikts
slikts / DarkMonokai.qss
Last active December 13, 2018 22:46 — forked from Zren/DarkMonokai.qss
Dark Monokai - Quassel Theme (qss)
/**
** ____ _ ___ ___ _ _
** | _ \ | | | \/ | | | (_)
** | | \ |__ _ _ __| | __ | . . | ___ _ __ ___ | | __ __ _ _
** | | | | _` | '__| |/ / | |\/| |/ _ \| '_ \ / _ \| |/ // _` | |
** | |_/ /(_| | | | < | | | | (_) | | | | (_) | <| (_| | |
** |____/\__,_|_| |_|\_\ \_| |_/\___/|_| |_|\___/|_|\_\\__,_|_|
**
** Quassel Theme
**
@slikts
slikts / Deferred.js
Last active December 8, 2018 10:31
Deferred
class Deferred {
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = value => {
resolve(value);
return this.promise;
};
this.reject = reason => {
reject(reason);
return this.promise;
@slikts
slikts / css_colors.js
Created September 25, 2018 09:31 — forked from bobspace/css_colors.js
All of the CSS Color names as an array in javascript.
// CSS Color Names
// Compiled by @bobspace.
//
// A javascript array containing all of the color names listed in the CSS Spec.
// The full list can be found here: http://www.w3schools.com/cssref/css_colornames.asp
// Use it as you please, 'cuz you can't, like, own a color, man.
export default [
`AliceBlue`,
`AntiqueWhite`,
class JSONSet extends Set{
constructor(values) {
super()
this.map = new Map()
if (values) {
[...values].forEach(value => void this.add(value))
}
}
has(value) {
return this.map.has(JSON.stringify(value))
const abortError = new Error(`Aborted`)
const promisifySignal = signal =>
signal.aborted
? Promise.reject(abortError)
: new Promise(
(_, reject) =>
void signal.addEventListener(`abort`, () => void reject(abortError), { once: true }),
)
const sleep = (delay, ...args) => new Promise(resolve => setTimeout(resolve, delay, ...args))
const cancelableSleep = (delay, signal, ...args) =>
const _new = (constructor) => (...args) => constructor.apply(Object.create(constructor.prototype), args)