Skip to content

Instantly share code, notes, and snippets.

@mbrowniebytes
mbrowniebytes / git-delete-merged-local-branches.sh
Created April 24, 2023 19:46
Delete merged local branches older than N days
#!/bin/bash
# delete merged local branches
days=90
found=0
# preview
# git branch --merged | grep -v -E "\\*|\bmaster\b|\bmain\b|\bdevelopment\b" | xargs -r -n 1
# list branches merged
@mbrowniebytes
mbrowniebytes / idea.properties
Created July 17, 2022 01:57
IntelliJ IDE properties
# Configuration directory
# idea.config.path=%APPDATA%\JetBrains\<product><version>
# Plugins directory
#idea.plugins.path=%APPDATA%\JetBrains\<product><version>\plugins
# System directory
#idea.system.path=%LOCALAPPDATA%\JetBrains\<product><version>
idea.system.path=R:/intellij
@mbrowniebytes
mbrowniebytes / commit-msg
Created May 12, 2021 15:35
Git hook to ensure commit starts with ticket number
#!/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 15:33
Git hook to prepend ticket number to commit message
#!/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 15:28
Git hook to enforce branch names
#!/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 March 29, 2021 19:36
Configure your bash profile for git
# 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
<?php
namespace App\Traits;
trait Stats
{
private $timer_start;
private $timer_finish;
public function statsTimerStart()
@mbrowniebytes
mbrowniebytes / SlimPHP cli.php
Last active September 30, 2021 17:17
Slim PHP from the command line
<?php
if (PHP_SAPI != 'cli') {
exit("CLI only");
}
if (empty($argv) || count($argv) < 2) {
exit("Missing route for CLI");
}
@mbrowniebytes
mbrowniebytes / login_stats.sh
Created September 22, 2020 19:31
simple bash login stats
#!/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 July 15, 2022 18:47
IntelliJ IDE vmoptions
-server
-ea
-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=1024m
-Deditor.maximize.on.double.click=false
-Dfile.encoding=UTF-8