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 / data-tech-blog-club-faq.md
Last active Jan 14, 2020
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 Jan 24, 2018
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 Nov 23, 2015
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 Nov 20, 2015
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 Nov 7, 2015
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 Aug 29, 2015
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
@bgreenlee
bgreenlee / flashScreen.swift
Created Apr 1, 2015
Flashing the screen in Swift. Sticking this here because it took me a while to work out the right variable types and casting.
View flashScreen.swift
func flashScreen() {
let inDuration: CGDisplayFadeInterval = 0.5
let outDuration: CGDisplayFadeInterval = 0.5
let color = NSColor.redColor()
var fadeToken: CGDisplayFadeReservationToken = 0
let colorToUse = color.colorUsingColorSpaceName(NSCalibratedRGBColorSpace)!
let err = CGAcquireDisplayFadeReservation(inDuration + outDuration, &fadeToken)
if Int(err) != Int(kCGErrorSuccess.value) {
NSLog("Error acquiring fade reservation")