Skip to content

Instantly share code, notes, and snippets.

@villeodell
villeodell / mac_setup.sh
Last active January 15, 2021 22:33
Install base apps on mac using brew, cask, and mas-cli
# Check/install brew
if test ! $(which brew); then
echo "Installing homebrew"
ruby -e "$(curl -fsSl https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew analytics off
# Update homebrew recipes
brew update
@villeodell
villeodell / ipak.R
Created May 18, 2018 14:32 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
# restart bluetoothd and bluetoothaudiod on macOS
sudo kill -9 `pgrep bluetooth`

Regular Expression Cheatsheet

Anchors

^   Matches at the start of string or start of line if multi-line mode is
	enabled. Many regex implementations have multi-line mode enabled by
	default.

$ Matches at the end of string or end of line if multi-line mode is enabled.
@villeodell
villeodell / userContent.css
Created April 26, 2020 20:25
Firefox new tab light/dark mode
/* create this as /chrome/userContent.css under Firefox Profile directory */
/* Enable Light/Dark Mode New Tab Background Color */
@media (prefers-color-scheme: dark) {
@-moz-document url("about:newtab"), url("about:home") {
body { background-color: #222 !important;}
}
}
@villeodell
villeodell / eventLink.js
Last active April 7, 2022 14:33
Google Workplace (G Suite) bookmarklets
@villeodell
villeodell / typinator-expansion-ms-teams-meeting-options.txt
Created September 16, 2021 22:00
Typinator expansion using perl and regex that prompts for Microsoft Teams join link and outputs a 'Meeting Options' link
{/Perl
use strict;
########
# input a teams join link, extract the important bits, use them to print the meeting options link
# {{?Join Link}} is Typinator code to ask for user input
########
my $str = '{{?Join Link}}';
my $regex = qr/(?i).+19(?::|%3a)(.+(?:@|%40)thread.+)\/(.+)\?context=%7b%22Tid%22%3a%22(.+)%22%2c%22Oid%22%3a%22(.+)%22%7d/mp;
@villeodell
villeodell / readme.md
Last active October 15, 2021 12:45
Restart bluetooth from macOS Dock

Restart Bluetooth from macOS Dock

macOS has an annoying bug where bluetooth periodically stops working. If you're working via a BT keyboard/trackpad you are forced to wait a minute or two until it resolves on it's own.

Alternative (5 seconds): Have a cable at the ready, plugin your trackpad, restart BT via the macOS Dock.

Setup a shortcut to restart Bluetooth from the dock

Install blueutil

@villeodell
villeodell / normalise-loudness.rb
Created December 18, 2021 18:51 — forked from njh/normalise-loudness.rb
Script to normalise a WAV file's loudness to specific LUFS using ffmpeg
#!/usr/bin/env ruby
#
# Script to normalise an audio file's loudness using ffmpeg
#
# Usage: normalise-loudness.rb <input.wav> <output.wav>
#
# License: https://unlicense.org/
#
# Requires the 'json' ruby gem:
#
@villeodell
villeodell / List applications by date last opened.md
Last active April 7, 2022 13:46
macOS command line: list applications by last opened date and output to csv

List macOS applications by date last opened

Make a list of your current applications along with the date you last used them.

  1. Get the relevant metadata attributes for Applications to mimic "Date last opened" in Finder using mdls
  2. Convert plist xml output to json using yq
  3. With jq
    • select just the most recent date if multiple dates
    • sort the results
  • ouput the app name and date to csv