Skip to content

Instantly share code, notes, and snippets.

View gfontenot's full-sized avatar
football

Gordon Fontenot gfontenot

football
View GitHub Profile
@gfontenot
gfontenot / post-commit
Created June 23, 2012 01:13
Post commit hook for Day One
#!/bin/sh
#
# Originally by Gordon Fontenot
# gordon.fontenot@me.com
#
# Log all commit messages to Day One
msg=`cat $PWD/.git/COMMIT_EDITMSG`
_pwd=`echo $PWD | sed -e "s/.*\///"`
_commit=`git rev-parse --short HEAD`
@gfontenot
gfontenot / alfred-vim.applescript
Created September 6, 2012 19:21
Alfred plugin for editing the selected item in Vim (using iTerm 2)
on alfred_script(q)
set {the_path, file_name} to parse_path(first item of q)
tell application "iTerm"
set _terminal to make new terminal
tell _terminal
launch session "Vim"
tell the last session
write text "cd \"" & the_path & "\""
# Replace e with your vim command
@gfontenot
gfontenot / gist:1203520
Created September 8, 2011 14:25
Get duration of a video file with Ruby and FFMpeg
def get_movie_duration video_file
# Run ffmpeg on the video, and do it silently
ffmpeg_output = `/usr/local/bin/ffmpeg -i "#{video_file}" 2>&1`
# Find the duration in the output, and force a return if it's found
/duration: ([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{2})/i.match(ffmpeg_output) { |m| return m[1] }
# If it didn't get a match, something is wrong. Log the error
return "FFMPEG ERROR"
@gfontenot
gfontenot / WeView.swift
Last active April 17, 2020 01:12
Demonstration of weird WKWebView behavior when paired with SwiftUI
import SwiftUI
struct ContentView: View {
@State var showModal: Bool = false
var body: some View {
NavigationView {
VStack {
WebView(url: URL(string: "https://www.example.com")!)
Button("Fixme") { self.showModal = true }
@gfontenot
gfontenot / Sample.swift
Created February 15, 2020 17:28
Swift UI sample of layout bug
import SwiftUI
struct Sample: View {
var body: some View {
NavigationView {
WebView(url: URL(string: "https://example.com")!)
.navigationBarItems(
trailing: Button(
action: { },
label: { Text("Done") }
@gfontenot
gfontenot / ElmSpike.swift
Created August 3, 2018 17:27
Quick spike on an elm-ish architecture in Swift
// Dumb value types representing UIViews. Comperable to our current models like Button.Model
struct StackView<Message> {
let children: [View<Message>]
}
struct Label {
let text: String
}
func assert(_ cond: @autoclosure () -> Bool) -> String {
if cond() {
return "✅"
} else {
return "❌"
}
}
#if !swift(>=4.2)
protocol KnownEnum: RawRepresentable, Hashable where RawValue == String {
@gfontenot
gfontenot / goroutines.swift
Created February 16, 2018 15:02 — forked from chriseidhof/goroutines.swift
goroutines.swift
import Foundation
enum Message<T> {
case value(T)
case finished
}
protocol Channel: IteratorProtocol {
func send(_ value: Message<Element>)
}
@gfontenot
gfontenot / Open Page In Chrome.scpt
Created March 14, 2011 16:52
Open the current Safari page in Google Chrome
tell application "Safari"
set the_url to URL of front document
end tell
tell application "Google Chrome"
try
set win to first window
on error
set win to make new window
end try
@gfontenot
gfontenot / oopsiefocus.scpt
Created June 28, 2011 14:16
Modified version of Shawn Blanc's OopsieFocus script
(*
OopsieFocus
A script to launch OmniFocus and activate the Quick Entry Panel
By Shawn Blanc (http://shawnblanc.net)
May 20, 2011
With code used from the Toggle Twitter script by Red Sweater Software:
http://www.red-sweater.com/blog/1646/toggle-twitter