Skip to content

Instantly share code, notes, and snippets.

class DirectedGraph<T> {
readonly edges: Map<T, Set<T>> = new Map();
addAll(from: T, ...to: T[]) {
let dependencies = this.edges.get(from);
if (dependencies == null) {
dependencies = new Set();
this.edges.set(from, dependencies);
}
Sets.addAll(dependencies, to);
@mmozeiko
mmozeiko / shader.hlsl
Last active February 4, 2024 17:53
compute shader for rendering monospaced glyphs in grid
//
struct TerminalCell
{
// cell index into GlyphTexture, should be two 16-bit (x,y) values packed: "x | (y << 16)"
uint GlyphIndex;
// 0xAABBGGRR encoded colors, nonzero alpha for Foreground indicates to render colored-glyph
// which means use RGB values from GlyphTexture directly as output, not as ClearType blending weights
uint Foreground;
@Egor-Skriptunoff
Egor-Skriptunoff / how_to_install_lua_and_luajit_on_windows.md
Last active April 26, 2024 11:44
How to install Lua and LuaJIT on Windows

How to install Lua and LuaJIT on 64-bit Windows

  1. Download the latest Lua and LuaJIT sources

    • Create temporary folder for Lua sources.
      I assume you would use C:\Temp\ folder.

    • Visit Lua FTP webpage and download the latest Lua source archive, currently it is lua-5.4.3.tar.gz

  • Use suitable software (7-Zip, WinRar, WinZip or TotalCommander) to unpack the archive.
@msteen
msteen / print-lezer-tree.ts
Last active May 1, 2024 21:05
Print Lezer Trees
// MIT License
//
// Copyright (c) 2021 Matthijs Steen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@na0x2c6
na0x2c6 / mic-toggle.applescript
Created May 12, 2021 08:10
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
BNF = { }
-- create definition
BNF["::="] = function (stack)
local non_terminal = pop(stack) ;
push(BNF,non_terminal) ; end
-- add words to definition
BNF[";"] = function (stack)
local non_terminal = pop(BNF)
# MIT License
#
# Copyright (c) 2018 Jelle Hermsen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@AetherDevSecOps
AetherDevSecOps / introspection.graphql
Last active April 29, 2021 03:38
GraphQL Get Entire Schema Using Introspection
__schema {
description
queryType {
kind
name
}
mutationType {
kind
name
}
@ggoodman
ggoodman / graphBuilder.ts
Created April 18, 2021 02:25
Exploration of building a module graph 'quickly' using esbuild and enhanced-resolve
import {
CachedInputFileSystem,
FileSystem,
ResolveContext,
ResolverFactory,
} from 'enhanced-resolve';
import { build, ImportKind, Loader } from 'esbuild';
import * as Fs from 'fs';
import Module from 'module';
import * as Path from 'path';
@mklement0
mklement0 / PSReadLineMetaInfoKeyHandler.ps1
Last active April 26, 2021 13:11
PowerShell sample code that demonstrates a PSReadLine key handler that display meta-information about the command being typed in real time.
<#
License: MIT
Author: Michael Klement <mklement0@gmail.com>
See https://stackoverflow.com/a/67266971/45375 for more information.
#>
# The printable characters to respond to.