Skip to content

Instantly share code, notes, and snippets.

View traveaston's full-sized avatar

Trav Easton traveaston

  • Perth, Australia
View GitHub Profile
@traveaston
traveaston / README.md
Last active December 2, 2019 18:11
Reverse the direction of Github compare (bookmarklet)

Create a new bookmark with the following code (Github doesn't allow making a draggable bookmarklet) or paste the IIFE (top of the JS file below) into the console on a Github compare page.

javascript:(function()%7B(()%20%3D%3E%20%7Bconst%20url%20%3D%20document.location.href%3Bconst%20targetBasename%20%3D%20url.split('%2F').slice(-1)%5B0%5D.split('...').reverse().join('...')%3Bconst%20lastSlash%20%3D%20url.lastIndexOf('%2F')%3Bconst%20targetURL%20%3D%20url.substring(0%2C%20lastSlash%20%2B%201)%20%2B%20targetBasename%3Bconsole.log('Reversed%20branch%20compare%20URL.%20Navigating%20to'%2C%20targetURL)%3Bdocument.location.href%20%3D%20targetURL%3B%7D)()%7D)()

I prefer to put the bookmarklet in a folder somewhere, hit ⌘+L, type reverse and tap down to the bookmarklet like so:
https://i.imgur.com/brhwipo.png

@traveaston
traveaston / youtube-playlist-length.js
Created November 7, 2019 21:17
Get the total length or duration of a Youtube playlist
(() => {
const formatTime = (seconds) => {
const units = {
days: Math.floor(seconds / 60 / 60 / 24),
hours: Math.floor(seconds / 60 / 60 % 24),
minutes: Math.floor(seconds / 60 % 60),
seconds: seconds % 60
}
// remove empty units, singularize if necessary, and return a string
@traveaston
traveaston / map_drives.sh
Last active July 24, 2019 17:25
Function for mounting windows network shares on Windows Subsystem for Linux (WSL)
# mounts windows drives for each folder in /srv/ using convention /srv/backups = drive B:
function map_drives() {
local share letter
for share in /srv/*; do
letter="${share:5:1}"
letter="${letter^}:"
# avoid unnecessary remounts
if ! mount | grep -i "$letter on $share" &>/dev/null; then
@traveaston
traveaston / tab.bash
Last active October 14, 2019 07:14 — forked from vitalybe/tab.bash
Open new iTerm tabs via command line
# tab function has been modified to integrate into basherk / bashrc file.
# dependant function/export taken from basherk https://github.com/traveaston/basherk
# assumes cd lists directory or has some other noisy output which we'd like to avoid here
# ignore commands with leading space
export HISTIGNORE=" *:$HISTIGNORE"
# credit: https://stackoverflow.com/a/17841619
# this solution avoids appending/prepending delimiter to final string
function array_join() {

Butter chicken

Ingredients

Purée

  • Onions
    • 60g ghee butter
    • 3-4 large brown onions
  • 2 teaspoons kosher/cooking salt