View cleanupEmptyFolders.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View dash-array-holes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = new Path.Circle({ | |
radius: 200, | |
strokeColor: 'blue', | |
center: view.center, | |
strokeCap: 'round', | |
strokeWidth: 3 | |
}) | |
const gap = 50 | |
const offsets = [] |
View stretch.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
View class.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |