Skip to content

Instantly share code, notes, and snippets.

View lambdageek's full-sized avatar
🪣

Aleksey Kliger (λgeek) lambdageek

🪣
View GitHub Profile
@lambdageek
lambdageek / net8-wasm-logging.md
Last active October 13, 2023 14:00
.NET 8 Additional WebAssembly logging

In .NET 8, Blazor projects now have a way to pass additional configuration options to the runtime, including setting environment variables before Mono starts.

The way to do it depends on whether you're using a blazorwasm template, or the new blazor (unified Server/Client project)

Blazor WebAssembly

If you created a blazorwasm project from the default template, in wwwroot/index.html replace this:

@lambdageek
lambdageek / aleksey_activate_dotnet.zsh
Last active June 30, 2023 14:43
A zsh script to activate/deactivate a dotnet SDK directory
# To install source this file from your .zshrc file
# Initialize colors.
autoload -U colors
colors
# Allow for functions in the prompt.
setopt PROMPT_SUBST
# Use in a PROMPT variable. For example (together with zsh-git-prompt):
typedef struct _MonoDelegateCodeCache
{
gpointer method_ptr;
gpointer invoke_impl;
} MonoDelegateCodeCache;
typedef struct _MonoDelegate {
...
MonoDelegateCodeCache *cache; // initially NULL
@lambdageek
lambdageek / nanboxing.ts
Created May 12, 2022 13:46
Fun with NaN boxing
/// We pack 64-bit integers into the 64 bytes of a double
type PackedInt64 = number;
const doubleView = new Float64Array(1);
const int32View = new Int32Array(doubleView.buffer);
export function pack(lo: number, hi: number): PackedInt64 {
int32View[0] = lo;
int32View[1] = hi;
return doubleView[0];
@lambdageek
lambdageek / ak-msbuildify-compilation.el
Created March 8, 2022 17:23
Make Emacs understand MSBuild Exec task compilation output
(defun ak-msbuildify-regexp-str (s)
(replace-regexp-in-string "\\^" "^ \\\\{0,2\\\\}" s))
(defun ak-msbuildify-alist-alist (xss-orig)
(let* ((xss (copy-alist xss-orig))
(l xss))
(while (consp l)
;; l is (('symbol REGEXP ...) ...)
(let* ((x (copy-sequence (car l))) ;; unshare with the original alist
(r (cdr x)))
@lambdageek
lambdageek / dotnet-emscripten-env.sh
Last active November 15, 2021 18:07
Environment for .NET 6 bundled Emscripten
#! /bin/sh
# Source this with `. dotnet-emscripten-env.sh` to set up the paths to use `emcc` from the version of Emscripten bundled with .NET 6
dotnet_packs_dir=/usr/local/share/dotnet/packs
dotnet_emscripten_prefix=Microsoft.NET.Runtime.Emscripten.2.0.23
dotnet_rid=osx-x64
dotnet_ver=6.0.0
@lambdageek
lambdageek / README.md
Created July 7, 2021 18:45
mono runtime components testing proj
  1. Save component-manifest.sample.proj to the base directory of dotnet/runtime

  2. Build with

    ./build.sh  --os iossimulator -c Release
    
  3. Test with

./dotnet.sh build component-manifest.sample.proj /p:RuntimeIdentifier=iossimulator-x64 /p:'MonoComponentOverride="hot_reload;debugger"' /v:d

@lambdageek
lambdageek / ExistentialsAndUniversals.hs
Last active April 24, 2021 02:16
Negations of existentials and universals in constructive logic
{-# language GADTs, RankNTypes, KindSignatures, PolyKinds, EmptyCase #-}
module ExistentialsAndUniversals where
-- To prove:
-- 1. ∀a.p a → ¬∃a.¬p a
-- 2. ∃a.p a → ¬∀a.¬p a
-- 3. ∀a.¬(p a) → ¬∃a.p a
-- 4. ∃a.¬(p a) → ¬∀a.p a
-- First some simple types
@lambdageek
lambdageek / build-distcc.sh
Created December 11, 2020 15:11
Build dotnet/runtime with distcc
#! /bin/sh
export PATH=/usr/lib/distcc:"${PATH}"
export DISTCC_NO_REWRITE_CROSS=1
exec ./build.sh "$@"
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
<LanguageVersion>latest</LanguageVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>