Skip to content

Instantly share code, notes, and snippets.

View neon-sunset's full-sized avatar
💭
So ARM64 has FJCVTZS for JS but nothing to count UTF-8 code point length :(

neon-sunset

💭
So ARM64 has FJCVTZS for JS but nothing to count UTF-8 code point length :(
View GitHub Profile
@ninjarobot
ninjarobot / strace-netcore.md
Last active December 3, 2024 12:36
Trace .NET Core Applications on Linux with `strace`

Trace .NET Core Applications on Linux with strace

Troubleshooting a running application can be difficult, usually it starts around checking log output and then following through the likely code paths to get an idea of where a failure may occur. In a development environment, you might attach a debugger a step through source, but troubleshooting isn't always that convenient. There are several helpful tools that can assist, but one that gives the most comprehensive view of a running application is strace. With strace you are able to see all of the system calls an application makes to get a detailed understanding of what is going on "under the hood" in order to troubleshoot an issue.

Take a simple "hello world" F# application, the kind you get from dotnet new console -lang F# -n strace-sample". Build it with dotnet build and then launch it with strace to get a trace of all the system calls in a file called trace.log(adjusting for your build output path if on a different framework vers

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active April 8, 2025 14:18
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@jnm2
jnm2 / AsyncParallelQueue.AtomicOperations.cs
Created August 24, 2019 22:37
AsyncParallelQueue and tests
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
internal sealed partial class AsyncParallelQueue<T>
{
/// <summary>
/// <para>
/// The purpose of this class is to separate what must be done inside a lock (everything this class does) from
@spencerkittleson
spencerkittleson / .editorconfig
Last active April 16, 2025 17:15
c# K&R Editor Config
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.cs]
@EgorBo
EgorBo / Dynamic PGO in .NET 6.0.md
Last active January 13, 2025 11:13
Dynamic PGO in .NET 6.0.md

Dynamic PGO in .NET 6.0

Dynamic PGO (Profile-guided optimization) is a JIT-compiler optimization technique that allows JIT to collect additional information about surroundings (aka profile) in tier0 codegen in order to rely on it later during promotion from tier0 to tier1 for hot methods to make them even more efficient.

What exactly PGO can optimize for us?

  1. Profile-driving inlining - inliner relies on PGO data and can be very aggressive for hot paths and care less about cold ones, see dotnet/runtime#52708 and dotnet/runtime#55478. A good example where it has visible effects is this StringBuilder benchmark:

  2. Guarded devirtualization - most monomorphic virtual/interface calls can be devirtualized using PGO data, e.g.:

void DisposeMe(IDisposable d)
@zingaburga
zingaburga / sve2.md
Last active April 21, 2025 15:49
ARM’s Scalable Vector Extensions: A Critical Look at SVE2 For Integer Workloads

ARM’s Scalable Vector Extensions: A Critical Look at SVE2 For Integer Workloads

Scalable Vector Extensions (SVE) is ARM’s latest SIMD extension to their instruction set, which was announced back in 2016. A follow-up SVE2 extension was announced in 2019, designed to incorporate all functionality from ARM’s current primary SIMD extension, NEON (aka ASIMD).

Despite being announced 5 years ago, there is currently no generally available CPU which supports any form of SVE (which excludes the [Fugaku supercomputer](https://www.fujitsu.com/global/about/innovation/

@moyix
moyix / killbutmakeitlooklikeanaccident.sh
Created February 5, 2022 22:51
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@FCLC
FCLC / A not so brief discussion of Alder Lake, the new AVX512 FP 16 extensions, Sapphire Rapids, its history, and why it requires a custom kernel.md
Last active August 8, 2024 02:30
On AVX512 FP16, Alder Lake, custom kernels, and how "Mistakes were made" has never rang so true

Warning: This is going to be a long one.  

  

I'm assuming general knowledge of x86_64 hardware extensions, and some insight into the workings of large hardware vendors. 

Understanding why AVX512 is useful not only in HPC, but also for gamers in emulation, or more efficient use of executions ports is a bonus. 

You don't need to have published 2 dozen papers on optimizing compute architecture. 

@skittleson
skittleson / method-example.cs
Last active April 26, 2023 19:08
Cross platform audio player in dotnet
// I've used a lot of libs including the popular ones for dotnet such as NAudio but all seem to be overly complicated or not cross platform.
// 1. install ffplay on your platform. for Windows `choco install ffplay`. Debian `apt install ffmpeg`.
// 2. install nuget pkg `CliWrap`
// 3. send your audio stream to the method.
public static async Task PlayAsync(Stream stream, CancellationToken cancellationToken)
{
var result = await Cli.Wrap("ffplay")
.WithStandardInputPipe(PipeSource.FromStream(stream))
.WithArguments($"-autoexit -nodisp -hide_banner -loglevel error -fs -")