Skip to content

Instantly share code, notes, and snippets.


Mike Schinkel mikeschinkel

View GitHub Profile
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
View benchmark_slice_aggregation.go
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)
View GrantLogonAsAService.ps1
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
mikeschinkel / Type.php
Created October 5, 2021 17:28
A reimagining of Sebastian Bergmann's Type.php if PHP had a "function list" declaration.
View Type.php
<?php declare(strict_types=1);
* This file is part of sebastian/type.
* (c) Sebastian Bergmann <>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
namespace SebastianBergmann\Type;
mikeschinkel /
Last active April 6, 2022 17:33
Potential approach for streamlined error handling in Go

Proposal for Streamlined Error Handling in Go

This is a proposal for a way to simplify the error handling in Go.

The idea is to use attempt{} and recover{} blocks to separate the happy path from the error handling. NOTE: this is NOT exception handling as you would see in Java or PHP. More on why below.

In this proposal Go would allow the developer to omit capturing the last returned variable from a function call if and only if that call was within a attempt{} block. The Go compiler would handle providing access to the error instance via the geterror() function within the recover{} block if any function returns a non nil error as its last omitted parameter, i.e.:

 data:= GetData()
mikeschinkel / example.php
Last active July 27, 2021 12:52
How we might be able to move to using parameterized queries in WordPress core
View example.php
// Put this in wp-config.php
// A site builder who wants to use prepared statements and parameterized queries
// could run these in various hooks before $wpdb->query() below is run.
$question_fragment = $wpdb->prepare( '`question_id` = %d', $question_id );
$answer_fragment = $wpdb->prepare( '`answer_name` = %s', $new_answer );
$wpdb->compose('UPDATE %s polls SET vote = vote+1 WHERE %s AND %s',
mikeschinkel / make_literal.php
Created June 26, 2021 12:55
A make_literal() function to get around functions that use is_literal() over-zealously
View make_literal.php
$safe_var = 'all your base they belong to us';
file_put_contents('/tmp/exploit.txt',$safe_var );
// imagine lots of stuff going on here...
$safe_var = file_get_contents('/tmp/exploit.txt');
function make_literal(string $non_literal):string {
$literal = '';