Skip to content

Instantly share code, notes, and snippets.

@rbreaves
rbreaves / gist:d185c1cd2892561199f5b90e1af5117b
Last active January 12, 2018 20:00
Gmail - Archive > 1 week && Mark As Read > 2 weeks
function markArchivedAsRead() {
var delayDays = 7; // will only impact emails more than 7 days old
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays); // what was the date at that time?
//Look for unread emails that are older than 14 days and exclude starred emails
var threads = GmailApp.search('label:unread older_than:14d -is:starred');
GmailApp.markThreadsRead(threads);
@rbreaves
rbreaves / cfconvention.sh
Last active April 14, 2018 17:55
Fix improper Coldfusion Code Conventions with Perl
#!/bin/sh
# Run script in the root directory of the site
#Fix tag based functions that have eol and tabs in the tag
find . -name '*.cf*' -not -name '*.json' | xargs perl -i -0pe 's/(?:\G|\<cf)(?:(?!\>).)*\K\n\t+/ /g'
#Fix script based functions that also have eol and tabs
find . -name '*.cf*' -not -name '*.json' | xargs perl -i -0pe 's/(?:\G(?!\A)|\tpublic|\tremote|\tprivate)(?:(?!\)).)*?\K\n\t+/ /g'
@rbreaves
rbreaves / relocateUnreadCountGmail.user.js
Created June 15, 2018 04:41
Unread Count on the Left in Gmail
// ==UserScript==
// @name Relocate Unread Count for Gmail
// @namespace http://elomental.com/
// @version 1.0
// @description Relocate the unread count to the left for Gmail labels
// @author Ryan Reaves
// @match https://mail.google.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
@rbreaves
rbreaves / split_audiobook_chapters.py
Last active November 24, 2022 07:17 — forked from szarroug3/split_audiobook_chapters.py
Split audiobook into chapters
#!/usr/bin/env python
"""
Script to split audiobook chapters into separate files using metadata
"""
from __future__ import print_function
import os
import re
@rbreaves
rbreaves / macOS keyboard layout for Linux
Last active March 31, 2024 10:35
Universal macOS keyboard layout for Linux - Applies to All Windows and Apple Keyboards
# permanent apple keyboard keyswap
echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
update-initramfs -u -k all
# Temporary & instant apple keyboard keyswap
echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd
# Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win
@rbreaves
rbreaves / ping-color
Created September 16, 2019 13:53
Ping Latency with Color
# Add to .zshrc or .bashrc
alias pg=pingout
pingout(){
ping 8.8.8.8 | awk -F" |=" '/time/{if($10>0 && $10<=70){printf "\033[1;32m%i\n\033[0m", $10}; if($10>70 && $10<=99){printf "\033[33m%i\n\033[0m", $10};if($10>99){printf "\033[31m%i\n\033[0m", $10 }}'
}
@rbreaves
rbreaves / WaylandUbuntu19.10-AppTitle
Last active October 10, 2024 09:00
Grab wmclass name or Window Name/Title under Wayland with Gnome 3.x
# Single Command, runs 2 calls to gdbus to get the currently active Window from Gnome 3.x
# Escaped so you can copy and paste into terminal directly
gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\)[`gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\).findIndex\(a\=\>a.meta_window.has_focus\(\)===true\) | cut -d"'" -f 2`].get_meta_window\(\).get_wm_class\(\) | cut -d'"' -f 2
# Unescaped version, will not run
# Broken down into 2 commands.
# Call to Gnome to get the array location of the active Application
gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m \
@rbreaves
rbreaves / vmboxkeyswap.py
Last active January 28, 2020 04:00
VirtualBox macOS keyswap for alt and cmd
#!/usr/bin/python
# Fixes the macOS keymap on the host to swap Alt & Cmd
# This allows for proper key location when using Virtual Machines under VirtualBox
# Support for Vmware and Parallels can easily be added via the app names
# Also Virtualbox does not detect the keyswap initially, so another app has to
# steal focus and then return focus to VirtualBox. Unknown if the same applies
# to the other VM solutions.
from AppKit import NSWorkspace
@rbreaves
rbreaves / macosAltCmdSwap.sh
Last active July 27, 2020 08:22
Swap alt and cmd on macOS via Terminal
# Reference
# https://developer.apple.com/library/archive/technotes/tn2450/_index.html
#
# How to swap wordwise shortcuts to align with Windows/Linux
# http://benogle.com/2010/01/18/windowslinux-developers-remap-your-mac.html
# https://theconfused.me/blog/switching-between-mac-and-linux-keyboards/
#
# Swap cmd & alt to Windows/Linux style
# left cmd = e3
# left alt = e2
@rbreaves
rbreaves / hwdb udev keyboard.sh
Last active January 31, 2023 21:02
hwdb udev Keyboard remap
# Original reference https://yulistic.gitlab.io/2017/12/linux-keymapping-with-udev-hwdb/
systemd --version | head -n1 | awk '{print $2}'
# note systemd versions below 220 need
# keyboard:usb:v*p*
# 220 and above
# evdev:name:<name>:*