Skip to content

Instantly share code, notes, and snippets.

Keith Baker keif

Block or report user

Report or block keif

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@keif
keif / prepare-commit-msg
Created Apr 19, 2019
prepare-commit-msg git hook to automatically prepend on to the commit message.
View prepare-commit-msg
#!/bin/bash
# Include any branches for which you wish to disable this script
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
# Get the current branch name and check if it is excluded
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@keif
keif / .gitconfig
Created Apr 19, 2019
Most recent incarnation of gitconfig 2019/04
View .gitconfig
[core]
autocrlf = input
excludesfile = /Users/ktbaker/.gitignore_global
[pull]
rebase = true
[push]
default = simple
[alias]
# log outputs
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --date=short
@keif
keif / git_merge_check.sh
Last active Mar 25, 2019
This utilizes an external text file (branches.txt) and runs a test against the branches to see if there is a merge conflict.
View git_merge_check.sh
#!/bin/bash
function git_merge_test() {
echo "test git branch merges";
RUN_UNIT_TESTS=0
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "test the branches in branches.txt for merge conflicts"
@keif
keif / gist:d62ccd60ebbdd79eb8ee7f800443a58e
Created Dec 26, 2018
https://projecteuler.net/problem=3The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143?
View gist:d62ccd60ebbdd79eb8ee7f800443a58e
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?
View project_euler_example_3.js
function isPrime(number) {
var index;
var limit = Math.ceil(Math.sqrt(number));
// since the main loop generates odd numbers only
// we can start testing primality dividing by 3
for (index = 3; index <= limit; index += 2) {
if (number % index === 0) {
return false;
}
}
@keif
keif / gist:296114e786f795a24ad70a3c3c5a3880
Created Apr 23, 2018
Better property detection using underscore
View gist:296114e786f795a24ad70a3c3c5a3880
// _.propertyOf along with any other underscore (i.e. _.isObject) to check if something was available instead of
// doing an undefined and null check.
_.isObject(_.propertyOf(data.prop)("prop"));
// _.propertyOf returns a function so you can also assign that to a variable and then use it later as well
var dataPropOf = _.propertyOf(data.prop);
_.isObject(dataPropOf("prop"));
// The exact same technique can be used if the property was an array:
@keif
keif / prepare-commit-msg
Last active Feb 5, 2018
This will automatically prepend your branch name to your commit.
View prepare-commit-msg
#!/bin/bash
# Include any branches for which you wish to disable this script
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
# Get the current branch name and check if it is excluded
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@keif
keif / prepare-commit-msg
Created Jan 30, 2018
This will automatically prepend your branch name to your commit.
View prepare-commit-msg
#!/bin/bash
# Include any branches for which you wish to disable this script
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
# Get the current branch name and check if it is excluded
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@keif
keif / breadth-first-search.js
Created Apr 29, 2016
JavaScript based Breadth-First Search
View breadth-first-search.js
/* A Queue object for queue-like functionality over JavaScript arrays. */
var Queue = function() {
this.items = [];
};
Queue.prototype.enqueue = function(obj) {
console.log("enqueue: ", obj);
this.items.push(obj);
};
Queue.prototype.dequeue = function() {
return this.items.shift();
View .bash_profile
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh # This loads NVM
You can’t perform that action at this time.