Skip to content

Instantly share code, notes, and snippets.

View Sammyjo20's full-sized avatar
🔭
Stargazing

Sam Sammyjo20

🔭
Stargazing
  • EU-WEST-2
View GitHub Profile
@Sammyjo20
Sammyjo20 / Pest.php
Created June 10, 2024 11:14
Lazy Man's Saloon Fake
/**
* Lazy Man's Saloon Fake
*
* This will record every request that you make in your application and store it in a folder
* based on the name of the test. This is incredibly powerful, but I wouldn't recommend it
* for every request if you are doing the same things over as it will waste API calls.
*
* @return void
*/
function lazyFakeSaloon(): void
@Sammyjo20
Sammyjo20 / example.php
Created September 4, 2023 20:27
Saloon Custom Rate Limit Example
<?php
use Saloon\RateLimitPlugin\Limit;
use Saloon\Http\Response;
Limit::custom(function (Response $response, Limit $limit) {
$hasExceededLimit = (int)$response->header('x-ratelimit-remaining-requests') === 0;
if ($hasExceededLimit === true) {
$limit->exceeded($releaseInSeconds);
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddMissingHaystackColumnsFromVersionZeroDotEight extends Migration
{
/**
* Run the migrations.
@Sammyjo20
Sammyjo20 / api-paginator.php
Last active August 6, 2022 00:15
API Paginator
<?php
namespace App\Data;
class Paginator
{
/**
* Constructor
*
* @param int $totalPages
@Sammyjo20
Sammyjo20 / SaloonRecord.php
Last active July 11, 2022 21:25
Record a Saloon Response to create a fixture
<?php
/**
* Record a request and respond with a fixture.
*
* @throws \Sammyjo20\Saloon\Exceptions\SaloonInvalidMockResponseCaptureMethodException
* @throws ReflectionException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Sammyjo20\Saloon\Exceptions\SaloonException
* @throws JsonException
@Sammyjo20
Sammyjo20 / gist:f71070279270ff2f667c4b9867b12a23
Created February 16, 2022 11:28
Kill All Node Processes
killall -KILL node
@Sammyjo20
Sammyjo20 / scroll.js
Created February 7, 2022 08:15
Vue 2 Router Fix Scroll Position
const router = new VueRouter({
routes: routes,
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
});
gpg -c --no-synkey-cache --cipher-algo AES256 file-name.sql
@Sammyjo20
Sammyjo20 / EncryptedJson.php
Created October 22, 2020 11:18
EncryptedJson Cast
<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class EncryptedJson implements CastsAttributes
{
/**
* Cast the given value.