Skip to content

Instantly share code, notes, and snippets.

Avatar

Alessandro Benoit micc83

View GitHub Profile
@micc83
micc83 / fix-msyql-1067.php
Created Jun 22, 2021
Fix issues with: 1067 Invalid default value for 'created_at'
View fix-msyql-1067.php
<?php
// Fix issues with: 1067 Invalid default value for 'created_at'
DB::statement(<<<EOT
ALTER TABLE `users`
MODIFY created_at TIMESTAMP null,
MODIFY updated_at TIMESTAMP null
DEFAULT null;
EOT);
@micc83
micc83 / sepa.php
Created May 28, 2021
Stripe SEPA full php example
View sepa.php
<?php
/**
* @see https://stripe.com/docs/billing/subscriptions/sepa-debit
*/
use Stripe\Customer;
use Stripe\SetupIntent;
use Stripe\Stripe;
use Stripe\Subscription;
@micc83
micc83 / TestCase.php
Created May 13, 2021
Assert a given command is scheduled once on Laravel Task Scheduling
View TestCase.php
<?php
namespace Tests;
use Illuminate\Console\Scheduling\Event;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Str;
abstract class TestCase extends BaseTestCase
@micc83
micc83 / upload.js
Created Apr 30, 2021 — forked from virolea/upload.js
Tracking file upload progress using axios
View upload.js
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@micc83
micc83 / settings.json
Last active Jul 22, 2020
Windows Terminal config file
View settings.json
// This file was initially generated by Windows Terminal 0.11.1251.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@micc83
micc83 / bosh.sh
Created Dec 20, 2018
Tail for commands on Mac
View bosh.sh
botch() {
while true; do
(echo -en '\033[H'
CMD="$@"
bash -c "$CMD" | while read LINE; do
echo -n "$LINE"
echo -e '\033[0K'
done
echo -en '\033[J') | tail -r | tail -r
sleep 2
@micc83
micc83 / .zshrc
Created Nov 13, 2018
Laradock bash aliases
View .zshrc
alias ld-up="(cd laradock;docker-compose up -d apache2 mariadb)"
alias ld-down="(cd laradock;docker-compose down)"
alias ld-ssh="(cd laradock;docker-compose exec workspace bash)"
@micc83
micc83 / .htaccess
Created Jan 30, 2018
Maintenance mode through .htaccess
View .htaccess
# Create file maintenance.html then
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
@micc83
micc83 / mysqldump.php
Created Jun 5, 2017
Simple PHP script to dump a MySql database
View mysqldump.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$database = 'db';
$user = 'user';
$pass = 'pass';
$host = 'localhost';
@micc83
micc83 / snapshot.php
Last active Jan 4, 2019
PHPUnit Assertion that asserts the response content match a previous taken snapshot
View snapshot.php
<?php
/**
* Assert the response content match a previous taken snapshot.
* If the snapshot doesn't exists on the first run it gets
* created and the test is marked as incomplete.
*/
private function seeSnapshot()
{
$testName = debug_backtrace()[1]['function'];
$filename = "snapshots/{$testName}.json";