Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Pretty swamped with work-work

Brad Greenlee bgreenlee

💭
Pretty swamped with work-work
View GitHub Profile
@bgreenlee
bgreenlee / wordle.py
Last active February 7, 2022 21:24
Wordle "Solver"
View wordle.py
#!/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
View data-tech-blog-club-faq.md

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.

View cacophony.php
<?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
View rescuewindows.lua
-- 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)
View Document.swift
import Cocoa
class Document: NSDocument {
@IBOutlet weak var textField: NSTextField!
var content = ""
override init() {
super.init()
View Default (OSX).sublime-keymap
{ "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/
View UIImage+Resize.swift
//
// 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
View rdio-music-to-code-by-csv
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
@bgreenlee
bgreenlee / WiFiInfo.swift
Created November 7, 2015 23:05
Swift Class to encapsulate wifi network info
View WiFiInfo.swift
//
// WiFiInfo.swift
//
// Created by Brad Greenlee on 11/7/15.
//
import Foundation
import CoreWLAN
extension CWPHYMode: CustomStringConvertible {
@bgreenlee
bgreenlee / random_gif.sh
Last active August 29, 2015 14:27
Post a random gif (with random icon) to a Slack channel
View random_gif.sh
HOOK_URL=https://hooks.slack.com/services/.../.../...
curl -X POST --data-urlencode "payload={\"channel\": \"#random\", \"username\": \"randombot\", \"text\": \"$(curl -s 'http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC' | sed -nE 's/^.*image_original_url":"([^"]+)".*$/\1/gp' | sed 's/\\//g')\", \"icon_emoji\": \":$(curl -s http://www.emoji-cheat-sheet.com/ | sed -n -E 's/^.*<span class="name".*>(.*)<\/span>.*$/\1/gp' | perl -MList::Util -e 'print List::Util::shuffle <>' | head -1):\"}" $HOOK_URL