This file contains hidden or 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
exports.handler = (evt, ctx, callback) => { | |
const authorizationHeader = evt.headers.Authorization; | |
if (!authorizationHeader) { | |
return callback("Unauthorized"); | |
} | |
const encodedCreds = authorizationHeader.split(" ")[1]; | |
const [username, password] = Buffer.from(encodedCreds, "base64") | |
.toString() |
This file contains hidden or 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
{ | |
"message": "The given data was invalid.", | |
"errors": { | |
"username": [ | |
"The username cannot include spaces", | |
"The username must contain at least 1 letter and number" | |
], | |
"password": [ | |
"The password must be longer than 8 characters" | |
] |
This file contains hidden or 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 | |
declare(strict_types=1); | |
use PhpCsFixer\Config; | |
use PhpCsFixer\Finder; | |
$finder = Finder::create() | |
->in(__DIR__) | |
->exclude([ |
This file contains hidden or 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 | |
/** | |
* Outputs the query with bindings inserted. | |
* | |
* @param \Illuminate\Database\Eloquent\Builder $query | |
* @return string | |
*/ | |
function combine_query(\Illuminate\Database\Eloquent\Builder $query): string | |
{ |
This file contains hidden or 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 | |
/** | |
* @param string $content | |
* @return array | |
*/ | |
function csv_to_array(string $content): array | |
{ | |
$rows = str_getcsv($content, "\n"); |
This file contains hidden or 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 | |
/** | |
* @param string $content | |
* @param int $width | |
* @param int $height | |
* @return string | |
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException | |
*/ | |
function crop_and_resize(string $content, int $width, int $height): string |
This file contains hidden or 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
# Where 12345 is the host port and 80 is what it maps to. | |
vagrant ssh -- -R 12345:localhost:80 |
This file contains hidden or 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 | |
if (!function_exists('register_enum_type')) { | |
/** | |
* Registers the enum type as a string. | |
* Call this in the constructor of your migration. | |
*/ | |
function register_enum_type() | |
{ | |
\Illuminate\Support\Facades\Schema::getConnection() |
This file contains hidden or 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 // app/Providers/BladeServiceProvider.php | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
class BladeServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap any application services. |
This file contains hidden or 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\Http\UploadedFile; | |
class Flatten | |
{ | |
/** | |
* Used for turning an array into a PHP friendly name. | |
* | |
* @param array $array |