Skip to content

Instantly share code, notes, and snippets.

View zhanang19's full-sized avatar
🏠
Working from home

Zainal Hasan zhanang19

🏠
Working from home
View GitHub Profile
@valorin
valorin / Middleware-CSP.php
Last active February 5, 2024 18:34
CSP Middleware - the simple CSP middleware I use across all of my projects.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\Str;
/**
* Simple Content Security Policy middleware.
@BinaryKitten
BinaryKitten / toRawSql.php
Last active January 22, 2023 21:52
toRawSql.php
<?php
declare(strict_types=1);
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder as QueryBuilder;
QueryBuilder::macro(
'toRawSql',
function () {
@tomholford
tomholford / install_pg_gem.md
Last active April 18, 2024 20:37
Install postgresql gem `pg` on macOS

Installing pg gem on macOS

If you're trying to install the postgresql gem pg and it is failing with the following error message:

Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: ~/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pg-1.2.3/ext
~/.rbenv/versions/3.0.0/bin/ruby -I ~/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -r ./siteconf20210125-97201-pycpo.rb extconf.rb
@torian257x
torian257x / app.blade.php
Last active April 26, 2021 07:29
multi build of laravel mix with performance improvement for tailwindcss "yarn hot" -> javascript as hot, tailwind as watch
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
{
"name": "mmollick/github-team-repos",
"authors": [
{
"name": "Mike Mollick",
"email": "mollick2@gmail.com"
}
],
"require": {
"guzzlehttp/guzzle": "^7.0"
@3v1n0
3v1n0 / vscode-unused-workspace-storage-cleanup.sh
Last active April 19, 2024 14:51
VSCode unused workspaceStorage cleanup
#!/bin/bash
CONFIG_PATH=~/.config/Code
for i in $CONFIG_PATH/User/workspaceStorage/*; do
if [ -f $i/workspace.json ]; then
folder="$(python3 -c "import sys, json; print(json.load(open(sys.argv[1], 'r'))['folder'])" $i/workspace.json 2>/dev/null | sed 's#^file://##;s/+/ /g;s/%\(..\)/\\x\1/g;')"
if [ -n "$folder" ] && [ ! -d "$folder" ]; then
echo "Removing workspace $(basename $i) for deleted folder $folder of size $(du -sh $i|cut -f1)"
@TerrePorter
TerrePorter / app.php
Last active January 25, 2024 21:10
Laravel: Giving a service provider load priority
<?php
/*
In the bootstrap/app.php file, add one of the following above the return statement.
*/
/*
Option 1, if you want to be ballsey and load before any service provider in the config/app.php file.
*/
$app->resolving(Illuminate\Foundation\Bootstrap\RegisterProviders::class, function () use ($app) {
@hgrimelid
hgrimelid / php-dyld.md
Created August 17, 2018 07:36
php: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.61.dylib

After upgrading to Node v.10.9.0 via Homebrew the following error message was thrown from PHP:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.61.dylib
  Referenced from: /usr/local/bin/php
  Reason: image not found

Reinstall PHP to fix, for me that's:

@paulund
paulund / AppServiceProvider.php
Last active March 16, 2023 18:10
Laravel Cache Auth::user(). Learn how to cache the logged in user at https://paulund.co.uk/laravel-cache-authuser
<?php
namespace App\Providers;
use App\Models\User;
use App\Observers\UserObserver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@jacklorusso
jacklorusso / workbench.colorCustomizations.json
Last active December 19, 2023 07:40
A list of all Visual Studio Code customizable colors, grouped by UI region. Copy and paste into User Settings (comments are allowed) to tweak an existing theme or work on your own.
"workbench.colorCustomizations": {
// Contrast Colors - The contrast colors are typically only set for high contrast themes. If set, they add an additional border around items across the UI to increase the contrast.
"contrastActiveBorder": "",
"contrastBorder": "",
// Base Colors
"focusBorder": "",
"foreground": "",
"widget.shadow": "",
"selection.background": "",
"descriptionForeground": "",