Skip to content

Instantly share code, notes, and snippets.

@mrange
mrange / file0.cs
Last active Jun 22, 2021
Static inject T4
View file0.cs
namespace t4inject
{
partial interface IA
{
}
partial class A : IA
{
partial void OnCreated(CreationContext context);
@mrange
mrange / File0.cs
Last active Jun 19, 2021
Parser Combinators 2 C#
View File0.cs
#nullable enable
namespace CsParserCombinator
{
using System;
using static Parsers;
class Program
{
static readonly Parser<int> _algebraParser = CreateAlgebraParser();
@mrange
mrange / main.cs
Created Jun 9, 2021
Parser Combinator C#
View main.cs
namespace CsParserCombinator
{
using System;
using static CsParserCombinator.Parsers;
class Program
{
const string Input = @"
x = 3
y=4
@mrange
mrange / schema_0_example.cs
Last active Jun 5, 2021
Schema inferrer F#
View schema_0_example.cs
#nullable enable
namespace Responses.Customers
{
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
/* Created model classes from input JSON:
@mrange
mrange / refont.fs
Created May 17, 2021
Change font textures from classic 320x200 to 256x256
View refont.fs
open System
open System.Drawing
open System.Drawing.Drawing2D
open System.Drawing.Imaging
open System.Runtime.InteropServices
let message (cc : ConsoleColor) (msg : string) =
let occ = Console.ForegroundColor
try
@mrange
mrange / README.md
Last active May 16, 2021
GLSL hsv2rgb macro for constexpr initialization
View README.md

GLSL hsv2rgb macro for constexpr initialization

One piece of GLSL code I am constantly coming back to is Sam Hocevar's hsv2rbg and rgb2hsv functions posted on stackoverflow: https://stackoverflow.com/a/17897228/418488

The code

// Sam Hovevar has licensed the code under WTFPL.

// All components are in the range [0…1], including hue.
View test.fs
open System
open NStack
open Terminal.Gui
let ustr (x: string) = ustring.Make(x)
let doNothing () = ()
[<EntryPoint>]
let main argv =
View .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/mrange/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
View settings.json
{
"editor.fontSize": 40,
"editor.fontLigatures": false,
"editor.tabSize": 2,
"editor.renderWhitespace": "all",
"files.trimTrailingWhitespace": true,
"editor.codeLens": false,
"editor.rulers": [
40,
80,
@mrange
mrange / experiment.glsl
Last active Mar 21, 2021
experimenting
View experiment.glsl
#define RESOLUTION resolution
#define SCA(x) vec2(sin(x), cos(x))
#define PI pi
#define TAU tau
#define TIME time
#define TTIME (TAU*TIME)
#define RESOLUTION resolution
#define ROT(a) mat2(cos(a), sin(a), -sin(a), cos(a))
#define PSIN(a) (0.5+0.5*sin(a))
#define L2(x) dot(x, x)