Skip to content

Instantly share code, notes, and snippets.

@pimbrouwers
pimbrouwers / README.md
Last active July 20, 2025 12:54
Turnpike

Turnpike

<?php
$db = new Turnpike\Db($dsn, DB_USER, DB_PASS);
$viewEngine = new Turnpike\PhpViewEngine(TEMPLATE_ROOT);
$router = new Turnpike\Router;

// Middleware 
$router-&gt;Run(function (Turnpike\Request $req, Turnpike\Response $res) {
@pimbrouwers
pimbrouwers / ubuntu-20_04-web-server-setup-instructions.md
Last active January 23, 2025 14:57
Ubuntu 20.04 Web Server Setup Instructions

Ubuntu 20.04 Web Server Setup Instructions

!!! Work in progress, use at your own risk. !!!

  • nginx
  • certbot
  • iptables

Updates

@pimbrouwers
pimbrouwers / c-sharp-parse-linkheader.cs
Last active April 5, 2024 20:53
C# Parse Link Header
public class LinkHeader
{
public string FirstLink { get; set; }
public string PrevLink { get; set; }
public string NextLink { get; set; }
public string LastLink { get; set; }
public static LinkHeader LinksFromHeader(string linkHeaderStr)
{
LinkHeader linkHeader = null;
@pimbrouwers
pimbrouwers / char-counts.md
Last active February 19, 2024 12:42
Useful character counts to help when deciding field length

8 CHARS

Lorem ip

16 CHARS

Lorem ipsum dolo

@pimbrouwers
pimbrouwers / mssql-calendar-table.sql
Last active October 12, 2023 13:20
SQL Server Calendar Table
USE master
GO
IF OBJECT_ID('dbo.calendar') IS NOT NULL
DROP TABLE dbo.calendar;
IF OBJECT_ID('dbo.fn_generate_calendar') IS NOT NULL
DROP FUNCTION dbo.fn_generate_calendar;
GO
@pimbrouwers
pimbrouwers / Invoke-DotnetExe.ps1
Last active December 3, 2022 01:44
Invoke-DotnetExe.ps1
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, HelpMessage = "The path to the project")]
[String]
$Project,
[Parameter(Mandatory = $true, HelpMessage = "The .NET Runtime Identifier")]
[ValidateSet("win-x64")]
[String]
$Rid,
@pimbrouwers
pimbrouwers / sqlite-calendar-table.sql
Last active November 16, 2022 21:46
SQLite Calendar Table
--DROP TABLE IF EXISTS calendar;
--CREATE TABLE calendar AS
WITH RECURSIVE dates_cte (dt) AS (
VALUES('1970-01-01') -- Choose a start date
UNION ALL
SELECT date(dt, '+1 day')
FROM dates_cte
WHERE dt < '2050-12-31' -- Choose an end date
),
calendar_cte AS (
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Project.Repo
{
public interface IMapper<TEntity> where TEntity : class
{
IEnumerable<PropertyInfo> Properties { get; }
Type Type { get; }
open System
open System.Text
[<AbstractClass; Sealed>]
type StringBuilderCache private () =
// The value 360 was chosen in discussion with performance experts as a compromise between using
// as litle memory (per thread) as possible and still covering a large part of short-lived
// StringBuilder creations on the startup path of VS designers.
[<Literal>]
static let _maxBuilderSize = 360
@pimbrouwers
pimbrouwers / Database.fsx
Created April 25, 2022 15:25
F# Database Abstractions using Donald
open System
open System.Data
open System.Data.Common
open Donald
//
// Logging
type LogError =
{ Error : exn
Message : string }