Skip to content

Instantly share code, notes, and snippets.

@rodgerhe
rodgerhe / aws-sts.sh
Created April 19, 2021 11:36 — forked from joariasl/aws-sts.sh
Script to issue a STS token using an AWS profile credential that set another AWS profile credential with the result
#!/bin/bash
script_name=`basename "$0"`
text_bold=$(tput bold)
text_normal=$(tput sgr0)
showHelp() {
echo -e "${script_name}
${text_bold}DESCRIPTION${text_normal}
@rodgerhe
rodgerhe / dot-p10k.zsh
Created November 26, 2020 01:31 — forked from practicalli-johnny/dot-p10k.zsh
Prezto and Powerline10k personal configurations
# Generated by Powerlevel10k configuration wizard on 2020-02-11 at 01:01 UTC.
# Based on romkatv/powerlevel10k/config/p10k-rainbow.zsh, checksum 05731.
# Wizard options: awesome-fontconfig + powerline, small icons, rainbow, time,
# angled separators, blurred heads, sharp tails, 2 lines, disconnected, full frame,
# darkest-ornaments, sparse, few icons, concise, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with powerline prompt style with colorful background.
# Type `p10k configure` to generate your own config based on it.
#
@rodgerhe
rodgerhe / delete_branches_older_than.sh
Created November 26, 2020 00:53 — forked from AvnerCohen/delete_branches_older_than.sh
Script to delete branches older than 6 months old, ignore local vs remote errors.
#!/bin/sh
ECHO='echo '
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
if [[ "$(git log $branch --since "6 months ago" | wc -l)" -eq 0 ]]; then
if [[ "$DRY_RUN" = "false" ]]; then
ECHO=""
fi
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git branch -d $local_branch_name
@rodgerhe
rodgerhe / rename-database.sql
Created September 4, 2020 04:09 — forked from shivanshs9/rename-database.sql
Rename MySQL Database
DROP PROCEDURE IF EXISTS moveTables;
DROP PROCEDURE IF EXISTS renameDatabase;
DELIMITER $$
CREATE PROCEDURE moveTables(_schemaName varchar(100), _newSchemaName varchar(100))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE table_name VARCHAR(64);
DECLARE table_cursor CURSOR FOR SELECT information_schema.tables.table_name FROM information_schema.tables
WHERE information_schema.tables.table_schema = _schemaName;
@rodgerhe
rodgerhe / prepare-commit-msg.sh
Last active July 6, 2020 12:52
Automatically add branch name as prefix in git commit message
#!/bin/sh
#
# A githook script to prepare the commit log message.
# It adds the branch name to the commit message (based on name pattern), if it is not already part of it.
# Branch name pattern is configured in regex variable.
branchPath=$(git symbolic-ref -q HEAD) # Somthing like refs/heads/myBranchName
branchName=${branchPath##*/} # Get text behind the last / of the branch path
# update the regex pattern to match with the project
@rodgerhe
rodgerhe / iterm2.md
Created May 24, 2020 14:15 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@rodgerhe
rodgerhe / laravel_conditional_index_migration.php
Created March 12, 2020 23:34 — forked from Razoxane/laravel_conditional_index_migration.php
Laravel - Create Index If Not Exists / Drop Index If Exists
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class LaravelConditionalIndexMigration extends Migration
{
/**
* Run the migrations.
@rodgerhe
rodgerhe / git-pushing-multiple.rst
Created August 4, 2019 12:46 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just