Skip to content

Instantly share code, notes, and snippets.

@mbrowniebytes
mbrowniebytes / commit-msg
Created May 12, 2021
Git hook to ensure commit starts with ticket number
View commit-msg
#!/usr/bin/env bash
# commit message file
commit_msg_file="$1"
valid_comment_prefix="^#?[0-9]{6,10} .+"
error()
{
@mbrowniebytes
mbrowniebytes / prepare-commit-msg
Created May 12, 2021
Git hook to prepend ticket number to commit message
View prepare-commit-msg
#!/usr/bin/env bash
# commit message file
commit_msg_file="$1"
# condition the commit is invoked; none (git commit), message (git commit -m <msg>), template, merge, squash, or commit
# commit_source=$2
# commit hash
# sha1=$3
local_branch="$(git rev-parse --abbrev-ref HEAD)"
@mbrowniebytes
mbrowniebytes / pre-commit
Created May 12, 2021
Git hook to enforce branch names
View pre-commit
#!/usr/bin/env bash
local_branch="$(git rev-parse --abbrev-ref HEAD)"
# valid_branch_regex="^(feature|bugfix|improvement|library|prerelease|release|hotfix)\/[a-z0-9._-]+$"
valid_branch_regex="^#?[0-9]{6,10}-[a-zA-Z]+$"
error()
{
echo "GIT PRE-COMMIT HOOK ERROR:"
@mbrowniebytes
mbrowniebytes / bash_profile.sh
Created Mar 29, 2021
Configure your bash profile for git
View bash_profile.sh
# change me vars
ec2_name="ec2namechangeme"
# use vim
export EDITOR=vim
alias vi="vim"
# allow tab auto complete w/ sudo
if [[ "$HOME" == "/home/ec2-user" ]]; then
View Stats.php
<?php
namespace App\Traits;
trait Stats
{
private $timer_start;
private $timer_finish;
public function statsTimerStart()
@mbrowniebytes
mbrowniebytes / cli.php
Last active Dec 14, 2020
Slim PHP from the command line
View cli.php
<?php
// command line only
if (PHP_SAPI != 'cli') {
exit("CLI only");
}
// 1st arg is calling script, and then should pass in a uri which should map to a route
if (empty($argv) || count($argv) < 2) {
exit("Missing route for CLI");
@mbrowniebytes
mbrowniebytes / login_stats.sh
Created Sep 22, 2020
simple bash login stats
View login_stats.sh
#!/bin/bash
# display motd on login, or sudo su - user as that is a login
# sudo vim /etc/profile.d/login_stats.sh
motd(){
SERVER="server-name - aws ec2"
# 15:52:46 up 13 days, 5:27, 1 user, load average: 0.00, 0.00, 0.00
@mbrowniebytes
mbrowniebytes / idea64.exe.vmoptions
Last active Aug 24, 2021
IntelliJ IDE vmoptions
View idea64.exe.vmoptions
-server
-ea
-Xms2048m
-Xmx4096m
-XX:ReservedCodeCacheSize=1024m
-Deditor.maximize.on.double.click=false
-Dfile.encoding=UTF-8
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
View phpcs.xml
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>PHP Code Sniffer configuration file.</description>
<!-- https://github.com/squizlabs/PHP_CodeSniffer -->
<!-- check all these dirs/files -->
<file>app</file>
<file>bin</file>
<file>cfg</file>
<file>src</file>