Skip to content

Instantly share code, notes, and snippets.

View lgw4's full-sized avatar

Chip Warden lgw4

View GitHub Profile
@timothyham
timothyham / ipv6guide.md
Last active July 19, 2024 01:14
A Short IPv6 Guide for Home IPv4 Admins

A Short IPv6 Guide for Home IPv4 Admins

This guide is for homelab admins who understand IPv4s well but find setting up IPv6 hard or annoying because things work differently. In some ways, managing an IPv6 network can be simpler than IPv4, one just needs to learn some new concepts and discard some old ones.

Let’s begin.

First of all, there are some concepts that one must unlearn from ipv4:

Concept 1

@jonico
jonico / count-committers-on-ghes.sh
Last active April 16, 2024 19:20
Count all unique committers in the last 90 days on GitHub Enterprise Server
ghe-console -y <<'ENDSCRIPT'
ActiveRecord::Base.connected_to(role: :reading) do
puts "Version 0.2.0"
emails = Set.new
start_time = 90.days.ago.beginning_of_day
Repository.where(active: true).find_each do |repo|
Push
.where(repository: repo)
.where("created_at >= ?", start_time)
.find_each do |push|
@zish
zish / terraform_bash_completion.sh
Last active May 31, 2024 13:20
Better Terraform Bash Completion
# Bash Terraform completion
#
# Originally adapted from
# https://gist.github.com/cornfeedhobo/8bc08747ec3add1fc5adb2edb7cd68d3
#
# Author: Jeremy Melanson
#
# Features of this version:
# - Uses built-in bash routines for text processing, instead of external tools
# (awk, sed, grep, ...).
@lgw4
lgw4 / apt-packages-list
Last active August 29, 2015 14:01
Wrapper script for getting a package list on a Debian-based Linux system
#!/usr/bin/env sh
dpkg --get-selections | sort

When I need to remember the spelling for a list comprehension with more than one loop in Python, I find the following mnemonic helpful:

write the for statements in the same order you would write a nested loop

For example, suppose we have a nested list that we wish to flatten:

>>> nested_list = [[1, 2, '5!'], (3, 'sir!')]
@lgw4
lgw4 / retina_13_rotate_resolution.scpt
Last active September 2, 2015 21:08
Rotate resolution between 1280 x 800, 1440 x 900, and 1680 x 1050 on MacBook Pro 13" Retina, Yosemite version
-- Rotate Resolution (between 1280 x 800, 1440 x 900, and 1680 x 1050)
-- MacBook Pro 13" Retina, Yosemite version
tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
click radio button "Display" of tab group 1
click radio button "Scaled" of radio group 1 of tab group 1
tell radio group 1 of group 2 of tab group 1
@lgw4
lgw4 / retina_13_most_space.scpt
Last active September 2, 2015 20:43
Most Space resolution (1680 x 1050) on MacBook Pro 13", Yosemite version
-- Most Space Resolution (1680 x 1050)
-- MacBook Pro 13" Retina, Yosemite version
tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
click radio button "Display" of tab group 1
click radio button "Scaled" of radio group 1 of tab group 1
click radio button 4 of radio group 1 of group 2 of tab group 1
@lgw4
lgw4 / retina_13_more_space.scpt
Last active September 2, 2015 21:03
More Space (1440 x 900) resolution for MacBook Pro 13" Retina, Yosemite version
-- More Space resoltuion (1440 x 900)
-- MacBook Pro 13" Retina, Yosemite version
tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
click radio button "Display" of tab group 1
click radio button "Scaled" of radio group 1 of tab group 1
click radio button 3 of radio group 1 of group 2 of tab group 1
@lgw4
lgw4 / a_better_finder_hide_command.scpt
Created March 21, 2014 04:18
A Better Finder Hide Command
tell application "System Events"
set frontProcess to first process whose frontmost is true
-- When it's down to just Finder and the front process, we have to switch
-- to the Finder first to get the front process to hide itself. Furthermore,
-- the Finder will not be listed as among the visible processes unless it
-- has open windows, so treat a condition of 2 *or fewer* visible apps as
-- meaning the Finder should be activated before hiding the front process.
@lgw4
lgw4 / vacuum_apple_mail_envelope_index.scpt
Last active October 23, 2019 10:25
Vacuum Apple Mail Envelope Index
(*
Speed up Mail.app by vacuuming the Envelope Index
Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/
Originally by "pmbuko" with modifications by Romulo
Updated by Brett Terpstra 2012
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compability
*)
tell application "Mail" to quit
set os_version to do shell script "sw_vers -productVersion"