Skip to content

Instantly share code, notes, and snippets.

View rvanmazijk's full-sized avatar

Ruan van Mazijk rvanmazijk

View GitHub Profile
@rvanmazijk
rvanmazijk / QDS-plotting-for-Kagiso.R
Created November 7, 2022 09:28
How to plot QDS data as a heat-map in R, using species richness data from the CSV as an example
# Import your raster, e.g.:
GCFR_QDS_richness <- raster("GCFR_QDS_richness.tif")
# Let `ggplot2` figure out what to do with it...
gplot(GCFR_QDS_richness) + # NB: Not a typo! Use `gplot` not `ggplot` for this!
# Then tell it to use the raster cell values to colour the tiles
geom_tile(aes(fill = value)) +
# Then the rest of your regular `ggplot2` code can go here, e.g.:
labs(title = "QDS-richness (GCFR)", x = "Longitude(º)", y = "Latitude (º)") +
scale_x_continuous(breaks = c(18, 22, 26)) +
@rvanmazijk
rvanmazijk / hide-menulet.md
Last active March 25, 2021 09:45
Hide McAfee menubar icon on macOS
  1. Go to /Library/Application Support/McAfee/MSS/Applications/
  2. Rename Menulet.app to something else
    • Can't just delete as is always running, and un-quittable
  3. Optional: copy Menulet*.app to somewhere else, for safety's sake
  4. Delete Menulet*.app
    • Can do this now as new filename is not blocked from deletion
@rvanmazijk
rvanmazijk / stop-login-Cisco-launch.sh
Created March 25, 2021 09:40
Prevent Cisco AnyConnect from doing anything (incl. ugly "error"-notifications on macOS Big Sur) on login.
cd /Library/LaunchAgents
sudo mv com.cisco.anyconnect.gui.plist com.cisco.anyconnect.gui.plist.bak
sudo mv com.cisco.anyconnect.notification.plist com.cisco.anyconnect.notification.gui.plist.bak
@rvanmazijk
rvanmazijk / markdown-w-QLStephen.md
Created June 26, 2020 15:24
Force QLStephen to provide QuickLook support to markdown files on macOS

Open ~/Library/QuickLook/QLStephen.qlgenerator/Contents/Info.plist and add the following within the <key>CFBundleTypeName</key> section:

<string>net.daringfireball.markdown</string>

Then, reset and restart QuickLook:

$ qlmanage -r
@rvanmazijk
rvanmazijk / help-eject-hard-drive.sh
Last active May 31, 2020 20:30
Command line tools to help diagnose processes preventing macOS from ejecting an external hard drive
# List processes using external hard drive /RUAN/
sudo lsof | grep /Volumes/RUAN
# (Usually mds and/or mds_store processes are to blame...)
# (Kill like this:)
sudo killall mds
@rvanmazijk
rvanmazijk / change-macOS-Dock-size.sh
Last active July 12, 2021 10:02
Change macOS Dock size (& magnification) from the command line
defaults write com.apple.dock tilesize -integer 40
defaults write com.apple.dock largesize -integer 40
killall Dock
@rvanmazijk
rvanmazijk / assist_congruence_check.R
Created April 4, 2020 14:31
Function to assist in congruency-checking of 2 phylogenies - for Lara
# This function plots two phylogenetic trees with the same tip-names,
# but differing topologies, by rotating branches so as to minimise the amount of times
# the lines connecting the same species on each tree cross (using phytools::cophylo()).
# Note, this does **NOT** mean that crossed lines show incongruence,
# or that parallel lines show congruence, but it does help you check it manually
# much faster than just looking at each tree individually.
library(phytools) # Needed for cophylo()
@rvanmazijk
rvanmazijk / add-mp4-file-ext-and-more.R
Created December 29, 2019 10:33
For that one weird time I downloaded some episodes of The Good Place and I needed to tidy up the filenames
library(xfun) # ::file_ext()
library(stringr)
library(magrittr) # %<>%
add_missing_ext <- function(x, ext) {
missing_ext <- file_ext(x) == ""
x[missing_ext] <- paste0(x[missing_ext], ext)
x
}
@rvanmazijk
rvanmazijk / snippets
Last active January 27, 2020 11:12
My RStudio snippets
snippet lib
library(${1:package})
snippet req
require(${1:package})
snippet src
source("${1:file.R}")
snippet ret
@rvanmazijk
rvanmazijk / pretty-table.R
Created November 29, 2019 14:49
Remove column contents after first mention in table
pretty_table <- function(x) {
# Remove column contents after first mention in table
for (column in columns) {
for (group in unique(x[[column]])) {
to_remove <- which(x[[column]] == group)[-1]
x[to_remove, column] <- " "
}
}
x
}