Skip to content

Instantly share code, notes, and snippets.

View theking2's full-sized avatar
🎯
contemplating the odds

Johannes kingma theking2

🎯
contemplating the odds
View GitHub Profile
@theking2
theking2 / polishnotation.php
Last active March 27, 2025 17:32
Polish notation
<?php
/**
* Polish notation
* @param $expression - Space seperated operators and param indices
* @param $param - two or more params for the calculation
*/
function pn(string $expression, mixed ...$param) {
$operators = "+-*/%"; $delimiter = " ";
$expression = explode($delimiter, $expression);
@theking2
theking2 / import-dump.cmd
Created February 5, 2025 15:07
Import Mariadb Dump
@ECHO OFF
@ECHO Expanding
@tar -xf %1
@ECHO Importing
@"C:\wamp\bin\mariadb\mariadb10.6.18\bin\mysql.exe" --user=username --password=password database < %~n1
@ECHO Cleaning
@del %~n1
@theking2
theking2 / config.php
Last active January 27, 2025 09:31
docker-compose.yaml for nginx-proxy-manager with nextcloud
<?php
$CONFIG = [
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' =>
[
[
'path' => '/var/www/html/apps',
'url' => '/apps',
'writable' => false,
@theking2
theking2 / css-units-best-practices.md
Last active October 6, 2024 08:43 — forked from basham/css-units-best-practices.md
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px, vw, dvh, svh ch, ex, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

This file has been truncated, but you can view the full file.
2024-07-03 19:29:48,804 14596 [INFO ] - [NuGet] OK https://community.chocolatey.org/api/v2/Packages(Id='nodejs',Version='12.6.0') 374ms
2024-07-03 19:29:48,809 14596 [INFO ] - [NuGet] GET https://community.chocolatey.org/api/v2/Packages(Id='nodejs.install',Version='12.6.0')
2024-07-03 19:29:49,282 14596 [INFO ] - [NuGet] OK https://community.chocolatey.org/api/v2/Packages(Id='nodejs.install',Version='12.6.0') 472ms
2024-07-03 19:29:49,285 14596 [INFO ] - [NuGet] GET https://community.chocolatey.org/api/v2/Packages(Id='nodejs',Version='12.5.0')
2024-07-03 19:29:49,416 14596 [INFO ] - [NuGet] OK https://community.chocolatey.org/api/v2/Packages(Id='nodejs',Version='12.5.0') 131ms
2024-07-03 19:29:49,419 14596 [INFO ] - [NuGet] GET https://community.chocolatey.org/api/v2/Packages(Id='nodejs.install',Version='12.5.0')
2024-07-03 19:29:49,933 14596 [INFO ] - [NuGet] OK https://community.chocolatey.org/api/v2/Packages(Id='nodejs.install',Version='12.5.0') 513ms
2024-07-03 19:29:49,936 14596 [INFO ] - [
@theking2
theking2 / selector.js
Created June 30, 2024 11:36
compact selector
/**
* returns a static (not live) NodeList representing a list of the document's elements that match the specified group of selectors.
* @param {string} selector
* @param {Element} [document] base
* @returns {(NodeList|Element|null)}
*/
const $ = (selector, base = document) => {
let elements = base.querySelectorAll(selector);
return (elements.length == 0) ? null : (elements.length == 1) ? elements[0] : elements;
}
@theking2
theking2 / ReplaceInFormFields.bas
Created June 29, 2024 12:50
ReplaceInFormFields
Private Sub ReplaceInFormFields(Semester)
Dim mergeField As Field
Dim fieldCode As String
' Loop through each merge field
For Each mergeField In ActiveDocument.Fields
If mergeField.Type = wdFieldMergeField Then
' Get the field code text
fieldCode = mergeField.Code.Text
<?php declare(strict_types=1);
/**
* ZipStepResponse
*
* This class creates a ZIP archive of the specified directory.
* With the name of the archive, it creates a new archive name if the current one is too large.
* in small steps to avoid PHP timeouts
*/
class ZipStepResponse
{
@theking2
theking2 / read-json-body.php
Last active June 17, 2024 16:50
read json body in php
<?php
$request = json_decode( file_get_contents( 'php://input' ) );
@theking2
theking2 / my.ini
Created June 6, 2024 10:11
charset/collation mariadb
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_520_ci