Skip to content

Instantly share code, notes, and snippets.

View verschuur's full-sized avatar
🤠

Govert Verschuur verschuur

🤠
  • Funxtion
  • Amsterdam
View GitHub Profile
// Checkout file from stash
git checkout stash@{0} -- <filename>
// Save file from stash using a different name
git show stash@{0}:<full filename> > <newfile>
@verschuur
verschuur / app.php
Created November 3, 2020 09:39 — forked from mmikkel/app.php
Craft 3 multi-env email settings
<?php
/**
* Yii Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app/main.php and [web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
# 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>
# 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">
<?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 September 9, 2019 14:30 — forked from xedef/remove-indexing-files.md
Remove all .DS_Store files (or any unwanted indexing file) from a S3 bucket, recursively

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"

# 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 November 16, 2017 15:55
Laravel middleware code to add response headers to prevent SEO indexing.
<?php
namespace App\Http\Middleware;
use Closure;
class PreventSEOIndexingHeaders
{
/**
* Handle an incoming request.
@verschuur
verschuur / ViewComposerServiceProvider.php
Last active November 16, 2017 16:18
Laravel ViewComposerServiceProvider example with several registering options
<?php
namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class ViewComposerServiceProvider extends ServiceProvider
{
/**