Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
@mikeschinkel
mikeschinkel / Dockerfile
Last active July 26, 2024 01:21
Statamic — Dockerfile and compose; FILES SHOWN DO NOT WORK, see the _README.md for the working solution.
# Use an official PHP image with FPM
FROM php:8.3-fpm
LABEL authors="gearbox.works"
ENV LARAVEL_STORAGE_PATH=/var/statamic/storage
# PHP Extension Installer
COPY --from=mlocati/php-extension-installer \
/usr/bin/install-php-extensions \
@mikeschinkel
mikeschinkel / Statics\MemCache.php
Created July 9, 2024 01:15
PHP Classes Statics\MemStream and Statics\MemCache (NOT memcached-related.)
<?php
declare(strict_types=1);
namespace Statics;
/**
* Class MemCache
*
* Handles static memory caching — NOT TO BE CONFUSED with `memcached`.
*/
@mikeschinkel
mikeschinkel / .README.md
Last active August 23, 2024 11:51
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
mikeschinkel / _readme.md
Last active February 16, 2024 01:10
How to transpose a table in Sqlite
@mikeschinkel
mikeschinkel / .readme.md
Last active October 1, 2024 08: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

./ramdisk-macos.sh 

To Detatch the RAM disk

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

Me

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?

ChatGPT

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
mikeschinkel / chat.md
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?

Me

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.

ChatGPT

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
mikeschinkel / StringLiteralsAreAPITA.md
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
mikeschinkel / _README.md
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.