Skip to content

Instantly share code, notes, and snippets.

Govert Verschuur verschuur

View GitHub Profile
View SQL snippets
# Copy field data from one table to another
UPDATE target_table
INNER JOIN source_table USING (matching_key_field)
SET target_table.<field> = source_table.<field>
View PHPCS commands and info
# Commands
phpcs --config-set default_standard PSR12
phpcs --config-set show_progress 1
phpcs --config-set colors 1
phpcs --report=gitblame /path/to/code
phpcs -s --report=gitblame /path/to/code
# Handy rulesets
<?xml version="1.0"?>
<ruleset name="Testing Suites rulesets">
View php-cli-progress-bar.php
<?php
# Shamelessly stolen from https://stackoverflow.com/questions/1053060/file-put-contents-with-array
# Remember to start $done with 1 or more, or you'll get a division by zero. 🙀
function show_status($done, $total, $size = 30)
{
static $start_time;
// if we go over our bound, just ignore it
if ($done > $total) {
return;
@verschuur
verschuur / remove-indexing-files.md
Created Sep 9, 2019 — forked from xedef/remove-indexing-files.md
Remove all .DS_Store files (or any unwanted indexing file) from a S3 bucket, recursively
View remove-indexing-files.md

You can replace "*.DS_Store" with any other recurrent file (e.g. Desktop.ini)

Please!

Validate that you are going to delete only what you want passing the --dryrun option. I've left if by default just in case of copy/paste.

aws s3 rm s3://your.bucket.name/maybe-a-subkey --dryrun --recursive --exclude "*" --include "*.DS_Store"

View Heroku env export & import
# Instructions:
# Make sure you have the Heroku CLI installed and configured (https://devcenter.heroku.com/articles/heroku-cli)
# Replace source-heroku-app and target-heroku-app with your app name
# 1. Export existing app’s variables to config.txt.
heroku config -s -a source-heroku-app > config.txt
# 2. Review and push to another app
cat config.txt | tr '\n' ' ' | xargs heroku config:set -a target-heroku-app
@verschuur
verschuur / PreventSEOIndexingHeaders.php
Created Nov 16, 2017
Laravel middleware code to add response headers to prevent SEO indexing.
View PreventSEOIndexingHeaders.php
<?php
namespace App\Http\Middleware;
use Closure;
class PreventSEOIndexingHeaders
{
/**
* Handle an incoming request.
@verschuur
verschuur / ViewComposerServiceProvider.php
Last active Nov 16, 2017
Laravel ViewComposerServiceProvider example with several registering options
View ViewComposerServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class ViewComposerServiceProvider extends ServiceProvider
{
/**
@verschuur
verschuur / .htaccess
Created Jan 16, 2017
Handy dandy complete .htaccess
View .htaccess
# ----------------------------------------------------------------------
# | Basic rewrite settings
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
You can’t perform that action at this time.