Skip to content

Instantly share code, notes, and snippets.

@Skateside
Skateside / init.lua
Last active July 5, 2026 15:18
My Current NeoVIM confirm
--[[
-- Settings
--]]
vim.opt.termguicolors = true
vim.opt.mouse = ""
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
@Skateside
Skateside / state-machine.ts
Last active March 23, 2026 16:03
A simple state machine, built in TypeScript
type IMachineSettings<
TContext extends Record<string, any> = {},
TStates extends string = "",
TEvents extends string = "",
> = {
context?: TContext,
initial: TStates,
states: Record<TStates, {
on?: Partial<Record<TEvents, TStates>>,
actions?: Partial<{
@Skateside
Skateside / swap.ts
Last active January 17, 2026 16:43
Justify every early return
/**
* Swaps the items in the array at `indexA` and `indexB`. If either `indexA` or
* `indexB` are less than `0`, more-than-or-equal-to the length of `array`, or
* not an integer, then no action is taken.
*
* @param array Array whose items should be swapped.
* @param indexA Index of one item to swap.
* @param indexB Index of the other item to swap.
*/
const swap = (array: any[], indexA: number, indexB: number) => {
@Skateside
Skateside / lib.object-hasown-groupby.d.ts
Last active January 26, 2024 22:58
Just thinking aloud about re-writing the Pocket Grimoire
export {}
declare global {
interface ObjectConstructor {
/**
* Checks to see if the given property is in the given object.
* @param object Object to check in.
* @param property Property to check for.
@Skateside
Skateside / breakout.css
Last active August 25, 2021 11:07
Making 100vw take up the whole width without a horizontal scrollbar or overflow:hidden
/* https://css-tricks.com/full-width-containers-limited-width-parents/#no-calc-needed */
/* "No calc() needed" now with added calc()! */
.breakout {
--main-bar: var(--scroll-bar, 0px);
--main-half-bar: calc(var(--main-bar) / 2);
width: 100vw;
width: calc(100vw - var(--main-bar));
position: relative;
left: 50%;
right: 50%;
@Skateside
Skateside / aria.js
Created September 30, 2018 12:32
Thinking aloud about a WAI-ARIA library
let types = [
[Aria.Property, [
"atomic",
]],
[Aria.ReferenceCollection, [
"controls",
]],
[Aria.State, [
"busy",
"current",
@Skateside
Skateside / polyfill.js
Created February 8, 2018 19:59
A simple polyfill for the "jQuery style methods" that have been added recently. Written in ES6 syntax
function polyfill(object, name, value) {
if (typeof object[name] !== typeof value) {
Object.defineProperty(object, name, {
value,
configurable: true,
enumerable: false,
writable: true
});
@Skateside
Skateside / unit tests.js
Last active August 2, 2017 08:14
jQuery AMCSS plugin
// $.am();
// $.addAm();
// $.removeAm();
// $.hasAm();
// $.normaliseAm() and $.normalizeAm()
// $.amHooks
// $.AM_PREFIX
describe("jQuery#am", function () {
@Skateside
Skateside / observer.js
Last active October 1, 2016 10:45
A simple, tiny and robust JavaScript observer
/**
* observer
*
* A namespace for observers. To create one, simply call the `makeObserver`
* function:
*
* var observer = makeObserver();
*
* This allows multiple observers to be run if needed. Subscribe to events
* using [[observer.on]], unsubscribe using [[observer.off]] and trigger events
@Skateside
Skateside / Access.js
Last active December 14, 2015 22:34
Getter/Setter object in JavaScript. Loosely based on the Varien_Object in Magento
/**
* access
*
* Created by calling the `Access` function.
*
* var a1 = Access();
* var a2 = new Access();
*
* Initial data can be passed, see [[access.addData]].
*