Skip to content

Instantly share code, notes, and snippets.

View BARNZ's full-sized avatar

BARNZ BARNZ

  • Christchurch
  • 06:56 (UTC +12:00)
View GitHub Profile
/**
* Execute the given function and set the given ref to true while it is busy executing
*/
export function trackState(stateRef, fn) {
stateRef.value = true
return Promise.resolve(fn())
.finally(() => stateRef.value = false)
}
My notes for upgrading laragon to work with latest apache and php8.1
Update to laragon 5:
- Stop all running services in laragon
- Make sure laragon itself is properly closed
- Download the latest laragon.exe and overwrite your original laragon.exe
https://github.com/leokhoa/laragon/releases/download/5.0.0/laragon.exe
Update to latest apache
- Download the latest apache 2.4 VS16 for windows (Apache 2.4.x OpenSSL 1.1.1 VS16):
// Using postgres ltree module to build an automatic materialised path from a parent_id field
// Useful for parent-child database structures where you need to query for non-immediate descendants or ancestors
DB::statement("CREATE EXTENSION IF NOT EXISTS pg_trgm"); // for additional index types
DB::statement("CREATE EXTENSION IF NOT EXISTS ltree"); // to build a materialised path with
// Helper function for fetching a materialised path of the given table and ID
// Assumes the parent fkey is parent_id
$sql = <<<'SQL'
@BARNZ
BARNZ / EXIFRotate.php
Created December 2, 2017 04:28
Auto-rotate image based on EXIF data
const EXIF_ROTATION_0 = 1;
const EXIF_MIRROR_0 = 2;
const EXIF_ROTATION_90 = 6;
const EXIF_MIRROR_90 = 5;
const EXIF_ROTATION_180 = 3;
const EXIF_MIRROR_180 = 4;
const EXIF_ROTATION_270 = 8;
const EXIF_MIRROR_270 = 7;
const GIF_TYPE = 1;
@BARNZ
BARNZ / GenerateToken.php
Last active September 7, 2023 18:39
Generate a Laravel 5.x hash/token
<?php
use Illuminate\Support\Facades\Password;
# Generate a token in the same style as laravels password reset tokens.
# Will generate something like: 785f616c4978a87ad65a899ed4133b358a4697649c55b0965a7ebb7486bd9801
/** @var DatabaseTokenRepository */
$repo = Password::getRepository();
$token = $repo->createNewToken($user);
@BARNZ
BARNZ / AppVersion.php
Created January 15, 2017 04:24
Laravel 5.x middleware to retrieve the version number from Node JS package.json
<?php
namespace App\Http\Middleware;
use Closure;
/**
* Reads the current version of the app into an APP_VERSION variable by reading
* the applications Node JS package.json file.
*
@BARNZ
BARNZ / FixMicrosoftLinks.php
Created January 15, 2017 04:18
Laravel 5.x middleware to handle hotlinking from MS Apps