Skip to content

Instantly share code, notes, and snippets.

@kohendrix
kohendrix / logrotate.conf
Created April 3, 2020 00:21
logrotate template
$PATH_TO_LOGFILE {
missingok
maxsize 2K
rotate 1
dateext
dateformat _%Y%m%d
compress
daily
}
@kohendrix
kohendrix / set_git_user.sh
Last active April 25, 2023 00:53
git user config setting helper
#!/bin/bash
# requires jq installed
# check if it's a git directory
if ! [ -d .git ]
then
echo "This is not a git directory."
exit 1
fi
@kohendrix
kohendrix / git_users.json
Last active April 22, 2023 14:35
used by set_git_user.sh
{
"work": {
"name": "Workie",
"email": "workie@email.com"
},
"personal": {
"name": "Funnie",
"email": "funnie@email.com"
}
}
@kohendrix
kohendrix / .nvm_setup
Last active December 31, 2019 09:07
basic setup for nvm (0.35.0)
# basic default setup
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# use nvm if the directory has .nvmrc
if [ -f .nvmrc ]
then
nvm use
fi
@kohendrix
kohendrix / initialize-vscode-workspace.sh
Created December 30, 2019 10:00
initialize a VS Code workspace with settings.json
#!/bin/bash
# this is just to create VS Code workspace settings.json
set -e
SETTINGS_FILE=".vscode/settings.json"
load_user_settings_prompt(){
ORIGINAL_FILE=$1
@kohendrix
kohendrix / .git_aliases
Last active December 30, 2019 10:03
git command aliases to be included in .bashrc or profile and such
# git
alias gpull="git pull"
alias gpullr="git pull --rebase"
alias gpush="git push"
alias gpushf="git push --force-with-lease"
alias gcm="git commit -m"
alias gca="git commit --amend"
alias gs="git status"
alias gaa="git add -A"
alias ga="git add"
@kohendrix
kohendrix / clean_branches.sh
Created December 20, 2019 10:09
Cleaning up git branches that are deleted on the remote, or not ever pushed to the remote.
#!/bin/bash
set -e
# functions ->
prune_prompt(){
echo "Prunable Branches ======="
PRUNABLES=`git remote prune origin --dry-run | grep 'origin/.*' | awk '{ print $4 }'`
if [ -z "$PRUNABLES" ]
@kohendrix
kohendrix / userUsecase.js
Last active May 21, 2019 02:57
just a simple usecase
const repo = require('./userRepository');
exports.greet = function() {
const user = repo.getUser();
return user.greet();
};
@kohendrix
kohendrix / user.js
Created May 21, 2019 02:35
simple model
class User {
constructor(name, email) {
this.name = name;
this.email = email;
}
greet() {
return `Hello, my name is ${this.name}`;
}
}
@kohendrix
kohendrix / userRepository.js
Created May 21, 2019 02:17
require when needed expample
function get() {
// check the db or something
const User = require('./user');
return new User('John', 'johndoe@somemail.com');
}
exports.getUser = get;