Skip to content

Instantly share code, notes, and snippets.

View nathanburgess's full-sized avatar
🍕
Beep boop

Nathan Burgess nathanburgess

🍕
Beep boop
View GitHub Profile
@nathanburgess
nathanburgess / gitconfig
Created February 23, 2022 15:41
My git configuration
[pull]
rebase = true
[user]
name = full_name
email = email
signingkey = GPG_SIGNING_KEY
[core]
editor = vim
autocrlf = input
[commit]
@nathanburgess
nathanburgess / dev-setup.md
Last active July 14, 2022 17:35
Everything I install when setting up a new machine for development

Before installing

touch ~/.aliases
mkdir ~/.nvm

Software

  • Warp - terminal replacement
  • homebrew - package manager
  • brew install zsh nvm yarn zoxide ripgrep jq git-delta
@nathanburgess
nathanburgess / prezto-setup.md
Last active July 14, 2022 17:36
Prezto prompt configuration

.zshrc

# Load aliases
if [[ -s "${ZDOTDIR:-$HOME}/.aliases" ]]; then
  source "${ZDOTDIR:-$HOME}/.aliases"
fi

# Set up Prezto's prompt
autoload -Uz promptinit
promptinit
@nathanburgess
nathanburgess / kata_22MAR19.rb
Created March 22, 2019 16:48
Take a formatted race results string and output the spread, mean, and median of the results.
#
# Calculate the median value of a list
def median(list)
sorted = list.sort
length = list.length
(sorted[(length - 1) / 2] + sorted[length / 2]) / 2
end
#
# Get the spread, mean, and median from a list of race results
@nathanburgess
nathanburgess / phpcs-runner.sh
Created March 18, 2019 19:41
Run phpcs against all staged PHP files with PSR2 standards. Optionally, pass "fix" to also run phpcbf.
#!/bin/sh
PROJECT=`cd $PWD && git rev-parse --show-toplevel`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
SFILES=${SFILES:-$STAGED_FILES_CMD}
echo "Checking PHP Lint..."
for FILE in $SFILES
do
php -l -d display_errors=0 $PROJECT/$FILE
@nathanburgess
nathanburgess / kata_15JAN2019.rb
Created February 15, 2019 17:28
Print the power set for a given list
def powerset(set)
0.upto(set.size) do |a|
set.combination(a) do |v|
print(v, "\n")
end
end
end
powerset([1, 2, 2])
@nathanburgess
nathanburgess / kata_25JAN2019.rb
Created January 23, 2019 22:02
Given an array containing stock prices at each time interval during a given day, return the times to buy and sell resulting in the maximum amount of profit.
def calc_time(arr)
mm = arr.each_with_index.minmax
"#{arr} :: Buy at t=#{mm[0][1]} and sell at t=#{mm[1][1]}"
end
puts(calc_time([3, 1, 7, 10, 5]))
puts(calc_time([1, 2, 1, 3, 5, 6, 4]))
@nathanburgess
nathanburgess / kata_11JAN2019.rb
Created January 7, 2019 23:27
Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. Given a flowerbed (represented as an array containing 0 and 1, where 0 means empty and 1 means not empty), and a number n, return if n new flowers can b…
def get_prev_next(bed, index)
length = bed.count - 1
prv = nxt = 1
prv = bed[index - 1] if index > 0
nxt = bed[index + 1] if index < length
nxt = 0 if index == length
[prv, nxt]
end
def plant_flower(bed)
@nathanburgess
nathanburgess / kata_14DEC2018
Created December 14, 2018 18:38
String mix
# StringMix class
class StringMix
def mix(str1, str2)
setup(str1, str2)
@unique_chars.each do |char|
count1, count2 = count_occurrences(char)
next if count1 < 2 && count2 < 2
@output << make_fragment(count1, count2, char)
end
class FindMin
@@min_diff = Float::INFINITY
@@index = -1
# Find the minimum value from a set of data given 2 columns
#
# @param [Object] data - The data to use
# @param [Integer] col1 - The first column to compare
# @param [Integer] col2 - The second column to compare
#