Skip to content

Instantly share code, notes, and snippets.

View pdarragh's full-sized avatar

Pierce Darragh pdarragh

View GitHub Profile
@pdarragh
pdarragh / Example usage
Created April 28, 2020 03:18
A simple script to extract colors from iTerm color profiles as hexadecimal values.
$ ./iterm2hex.py "Solarized Dark Higher Contrast.itermcolors"
#002731 // Ansi 0 Color
#D01B24 // Ansi 1 Color
#50EE84 // Ansi 10 Color
#B17E28 // Ansi 11 Color
#178DC7 // Ansi 12 Color
#E14D8E // Ansi 13 Color
#00B29E // Ansi 14 Color
#FCF4DC // Ansi 15 Color
#6BBE6C // Ansi 2 Color
#!/usr/bin/env python3.6
import random
from abc import ABC, abstractmethod
from copy import copy
from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Tuple, Type
CROSS_VALIDATION_TRAINING_EPOCHS = 10
@pdarragh
pdarragh / get_serial.py
Last active December 3, 2024 08:57
Short PyObjC script to get a Mac's serial number without calling `system_profiler`.
#!/usr/bin/python
# (Note that we must use system Python on a Mac.)
####
# Quick script to get the computer's serial number.
#
# Written for @john.e.lamb on the MacAdmins Slack team.
import objc
import CoreFoundation
@pdarragh
pdarragh / Jekyll Static Highlighting Navigation Menu.md
Last active November 24, 2024 21:49
Jekyll navigation bar with automatic highlighting.

Jekyll NavBar

In building a site powered by Jekyll and hosted by GitHub, I wanted the ability to highlight the current page's tab in the bar. I also wanted the bar to support second-level items (i.e. a dropdown), which proved somewhat tricky. This is the solution I arrived at after a few hours of fiddling around.

Construction

The contents of the navigation bar are contained in a data file located at _data/navigation.yml. This makes it accessible via the site-wide Liquid element {{ site.data.navigation}}. You can see the file for the formatting I used.

How it Works

@pdarragh
pdarragh / Instructions.txt
Last active August 29, 2015 14:07
Install Python3 and Pygame via Homebrew on OS X
####
## I do not guarantee that this works. Use at your own risk.
## I am *fairly* certain that these are all the steps I took to get Python3 and Pygame
## installed on OS X, but I may be forgetting something.
####
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor