Skip to content

Instantly share code, notes, and snippets.

View gilbitron's full-sized avatar

Gilbert Pellegrom gilbitron

View GitHub Profile
@gilbitron
gilbitron / stripe-exporter.php
Created March 28, 2023 15:01
Stripe > Lemon Squeezy exporter
<?php
/**
* This script creates an `export.csv` file of Stripe PaymentIntent data that is
* in the correct format for importing into Lemon Squeezy.
*
* @link https://docs.lemonsqueezy.com/help/migrating/migrating-from-stripe
*
* Usage:
* 1. Run `composer require stripe/stripe-php`
* 2. Replace `[STRIPE_API_KEY]` with your Stripe API key
@gilbitron
gilbitron / Caddyfile
Created March 14, 2022 17:23
Caddy wildcard + custom domains
{
on_demand_tls {
ask http://12.34.56.78/caddy-check
}
email hi@example.com
}
*.example.com {
tls ...custom certs...
reverse_proxy http://12.34.56.78
@gilbitron
gilbitron / CaddyController.php
Created June 16, 2021 10:55
Enabling HTTPS (SSL) for Laravel Sail using Caddy
<?php
# app/Http/Controllers/CaddyController.php
namespace App\Http\Controllers;
use App\Store;
use Illuminate\Http\Request;
class CaddyController extends Controller
{
@gilbitron
gilbitron / 1_write.php
Last active March 29, 2017 12:31
Testing re-serializing data in PHP that contains classes
<?php
include 'ExampleClass1.php';
include 'ExampleClass2.php';
$object = new stdClass;
$object->foo = 'bar';
$class1 = new ExampleClass1();
$class2 = new ExampleClass2();
@gilbitron
gilbitron / example1.php
Last active February 10, 2017 10:23
Modifying Arrays in PHP Closures
<?php
$array = [];
(function() use ($array) {
// Add an item to the array
$array[] = 'item';
})();
var_dump($array);

Keybase proof

I hereby claim:

  • I am gilbitron on github.
  • I am gilbitron (https://keybase.io/gilbitron) on keybase.
  • I have a public key whose fingerprint is 4DCC 72D3 B8F2 14E0 91E9 EC60 4F94 C68C 2F1A 4A3B

To claim this, I am signing this object:

@gilbitron
gilbitron / InvoicePaid.php
Created November 14, 2016 12:31
Convert the Laravel Spark invoice email to a notification email
<?php // app/Notifications/InvoicePaid.php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Laravel\Cashier\Invoice;
@gilbitron
gilbitron / curl-multi-test.php
Last active June 5, 2019 09:55
Testing 95 regular curl_exec requests vs curl_multi_exec requests
<?php
$sites = [
'http://www.google.com/',
'http://www.facebook.com/',
'http://www.youtube.com/',
'http://www.yahoo.com/',
'http://www.live.com/',
'http://www.wikipedia.org/',
'http://www.baidu.com/',
@gilbitron
gilbitron / after.sh
Last active March 1, 2023 22:06
Laravel Homestead daily database backup cron provision (after.sh)
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
if [ ! -f /etc/cron.daily/database-backup ]; then
sudo bash -c "cat > /etc/cron.daily/database-backup" <<EOL
#!/bin/bash
@gilbitron
gilbitron / ApiController.php
Last active July 21, 2020 01:05
ApiController Template for Laravel Spark
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
abstract class ApiController extends Controller