Skip to content

Instantly share code, notes, and snippets.

View bgreenlee's full-sized avatar

Brad Greenlee bgreenlee

View GitHub Profile
@bgreenlee
bgreenlee / wallpaper.sh
Last active November 4, 2024 20:50
Getting the name of the current Mac Aerial screensaver/wallpaper
#!/bin/bash
# Print the name of the current Mac Aerial screensaver/wallpaper
# requires jq (brew install jq)
LANG=$(defaults read -g AppleLocale | cut -c1-2) # this is not going to work for all locales
WALLPAPERS="/Library/Application Support/com.apple.idleassetsd/Customer/entries.json"
DESCRIPTIONS="/Library/Application Support/com.apple.idleassetsd/Customer/TVIdleScreenStrings.bundle/$LANG.lproj/Localizable.nocache.strings"
# get the path of the current wallpaper video by looking at the files the WallpaperVideoExtension process has open
@bgreenlee
bgreenlee / gbd.sh
Last active August 8, 2023 16:49
Interactive git branch deletion with fzf
# gbd - interactive git branch deletion
# based off https://www.peterp.me/articles/cli-tips-interactive-branch-delete/
# use tab to select multiple
# Drop this in your .bashrc or .zshrc (assumes fzf is installed)
gbd() {
local branches branch
branches=$(git for-each-ref --sort=-committerdate refs/heads/ --format="[%(committerdate:short)] %(color:bold green)%(refname:short)%(color:reset) - %(contents:subject)" --color=always | egrep -v main) &&
branch=$(echo "$branches" | fzf --multi --ansi --preview 'git show {2}' ) &&
git branch -D $(echo "$branch" | awk '{print $2}')
}
@bgreenlee
bgreenlee / wordle.py
Last active February 7, 2022 21:24
Wordle "Solver"
#!/usr/bin/env python3
from datetime import datetime
import urllib.request
import re
# grab the word list
words_url = 'https://www.powerlanguage.co.uk/wordle/main.c1506a22.js'
req = urllib.request.Request(words_url, data=None,
headers={
'User-Agent': 'Wordle "Solver" 1.0'
@bgreenlee
bgreenlee / data-tech-blog-club-faq.md
Last active January 14, 2020 22:29
Data Tech Blog Club FAQ

Data Tech Blog Club FAQ

What is Data Tech Blog Club?

Blog Club is a weekly meeting where we discuss an article or short paper on a topic at least vaguely adjacent to our work.

Can I Come to Blog Club?

Yes! The more the merrier! You don't have to be in the Data Tech org. Meetings are Monday at 11:30a Eastern in A-511. Hit up @brad to get an invite.

Do I Have to Read the Article?

Well, no, but you'll get more out of it if you do. The articles we pick usually don't require more than fifteen minutes or so to read. You can do it! But, if you totally spaced and it's five minutes before the meeting and what was the article anyway...no worries, come anyway. Someone will give a summary and we always end up having an interesting discussion.

<?php
if (strpos(`uname`, 'Darwin') === false) {
fwrite(STDERR, "This only works on macOS, sorry.\n");
exit(1);
}
$voices = array_map(
function($voice) {
return (explode(' ', $voice))[0];
@bgreenlee
bgreenlee / rescuewindows.lua
Created January 24, 2018 04:46
Hammerspoon function to move off-screen windows onto the main screen
-- Rescue Windows
-- Move any windows that are off-screen onto the main screen
function rescueWindows()
local screen = hs.screen.mainScreen()
local screenFrame = screen:fullFrame()
local wins = hs.window.visibleWindows()
for i,win in ipairs(wins) do
local frame = win:frame()
if not frame:inside(screenFrame) then
win:moveToScreen(screen, true, true)
import Cocoa
class Document: NSDocument {
@IBOutlet weak var textField: NSTextField!
var content = ""
override init() {
super.init()
{ "keys": ["super+f4"], "command": "public_gist_from_selection" }
@bgreenlee
bgreenlee / UIImage+Resize.swift
Created November 23, 2015 05:24
Swift port of UIImage+Resize, UIImage+Alpha, and UIImage+RoundedCorner, from http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
//
// UIImage+Resize.swift
// Port of UIImage+Resize.m
// from http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
//
import Foundation
import UIKit
extension UIImage {
@bgreenlee
bgreenlee / rdio-music-to-code-by-csv
Created November 20, 2015 16:57
Music to Code By Playlist
Yppah,Blue Schwinn
Yppah,D. Song
Yppah,R. Mullen
Yppah,Film Burn
Yppah,Never Mess With Sunday
Yppah,Happy to See You
Yppah,Soon Enough
Yppah,Paper Knife
Yppah,Golden Braid
Yppah,Three Portraits