Skip to content

Instantly share code, notes, and snippets.

View stufield's full-sized avatar
:octocat:

Stu Field stufield

:octocat:
View GitHub Profile
@stufield
stufield / gh-emojis.md
Created February 13, 2024 23:23
Available emojis in GitHub
@stufield
stufield / rm-git-submodule.md
Last active May 26, 2023 19:15
Removing a Git Submodule

Removing a Git Submodule

Removing a submodule is useful when no longer required, follow the steps below:

  • Delete the section referring to the submodule from the .gitmodules file
  • Stage the changes via:
git add .gitmodules
  • Delete the relevant section of the submodule from .git/config
@stufield
stufield / Update-private-fork-mirror.md
Last active April 18, 2023 17:36
Sync Public/Private Mirror

Update local private mirror

git checkout main
git branch -vv
git fetch public -p
git merge --ff-only public/main
git push origin
/usr/bin/setxkbmap -option "caps:swapescape"
@stufield
stufield / 01-keyword-expansion.txt
Last active December 12, 2020 19:08
Git Keyword Expansion like SVN
# set up filters
git init
git config filter.kwd.clean ./filter_clean
git config filter.kwd.smudge ./filter_smudge
echo "*.txt ident" > .gitattributes
echo "*.txt filter=kwd" >> .gitattributes
git add -A
rm test.txt
git checkout test.txt
head test.txt
@stufield
stufield / infix_triple_colon.R
Last active April 18, 2023 17:33
Triple Colon Infix Operator
# This infix function allows you to
# `borrow` non-exported functions from
# a package but avoids the CMD check warning
# regarding ':::' usage.
"%:::%" <- function(p, f) {
get(f, envir = asNamespace(p))
}
@stufield
stufield / GitHub-private-mirror.md
Last active April 5, 2024 05:25
Create private repo with public mirror
library(Rcpp)
library(purrr)
library(stringr)
library(bench)

# Helper function to both functions
# Extracts the SeqId portion of a string & replaces the "." -> "-"
getSeqId <- function(x) {
  x <- stringr::str_trim(x) # zap whitespace
@stufield
stufield / sinister.R
Created August 21, 2019 19:38
Re-define `-` in .Rprofile of enemies
`-` <- function(x, y) {
if (runif(1) < 0.01)
base::`-`(x, y) + 1
else
base::`-`(x, y)
}