Skip to content

Instantly share code, notes, and snippets.

@DerekZiemba
DerekZiemba / Format-Json.ps1
Created Sep 29, 2020
Proper Powershell JSON Formatting
View Format-Json.ps1
# https://github.com/PowerShell/PowerShell/issues/2736
# https://github.com/PowerShell/PowerShell/issues/8604
function Format-Json([Parameter(Mandatory, ValueFromPipeline)]$json) {
if ($json -isnot [string]) { $json = $json | ConvertTo-Json -Depth 10; }
$indent = 0;
$lines = $json.Split("`n", [System.StringSplitOptions]::RemoveEmptyEntries);
for (($len = $lines.Length), ($i = 0); $i -lt $len; $i++) {
@DerekZiemba
DerekZiemba / Benchmark.cs
Created Aug 14, 2020
NBody benchmark program
View Benchmark.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Runtime.InteropServices;
namespace Benchmark {
public static class Extensions {
public static string ToStringReset(this StringBuilder sb) {
@DerekZiemba
DerekZiemba / index.html
Last active Jul 29, 2020
HWInfo Report
View index.html
<html><head>
<meta name="GENERATOR" content="HWiNFO64 v6.28-4200">
<style>
A { text-decoration: none }
A:hover { text-decoration: underline }
TD { font: 80% verdana, tahoma, ms sans serif, arial; color: #000000; vertical-align: text-center; text-align: left }
TD.dn { font: 70% verdana, tahoma, ms sans serif, arial; color: #000000; vertical-align: text-center }
TD.di { font: bold 80% verdana, tahoma, ms sans serif, arial; color: #000000; vertical-align: text-center }
TD.ds { font: bold 80% verdana, tahoma, ms sans serif, arial; color: #000080; vertical-align: text-center }
TD.dt { font: bold 110% verdana, tahoma, ms sans serif, arial; color: #000080; vertical-align: text-center }
@DerekZiemba
DerekZiemba / index.html
Last active Jun 5, 2020
Javascript Fastest way to check for String Type that is not empty #jsbench #jsperf (https://jsbench.github.io/#79c073db881ec273a6ef630cfc258e49) #jsbench #jsperf
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Javascript Fastest way to check for String Type that is not empty #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@DerekZiemba
DerekZiemba / index.html
Created May 10, 2020
Map vs Object #jsbench #jsperf
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Map vs Object</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Fast MD5 Hash</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@DerekZiemba
DerekZiemba / index.html
Created Apr 24, 2020
Javascript Property Access Performance (http://jsbench.github.io/#4ef29e47641e4fa1fdb8af48b2a7fe12) #jsbench #jsperf
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Javascript Property Access Performance</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@DerekZiemba
DerekZiemba / index.html
Last active Apr 15, 2020
Fastest way to filter/compact array (https://jsbench.github.io/#7e604d68c13fb1b41e441a963cb9b764) #jsbench #jsperf
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Fastest way to filter/compact array</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@DerekZiemba
DerekZiemba / index.html
Last active Jan 31, 2020
Object Shape: Effects of how Object Properties are defined with their backing fields and limiting Enumerability + lazy properties and private fields (https://jsbench.github.io/#5c4e4ed52ce564de7d07231f9e44d687) #jsbench #jsperf
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Object Shape: Effects of how Object Properties are defined with their backing fields and limiting Enumerability + lazy properties and private fields</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>