Skip to content

Instantly share code, notes, and snippets.

@disco0
disco0 / lpeg-in-fennel.fnl
Created June 8, 2021 18:05 — forked from sogaiu/lpeg-in-fennel.fnl
lpeg in fennel
>> (local lpeg (require :lpeg))
nil
>> (local equalcount (lpeg.P {1 "S"
.. "S" (+ (* "a" (lpeg.V "B")) (* "b" (lpeg.V "A")) "")
.. "A" (+ (* "a" (lpeg.V "S")) (* "b" (lpeg.V "A") (lpeg.V "A")))
.. "B" (+ (* "b" (lpeg.V "S")) (* "a" (lpeg.V "B") (lpeg.V "B")))}))
nil
>> (lpeg.match equalcount "aabb")
5
>> (lpeg.match equalcount "baabba")
@disco0
disco0 / README.md
Created May 28, 2021 04:22 — forked from acutmore/README.md
Emulating a 4-Bit Virtual Machine in (TypeScript\JavaScript) (just Types no Script)

A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.

Syntax emits zero JavaScript.

type RESULT = VM<
  [
    ["push", N_1],         // 1
    ["push", False],       // 2
 ["peek", _], // 3
@disco0
disco0 / Logger.ts
Created May 27, 2021 11:41 — forked from arabold/Logger.ts
Simple, opinionated Logger for use with Node.js and Web Browsers
/**
* Simple, opinionated Logger for use with Node.js and Web Browsers with no
* additional dependencies.
*
* The logger supports and auto-detects the following environments:
* - Node.js (with and without JSDOM)
* = Browser
* - Electron
* - React Native - Logs to console or browser window depending on whether a debugger is connected
* - Unit Test & CI/CD - Logs are disabled by default
@disco0
disco0 / tree.ts
Created May 27, 2021 07:15 — forked from albovieira/tree.ts
tree in ts
import { Func } from 'mocha';
//Ref: https://code.tutsplus.com/articles/data-structures-with-javascript-tree--cms-23393
class NodeTree {
readonly name: string;
readonly value: any;
private parent: string | null;
private children: NodeTree[];
@disco0
disco0 / AutoComplete.lua
Created May 24, 2021 06:34 — forked from Lexikos/AutoComplete.lua
Improved auto-complete for SciTE
-- AutoComplete v0.8 by Lexikos
--[[
Tested on SciTE4AutoHotkey 3.0.06.01; may also work on SciTE 3.1.0 or later.
To use this script with SciTE4AutoHotkey:
- Place this file in your SciTE user settings folder.
- Add the following to UserLuaScript.lua:
dofile(props['SciteUserHome'].."/AutoComplete.lua")
- Restart SciTE.
]]
@disco0
disco0 / scut.styl
Created May 16, 2021 10:54 — forked from armornick/scut.styl
Translation of Scut to Stylus (https://davidtheclark.github.io/scut/)
/*
* Scut, a collection of Sass utilities
* to ease and improve our implementations of common style-code patterns.
* v1.1.2
* Docs at http://davidtheclark.github.io/scut
*
* Translated for Stylus by armornick
*/
scut-clearfix() {
// Extend in a media query
// =============================================================================
// Mixins
// -----------------------------------------------------------------------------
clearfix()
&:before,
&:after
content: ' '
display: tablet
@disco0
disco0 / ScopeTree.ts
Last active May 15, 2021 17:59 — forked from bradkovach/ScopeTree.ts
Tree with namespaces
interface IScopeNodeIndex<T> {
[path: string]: ScopeNode<T>
}
export class ScopeNode<T> {
constructor(
public value: T,
public children: IScopeNodeIndex<T> = {}
) {
@disco0
disco0 / mic-toggle.applescript
Created May 14, 2021 06:26 — forked from na0x2c6/mic-toggle.applescript
Mic mute toggle script on Mac
-- refs: https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ReadandWriteFiles.html
-- refs: https://medium.com/macoclock/how-in-the-bleep-do-i-mute-my-mic-anywhere-on-macos-d2fa1185b13
on writeTextToFile(theText, theFile, overwriteExistingContent)
try
set theFile to theFile as string
set theOpenedFile to open for access file theFile with write permission
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
@disco0
disco0 / WinFormExtensions.cs
Created April 26, 2021 10:29 — forked from MatthewKing/WinFormExtensions.cs
Extension methods for classes in the System.Windows.Forms namespace.
// Copyright Matthew King 2012-2015.
// Distributed under the Boost Software License, Version 1.0.
// (See http://www.boost.org/LICENSE_1_0.txt)
using System;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;