Skip to content

Instantly share code, notes, and snippets.

View micc83's full-sized avatar

Alessandro Benoit micc83

View GitHub Profile
@micc83
micc83 / skip-to-check-out.php
Last active April 11, 2024 00:13
Skip cart and redirect to direct checkout on WooCommerce
<?php
/**
* Skip cart and redirect to direct checkout
*
* @package WooCommerce
* @version 1.0.0
* @author Alessandro Benoit
*/
// Skip the cart and redirect to check out url when clicking on Add to cart
@micc83
micc83 / mysqldump.php
Created June 5, 2017 13:17
Simple PHP script to dump a MySql database
<?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 / var_dump.js
Created July 2, 2013 14:06
Javascript var_dump (for diehard PHP coder)
function varDump( Obj ) {
this.eplode = function( theObj ){
var output = ("<ul style='list-style:none;padding-left:20px;margin:0;color:#02adea;'>");
if( typeof theObj == 'object' ){
for( var p in theObj ){
output += "<li style='font-size:12px;'>";
if( theObj[p] &&
( theObj[p].constructor == Array || theObj[p].constructor == Object ) ){
@micc83
micc83 / wpcf7-mail-tags.php
Created June 23, 2016 09:40
Create custom tags for Wordpress Contact Form 7
<?php
add_filter( 'wpcf7_special_mail_tags', function ( $output, $name, $html ) {
if ($name === 'current_url'){
return "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
return $output;
}, 10, 3 );
@micc83
micc83 / fix-msyql-1067.php
Created June 22, 2021 13:21
Fix issues with: 1067 Invalid default value for 'created_at'
<?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 15:39
Stripe SEPA full php example
<?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 08:19
Assert a given command is scheduled once on Laravel Task Scheduling
<?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 April 30, 2021 13:03 — forked from virolea/upload.js
Tracking file upload progress using axios
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 July 22, 2020 12:51
Windows Terminal config file
// 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 / .htaccess
Created May 13, 2015 16:25
htaccess google speed
Header unset Pragma
FileETag None
Header unset ETag
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"