This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Contracts\Container\Container; | |
use Illuminate\Contracts\Container\ContextualAttribute; | |
use Illuminate\Support\Facades\Route; | |
/** | |
* Create a new contextual attribute that grabs fields from the request POST data. | |
* | |
* The equivalent of doing `$request->post($key, $default)` in a controller. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Typically it's common to add timestamp columns to the end of a database table, like this: | |
create table links ( | |
id bigserial primary key, | |
link text, | |
created_at timestamp without time zone not null default now(), | |
updated_at timestamp without time zone not null default now(), | |
deleted_at timestamp without time zone null default null | |
); | |
-- However, when new columns are added it starts to look weird |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mincoins(array $coins, int $target): int | |
{ | |
// Check the simplest answers first... | |
if (count($coins) === 0) { | |
return 0; | |
} | |
if (in_array($target, $coins)) { | |
return 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL | |
https://www.postgresql.org/docs/current/sql-createindex.html | |
https://www.postgresql.org/docs/current/datatype-json.html | |
https://www.postgresql.org/docs/current/functions-json.html | |
https://www.postgresql.org/docs/current/ltree.html | |
https://notso.boringsql.com/posts/how-not-to-change-postgresql-column-type/ | |
https://patshaughnessy.net/2017/12/12/installing-the-postgres-ltree-extension | |
https://pganalyze.com/blog/5mins-postgres-17-incremental-backups | |
https://www.mydbops.com/blog/postgresql-17-incremental-backup-pg-basebackup-pg-combinebackup/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Docker | |
docker run --rm -it --network="host" --add-host host.docker.internal:host-gateway dimitri/pgloader:latest pgloader --verbose --debug --client-min-messages debug --log-min-messages debug mysql://<user>:<password>@127.0.0.1:3306/dbname postgresql://<user>:<password>@127.0.0.1:5432/dbname | |
# Brew | |
# @see: https://github.com/dimitri/pgloader/issues/962 | |
brew install pgloader | |
pgloader --verbose --debug --client-min-messages debug --log-min-messages debug --dynamic-space-size 262144 -v pgloader.load | |
# Config (pgloader.load) | |
LOAD DATABASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disable the firewall: | |
/usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off | |
Remove the firewall config (**doesn't work due to permissions**): | |
sudo rm /usr/libexec/ApplicationFirewall/com.apple.alf.plist | |
Or, backup the firewall config (**doesn't work due to permissions**): | |
sudo mv /usr/libexec/ApplicationFirewall/com.apple.alf.plist /usr/libexec/ApplicationFirewall/com.apple.alf.plist.bak | |
Enable the firewall: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Array Looping | |
*/ | |
const arr = ['foo']; | |
// A for...in loop will return the key... | |
// @see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in | |
for (const key in arr) { | |
console.log(key); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php | |
$attr3 = 'baz'; | |
$attr4 = 99_999; | |
$attr5 = new stdClass; | |
$attrWtf = 'wtf'; | |
@endphp | |
<x-my-component | |
attr1="foo" {{-- Component receives string --}} | |
attr2="{{ 'bar' }}" {{-- Component receives string --}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @see: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#usage | |
final readonly class DatabaseConfig | |
{ | |
#[Concat( | |
#[Env('DB_HOST')], | |
#[Str('://')], | |
#[Env('DB_USER')], | |
#[Str('@')], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Contextual attributes were implementated by @innocenzi and @ollieread: | |
- https://github.com/laravel/framework/pull/51934 | |
- https://github.com/laravel/framework/pull/52428 | |
I added contextual attributes for the core drivers: | |
- https://github.com/laravel/framework/pull/52265 |
NewerOlder