Skip to content

Instantly share code, notes, and snippets.

@ConorSheehan1
ConorSheehan1 / find_tools.sh
Last active Mar 21, 2019
grep within glob files
View find_tools.sh
# bash, find import in every .py file recursively under the current dir
grep -rin --include="*.py" import
# find files bye name and follow symlinks
find -L ./ -name "*.sublime-snippet"
@ConorSheehan1
ConorSheehan1 / standup.sh
Last active Jul 23, 2020
bash script to show git commits for a standup.
View standup.sh
# show commits from all branches for current git user.
function my-commits-since() {
git log --all --author=$(git config user.email) --since=$@
}
# show commits from yesterday.
# if none were found, assume it's Monday and show commits from Friday.
function standup() {
if [ -z "$(my-commits-since yesterday)" ]; then
my-commits-since last.friday.midnight $@;
View show_all_commands.md

set -x shows all commands in bash as they are run. to stop showing commands, reload the shell e.g. exec $SHELL

set -x && echo "hi"
exec $SHELL

# # output (stdout)
# + echo hi
# hi
View docker_commands.md

Commands

# start container, attach stdin, use psuedo tty, use host network
docker run -it --network=host ubuntu:16.04  

# Delete all containers
docker rm $(docker ps -aq)  
# Delete all images  
docker rmi $(docker images -q)  
@ConorSheehan1
ConorSheehan1 / .rubocop.yml
Last active Mar 11, 2019
My personal preference for ruby style
View .rubocop.yml
# add indent after access modifier e.g. private
Layout/IndentationConsistency:
EnforcedStyle: rails
# Use double quotes by default, common in large projects including rails
# https://anti-pattern.com/always-use-double-quoted-strings-in-ruby
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
@ConorSheehan1
ConorSheehan1 / sublime_ruby_regexps.md
Last active Mar 29, 2019
regular expressions for updating ruby syntax (tested using sublime-text-3 replace function)
View sublime_ruby_regexps.md
@ConorSheehan1
ConorSheehan1 / pre-commit
Last active Apr 25, 2018
before commit, check if puppet files have valid syntax
View pre-commit
#!/bin/sh
# this hook aborts commits which contain invalid puppet syntax
errors=0
# get all files in commit, use awk to get file name only, use grep to get puppet files only
files=$(git diff --cached --name-status | awk '$1 != "D" { print $2 }' | grep "\.pp")
# if you are committing .pp files
if [[ "$files" ]]; then
@ConorSheehan1
ConorSheehan1 / commit-msg
Last active Apr 25, 2018
check commit message contains link to trello card
View commit-msg
#!/usr/bin/env bash
# this hook aborts commits which do not include a link to trello
INPUT_FILE=$1
START_LINE=`head -n1 $INPUT_FILE`
PATTERN="https:\/\/trello\.com\/"
if ! [[ "$START_LINE" =~ $PATTERN ]]; then
echo "Commit messages should include a link to the related trello card."
echo "To override this check add the --no-verify flag "
exit 1
You can’t perform that action at this time.