Skip to content

Instantly share code, notes, and snippets.

View jmbrunskill's full-sized avatar

James Brunskill jmbrunskill

View GitHub Profile
@jmbrunskill
jmbrunskill / inline_replace.sh
Created May 17, 2024 00:31
Multi Search and Replace
#!/bin/bash
echo "Updating Files"
FILE_LIST=`find . -type f | grep -E "\.(rs|ts|tsx)$" | grep -v node_modules | grep -v target`
REPLACEMENTS_LIST=("s/Equipment/AssetItem/g s/equipment/asset_item/g" )
echo "Replacing:"
for REPLACEMENT in ${REPLACEMENTS_LIST[@]}
do
echo $REPLACEMENT
done
@jmbrunskill
jmbrunskill / clean_all_cargo.rs
Created May 17, 2024 00:30
Clean out all your cargo/rust directories
# Find all cargo.toml in folders linked from current directory and run cargo clean in each one directories
find . -name Cargo.toml -execdir cargo clean \;
@jmbrunskill
jmbrunskill / inplace_replace.sh
Created June 9, 2022 04:49
Bash Script to Search and Replace across Multiple files
#!/bin/bash
echo "Updating Files"
FILE_LIST=`find . -type f | grep -E "\.(rs|ts|tsx)$"` #Choose your prefered file types here
REPLACEMENTS_LIST=("s/Example/TitlecaseReplacement/g" "s/example/snake_case_relacement/g") #Add more replacements here as desire
echo "Replacing:"
for REPLACEMENT in ${REPLACEMENTS_LIST[@]}
do
echo $REPLACEMENT
done
@jmbrunskill
jmbrunskill / main.go
Last active November 26, 2020 11:11
Solution to Matt Parkers Math Puzzles # 19 using Go- http://www.think-maths.co.uk/19challenge
package main
//Matt Parkers Math Puzzles number 19
//Find an integer N for which the the sum of the squares of the first N primes is divisible by N and N is greater than 19
func main() {
//Shamelessly use a precalculated list of 38 primes
primes := [38]int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163}
sumOfSquares := 0
@jmbrunskill
jmbrunskill / git_auto_commit
Created March 18, 2017 09:59
Automatically Check in and push Changes to GIT - assumes already on the right branch and keys are setup to allow push
#!/bin/bash
cd $GIT_REPO
if [[ `git status --porcelain` ]]
then
# changes
git add .
git commit -m "Auto Git Commit for `date`"
git push origin master
fi