Skip to content

Instantly share code, notes, and snippets.

View fgilio's full-sized avatar

Franco Gilio fgilio

View GitHub Profile
WITH RECURSIVE fizz_buzz (sequence, modulo_3, modulo_5) AS (
SELECT 1, CAST('' AS CHAR(4)), CAST('' AS CHAR(5))
UNION ALL
SELECT sequence + 1,
IF(MOD(sequence + 1, 3) = 0, 'Fizz', ''),
IF(MOD(sequence + 1, 5) = 0, 'Buzz', '')
FROM fizz_buzz
WHERE sequence < 100
)
@Billz95
Billz95 / .php_cs.dist
Last active January 15, 2024 02:58
A Customised fixer for PHP-CS-Fixer to use `prettier`'s php plugin to pre-process the code before getting analysed by other fixers. This would enable `php-cs-fixer` to take advantage of `prettier`'s ability of managing long line.
<?php
require_once __DIR__.'/relative/path/to/PrettierPHPFixer/File';
return PhpCsFixer\Config::create()
->registerCustomFixers([
(new PrettierPHPFixer()),
])
->setRules([
'Prettier/php' => true,
@poing
poing / laravel_facades.md
Last active March 25, 2024 21:37
Laravel Facades

Understanding Facades in Laravel

What's a Facade?

The Laravel explination, shown below is confusing.

Facades provide a "static" interface to classes that are available in the application's service container. Laravel ships with many facades which provide access to almost all of Laravel's features. Laravel facades serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

Many examples use Cache::get('key') to demonstrate how a Facade works. Comparing the following code to the utility that a Facade provides.

@stidges
stidges / tailwind.itermcolors
Last active November 30, 2023 21:00
An iTerm2 color scheme based on the Tailwind CSS color scheme (https://tailwindcss.com/docs/colors)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.17254902422428131</real>
<?php
namespace App\Libraries\Queue;
use Illuminate\Events\Dispatcher;
use Illuminate\Queue\DatabaseQueue;
use Illuminate\Support\Str;
use Laravel\Horizon\Events\JobDeleted;
use Laravel\Horizon\Events\JobPushed;
use Laravel\Horizon\Events\JobReleased;
@Krato
Krato / Laravel Nova snippets.md
Last active November 25, 2020 23:02
A set of snippets I use in Laravel Nova

A set of snippets I use in Laravel Nova

Snippets

Vue,js devtools (Only with manual installation)

cd ./nova 
yarn
mv webpack.mix.js.dist webpack.mix.js
@loganvolkers
loganvolkers / Byte Formatting for Google Sheets.md
Last active April 16, 2024 10:42
Byte formatting for Google Sheets
@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@atomkirk
atomkirk / gcloud-function-printenv.sh
Created April 28, 2018 13:06
printenv of google cloud function
X_GOOGLE_FUNCTION_TIMEOUT_SEC=540
X_GOOGLE_FUNCTION_MEMORY_MB=2048
FUNCTION_TIMEOUT_SEC=540
SHLVL=1
FUNCTION_MEMORY_MB=2048
X_GOOGLE_FUNCTION_TRIGGER_TYPE=CLOUD_STORAGE_TRIGGER
PORT=8080
ENTRY_POINT=**********
OLDPWD=/var/tmp/worker/
HOME=/tmp
getHexColor = (color) ->
return "" unless color
return color if /^#/.test(color)
rgbValues = getRGBValues(color)
hexValues = rgbValues.map(numberToHex)
"#" + hexValues.join("")
numberToHex = (number) ->
"0#{number.toString(16)}".slice(-2).toUpperCase()