Skip to content

Instantly share code, notes, and snippets.

Avatar

James F McMahon JamesMcMahon

  • VMWare
  • Chicago, IL
View GitHub Profile
@JamesMcMahon
JamesMcMahon / root-crontab
Created Feb 24, 2021
Pihole Autoupdate Cron
View root-crontab
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
@JamesMcMahon
JamesMcMahon / rsync-backup.sh
Last active Nov 1, 2021
Remote backup Rsync
View rsync-backup.sh
#!/usr/bin/env bash
set -e
log_file=$1
local_path=$2
remote_path=$3
time rsync --archive --verbose --new-compress --human-readable --protect-args --progress --exclude=.DS_Store --log-file=rsync_${log_file}.log ${local_path} ${remote_path}
time rsync --checksum --archive --verbose --new-compress --human-readable --protect-args --progress --exclude=.DS_Store --log-file=rsync_${log_file}_checksum-verify.log ${local_path} ${remote_path}
@JamesMcMahon
JamesMcMahon / comparedirs.py
Created Feb 3, 2020
Compare directories script I created for my NAS
View comparedirs.py
#!/usr/bin/env python
import os
import sys
def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text
@JamesMcMahon
JamesMcMahon / toolbox-fix.sh
Last active Jul 20, 2019
Fix issue with Jetbrains Toolbox apps
View toolbox-fix.sh
xattr -cr Applications/JetBrains\ Toolbox/
View tracker-script.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'tracker_api'
require 'date'
require 'descriptive_statistics'
def calc_running_velocity(last_3_iterations)
if last_3_iterations.size != 3
return nil
@JamesMcMahon
JamesMcMahon / exo-repl-notes.md
Created Mar 8, 2019
Exo Encounter REPL in Spacemacs - notes
View exo-repl-notes.md

Some notes on getting this to work via Spacemacs,

You need to add the following

(defun dotspacemacs/user-config ()
  (autoload 'fennel-mode "~/.emacs.d/private/local/fennel-mode/fennel-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.fnl\\'" . fennel-mode))
  )
@JamesMcMahon
JamesMcMahon / comparedirs.py
Created Mar 31, 2018
Script to compare just directory names
View comparedirs.py
#!/usr/bin/env python
import os
import sys
def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text
@JamesMcMahon
JamesMcMahon / brew-deps.sh
Created Sep 10, 2017
Lists brew dependencies
View brew-deps.sh
#!/bin/zsh
brew list | while read cask; do echo -n $fg[blue] $cask $fg[white]; brew deps $cask | awk '{printf(" %s ", $0)}'; echo ""; done
View tracker.highlighter.user.js
// ==UserScript==
// @name Tracker Blocked Highlighter
// @namespace http://tampermonkey.net/
// @version 0.1
// @author jmcmahon
// @match https://www.pivotaltracker.com/*
// @grant none
// ==/UserScript==
(function() {
@JamesMcMahon
JamesMcMahon / sieve_of_eratosthenes.rb
Last active Sep 24, 2016
Sieve of Eratosthenes in Ruby
View sieve_of_eratosthenes.rb
#!/usr/bin/env ruby
def gen_primes(n)
sieve = Array.new(n) { |i| i > 1 }
(0...Math.sqrt(n)).each do |i|
next unless sieve[i]
(i * i...n).step(i) { |j| sieve[j] = false }
end