Skip to content

Instantly share code, notes, and snippets.

View danmoseley's full-sized avatar
:shipit:

Dan Moseley danmoseley

:shipit:
  • Microsoft
  • Jackson, WY
  • 10:31 (UTC -06:00)
View GitHub Profile
@danmoseley
danmoseley / gist:eeb38412d74c3eb22bc69472940b1f95
Created July 17, 2023 20:05
regex writer stringTable sizes
| Row Labels | Count of 1 |
| ----------- | ---------- |
| 0 | 12647 |
| 1 | 62735 |
| 2 | 43475 |
| 3 | 27852 |
| 4 | 17408 |
| 5 | 11870 |
| 6 | 8788 |
| 7 | 7623 |
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
namespace compressionspeed
{
internal class Program
{
static TimeSpan last = TimeSpan.Zero;
static long lastSize = 0;
@danmoseley
danmoseley / chisquared.cs
Last active December 30, 2022 19:59
test random with chi squared
using System.Diagnostics;
using System.Linq;
using System.Numerics;
internal class Program
{
public static void Main(string[] args)
{
// Check for an off-by-one type error causing us to consistently not generate values
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
[MemoryDiagnoser]
@danmoseley
danmoseley / test.tars.cs
Last active August 21, 2022 21:46
test tars
// See https://aka.ms/new-console-template for more information
using System.Formats.Tar;
using Xunit;
public static class C
{
public async static Task Main()
{
List<Task> tasks = new();
using System;
using System.Text.RegularExpressions;
Regex re = new Regex(@"\Gbar", RegexOptions.Compiled);
string fooBarString = @" bar";
var match1 = re.Match(fooBarString, 1);
Console.WriteLine(String.Format("Match 1 sucess: {1} {0}", match1.Success, match1.Index));
var match2 = re.Match(fooBarString, 1, fooBarString.Length-1);
Console.WriteLine(String.Format("Match 2 sucess: {1} {0}", match1.Success, match2.Index));
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
Vector128<byte> value = Vector128.Create((byte)0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
Vector128<byte> mask = Vector128.Create((byte)0b01000100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// PSHUFB -- result[i] = (mask[i] & 0x80) ? 0 : value[mask[i] & 15]
Vector128<byte> result1 = Ssse3.Shuffle(value, mask);
@danmoseley
danmoseley / specialfolders.md
Created April 24, 2022 00:58
specialfolders.md
KNOWNFOLDERID Guid Default Windows path CSIDL SpecialFoler Windows *nix Mac
FOLDERID_AccountPictures {008ca0b1-55b4-4c56-b8a8-4de4b299d3be} %APPDATA%\Microsoft\Windows\AccountPictures -
FOLDERID_AddNewPrograms {de61d971-5ebc-4f02-a3a9-6c82895e5c04} Virtual -
"area-AssemblyLoader-coreclr", "@jeffschwMSFT",
"area-AssemblyLoader-mono", "@lambdageek",
"area-Build-mono", "@steveisok",
"area-Codegen-AOT-mono", "@SamMonoRT",
"area-CodeGen-coreclr", "@JulieLeeMSFT",
"area-Codegen-Interpreter-mono", "@SamMonoRT",
"area-Codegen-JIT-mono", "@SamMonoRT",
"area-CodeGen-LLVM-mono", "@SamMonoRT",
"area-Codegen-meta-mono", "@SamMonoRT",
"area-CoreLib-mono", "@marek-safar",
// This test should apply equally to Unix, but this reliably hits a particular one of the
// myriad ways that assembly load can fail
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsWindows))]
public void LoadFile_ValidPEBadIL_ThrowsBadImageFormatExceptionWithPath()
{
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "kernelbase.dll");
if (!File.Exists(path))
return;
AssertExtensions.ThrowsContains<BadImageFormatException>(() => Assembly.LoadFile(path), path);