Skip to content

Instantly share code, notes, and snippets.

View arnoson's full-sized avatar
🐤
I may be slow to respond.

Arno Schlipf arnoson

🐤
I may be slow to respond.
View GitHub Profile
@arnoson
arnoson / extend-layer.ahk
Last active September 19, 2024 11:24
Simple AutoHotKey v2 Extend Layer
; Extend Layer
; Based on https://dreymar.colemak.org/layers-extend.html
#Requires AutoHotkey v2.0
#SingleInstance Force
SetCapsLockState("AlwaysOff")
#HotIf GetKeyState("CapsLock", "P")
; Modifiers
@arnoson
arnoson / .clang-format
Last active March 16, 2023 17:54 — forked from nicklasfrahm/.clang-format
Prettier (JS/TS) style .clang-format options
ColumnLimit: 80
ContinuationIndentWidth: 2
IndentWidth: 2
TabWidth: 2
ConstructorInitializerIndentWidth: 2
IndentCaseLabels: true
UseTab: Never
SortIncludes: true
SortUsingDeclarations: false
AlignConsecutiveMacros: false
@arnoson
arnoson / cleanupEmptyFolders.js
Created November 15, 2022 11:47
nodejs: remove empty directories recursively
import { readdirSync, rmdirSync, statSync } from 'node:fs'
import { join } from 'node:path'
export const cleanupEmptyFolders = (folder) => {
if (!statSync(folder).isDirectory()) return
let files = readdirSync(folder)
if (files.length > 0) {
files.forEach((file) => cleanupEmptyFolders(join(folder, file)))
// Re-evaluate files; after deleting subfolders we may have an empty parent
@arnoson
arnoson / dash-array-holes.js
Created November 4, 2021 14:32
Create a dash array with holes in it
const path = new Path.Circle({
radius: 200,
strokeColor: 'blue',
center: view.center,
strokeCap: 'round',
strokeWidth: 3
})
const gap = 50
const offsets = []
@arnoson
arnoson / stretch.js
Last active November 8, 2021 12:49
Stretch a round paper.js path item
const getBottomSegment = (segments) =>
segments.reduce((prev, curr) => (curr.point.y > prev.point.y ? curr : prev))
const getTopSegment = (segments) =>
segments.reduce((prev, curr) => (curr.point.y < prev.point.y ? curr : prev))
const wrapSegmentIndex = (path, index) =>
(index =
index < 0 ? path.segments.length + index : index % path.segments.length)
@arnoson
arnoson / class.lua
Created April 8, 2021 23:22
Lua class helper
-- Inspired by: lua-users.org/wiki/SimpleLuaClasses
function class(base)
local c = {}
-- Inherit base by making a shallow copy.
if type(base) == 'table' then
for key,value in pairs(base) do c[key] = value end
c._base = base
end