Skip to content

Instantly share code, notes, and snippets.

@tommy-muehle
tommy-muehle / composer hook-class.php
Last active August 29, 2015 14:07
How to add a coding-standard to phpcs via composer hook
<?php
namespace TM;
use Composer\Package\Package;
use Composer\Script\Event;
/**
* Class MyClass
*
<?php
namespace TM\Website\Controller\Abstracts;
use Silex\Application;
/**
* Class BaseController
*
* @package TM\Website\Controller
@tommy-muehle
tommy-muehle / prepare-commit-msg
Created June 30, 2015 10:31
Git hook to add JIRA issue key from branch-name (if it exists) and add it before the commit message
#!/usr/bin/env php
<?php
/**
* Add this file as "prepare-commit-msg" under /my-project/.git/hooks directory
* and make it executable. (chmod +x)
*
* Example:
* If Branchname was: "release/MYPRO-1-awesome-feature"
* and the commit message you typed in are: "Take this"
@tommy-muehle
tommy-muehle / composer
Last active May 10, 2016 08:41
/usr/local/bin/composer
#!/usr/bin/env bash
PHP=/usr/local/opt/php70/bin/php
ARGUMENTS="--ignore-platform-reqs --optimize-autoloader"
EXCLUDE_COMMANDS=(init selfupdate dumpautoload diagnose)
for item in "${EXCLUDE_COMMANDS[@]}"; do
if [[ $1 == "$item" ]]; then ARGUMENTS=""; fi
done
echo "Running composer with $($PHP -v)"
@tommy-muehle
tommy-muehle / post-receive
Last active May 24, 2019 09:53
Git hook to auto-merge hotfix branches
#!/usr/bin/env bash
while read oldrev newrev refname
do
BRANCH=$(git rev-parse --symbolic --abbrev-ref $refname)
if [[ "$BRANCH" =~ ^hotfix/* ]]; then
echo " /==============================="
echo " | HOTFIX DETECTED ..."
GIT_WORK_TREE=/tmp git checkout master -f -q
GIT_WORK_TREE=/tmp git merge $BRANCH -q --comit -m "Merge $BRANCH" --no-ff
@tommy-muehle
tommy-muehle / scare.sh
Last active July 1, 2016 13:50
admin-scare | Usage: .bashrc ./scare.sh
#!/bin/bash
messages=("Encrypt / ... Waiting" "Create bitcoin ... Waiting" "Format disk ... Waiting" "Copy all emails ... Waiting" "Update passwords ... Waiting")
echo ${messages[$RANDOM % ${#messages[@]} ]}
sleep 2000
@tommy-muehle
tommy-muehle / performance-tester.php
Last active January 5, 2017 14:05
Wrapper to simulate a "composer run-script post-update-cmd" to start tooly-composer-script's script handler. The standard way "blackfire run composer run-script post-install-cmd" only returns a big passthru. (https://blackfire.io/profiles/4013cbc8-af9d-49ba-83ac-becc921a322b/graph?settings%5Bdimension%5D=wt&settings%5Bdisplay%5D=landscape&settin…
<?php
require __DIR__ . '/../vendor/autoload.php';
use Composer\Script\Event;
use Composer\IO\ConsoleIO;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Helper\HelperSet;
use Tooly\ScriptHandler;
@tommy-muehle
tommy-muehle / php.ini
Created March 22, 2017 09:07
php.ini
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
@tommy-muehle
tommy-muehle / CacheWarmer.php
Last active September 18, 2017 09:45
Gist's for better testing article
<?php
namespace My\App;
class CacheWarmer
{
private $cacheDirectory;
public function __construct(string $cacheDirectory)
{
@tommy-muehle
tommy-muehle / main.go
Created January 4, 2018 09:15
PubSub subscription example
package main
import (
"context"
"log"
"cloud.google.com/go/pubsub"
)
func main() {