Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
mikeschinkel /
Last active March 12, 2024 02:48
Go json.Unmarshal() vs. PHP json_decode() performance a large JSON file

GoLang json.Unmarshal() vs. PHP json_decode()

To evaluate if Go json.Unmarshal() is faster or slower than PHP json_decode() for arbitrary JSON I decided to run a quick benchmark on my 2015 MacBook Pro (Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz).

I used this ~25Mb JSON file and ran the attached two program under Go 1.22 and PHP 8.3.2, respectively.

My benchmarks were very unscientific but I was just looking for orders of magnitude.

Here are the results from three different runs, each:

Go (avg 30.82)

mikeschinkel /
Last active February 16, 2024 01:10
How to transpose a table in Sqlite
mikeschinkel /
Last active February 5, 2024 17:01
Script to create and remove a RAM disk on macOS

How to Create a RAM Disk on macOS

This script creates a RAM disk either in a ./data subdirectory off the root of the current Git repo, or a ./data subdirectory of the current directory if not in a Git repo.

To Attach a RAM Disk


To Detatch the RAM disk

package vermock
import (
//goland:noinspection GoSnakeCaseUsage
type MockGetter interface {
Get_Vermock() *Mock
mikeschinkel /
Last active December 23, 2022 10:26
My question of ChatGPT asking to help me choose PC component for a home router


What is the lowest power combination of server motherboard, CPU, reliable drives, ECC memory, fans and case that would make for a good powerful home router for one person with a lot of computer equipment?


When choosing a motherboard, CPU, and other components for a home router, it's important to consider the level of performance and reliability you need. You should also consider the power consumption of the components, as a low-power system will be more energy-efficient and potentially save you money on your energy bills.

For a powerful home router for one person with a lot of computer equipment, you might consider using a motherboard with a low-power CPU, such as an Intel Atom or a Qualcomm processor. These CPUs are designed for low-power applications and can provide sufficient performance for routing and other basic tasks. You'll also want to choose reliable drives, such as solid-state drives (SSDs), to ensure that your router is always available.

In addition to the motherboard and CPU,

mikeschinkel /
Created December 23, 2022 09:53
My Discussion with ChatGPT asking it to find ways to hold Fox News accountable for their spreading of misinformation.

How to Combat Misinformation in the US, especially Fox News?


Explain how to require Fox News to limit itself to factual reporting without violating the 1st amendment to the US Constitution that guarantees free speech.


It is not possible for the government or any other entity to require Fox News or any other news organization to limit itself to factual reporting without violating the First Amendment to the United States Constitution, which guarantees freedom of speech. The First Amendment protects the freedom of the press to report on issues and events as they see fit, even if their reporting is not always factual or unbiased.

However, there are ways to encourage news organizations to strive for accuracy and factual reporting. One way is through the use of media literacy education, which helps individuals develop the critical thinking skills needed to evaluate the accuracy and reliability of different sources of information. This can help people to identify and avoid sources of misinforma

mikeschinkel /
Last active June 22, 2022 01:09
Managing String Literals is a PITA, not just in GoLang but in (All?) Other Languages

Managing String Literals is a PITA,
Not Just in GoLang but in (All?) Other Languages

When working in Go, or Bash, or PHP, or any other language for that matter I find one of the most tedious tasks that are also very error prone is management of literal strings.

AFAIK no programming language has addressed this head on, ever. If I am right about that, it would be great if Go was the first.

Literal String Management

Management of literal strings occurs especially with URLs and local paths, but also with many other values that end up as literals used in source code. And there is not one good way to handle them, only several different ways all with major cons, and so developers are all over the map in how they handle string literals.

One approach is for a developer to assign a string literals to a named constant, and then use that name constant wherever the value is needed, e.g.:

mikeschinkel /
Last active April 9, 2022 04:15
Potential update to GoLang `encoding/csv`. Provides a ReadFunc() method that allows tweaking the logic for processing a CSV file.

Making encoding/csv.Reader extensible

The simple idea behind these potential modifications is to add a function csv.ReadFunc() that can be passed a csv.LogicFunc when called where the signature of the passed closure and related type and consts would be.

In this case there is really only one evalation needed, but there could easily be multiple in other use-cases.

mikeschinkel / benchmark_slice_aggregation.go
Last active February 3, 2022 23:00
GoLang benchmark for aggregating of multiple slice elements into a single slice
package test
// Initial source for benchmark from
// Added BenchmarkConcatAppendPreAllocate()
import "testing"
func BenchmarkConcatCopyPreAllocate(b *testing.B) {
for n := 0; n < b.N; n++ {
B = concatCopyPreAllocate(slices)
Function GrantLogonAsAService([string]$Username) {
Write-Host "Grant Logon-as-a-Service for $Username"
$SecurityId = $null
try {
$Principal = new-object System.Security.Principal.NTAccount $Username
$SecurityId = $Principal.Translate([System.Security.Principal.SecurityIdentifier]).Value.ToString()
} catch {
Write-Host "Attempt to access SecurityID failed."
$SecurityId = $null