Skip to content

Instantly share code, notes, and snippets.

Jim Kubicek jkubicek

View GitHub Profile
@jkubicek
jkubicek / script_runner.md
Last active Jul 28, 2017
Script running Fish script
View script_runner.md

The s function takes a single string argument and runs an executable located in the ./scripts/ directory that has the same path as the parameter

function s --argument SCRIPT_NAME
  eval ./scripts/$SCRIPT_NAME
end

The print-scripts function returns a space-separated list of all executables located in ./scripts/

@jkubicek
jkubicek / AlertQueue.swift
Last active Jun 30, 2017
Dispatch Alert Queue for iOS
View AlertQueue.swift
//: Playground - noun: a place where people can play
import Foundation
import PlaygroundSupport
class AlertQueue {
private let queue = DispatchQueue(label: "com.collectivehealth.alertqueue")
typealias Completion = () -> ()
View formatting.swift
import UIKit
//: # Collections
// This is bad
let badArray = ["one", "two", "apple",
"orange", "elephant", "orangutan"]
// This is good
let goodArray = ["one",
"two",
View lazyLeaks.swift
import Foundation
struct ExpensiveType {
init(name: String) {
print("This is expensive: \(name)")
}
}
class MyType {
@jkubicek
jkubicek / open-in-gmail.scpt
Created Feb 25, 2016
Applescript to open the currently selected Mail message in Gmail
View open-in-gmail.scpt
tell application "Mail"
set the_messages to selected messages of first message viewer
set the_headers to all headers of item 1 of the_messages
set thecommandstring to "echo \"" & the_headers & "\"| sed -n -e 's/Message-Id: <\\(.*\\)>/\\1/p'" as string
set sedResult to do shell script thecommandstring
set link to "https://mail.google.com/mail/#search/in%3Aanywhere+rfc822msgid%3A" & sedResult
do shell script "open " & link
end tell
@jkubicek
jkubicek / Fix embedded framework versions
Last active Nov 3, 2015
Fix embedded framework version numbers
View Fix embedded framework versions
# Add this script as a build phase in your project. It will update
# all embeded framework marketing versions and build version to be
# equal to the marketing and build version in your main app.
# More details:
# https://github.com/Carthage/Carthage/issues/859
# https://forums.developer.apple.com/thread/23778
PLIST_PATH=$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH
PLIST_PATH=$(dirname $PLIST_PATH)/$(basename $PLIST_PATH .plist)
@jkubicek
jkubicek / NSManagedObject.swift
Created Jul 2, 2015
managed object creation extension
View NSManagedObject.swift
protocol ManagedObject {
static var entityName: String { get }
}
extension ManagedObject where Self: NSManagedObject {
static func createWithContext(context: NSManagedObjectContext) -> Self {
return Self.createWithContext(context, entityName: self.entityName)
@jkubicek
jkubicek / gist:fe2dbc7ad583ffacf2b6
Last active Aug 29, 2015
Swift nil-check compound assignment operator.
View gist:fe2dbc7ad583ffacf2b6
infix operator ??= {}
func ??=<T>(inout optional: T?, value: T) {
if optional == nil {
optional = value
}
}
var id: Int? = nil
@jkubicek
jkubicek / keybase.md
Created Dec 16, 2014
Keybase Validation
View keybase.md

Keybase proof

I hereby claim:

  • I am jkubicek on github.
  • I am jkubicek (https://keybase.io/jkubicek) on keybase.
  • I have a public key whose fingerprint is 7E94 5E4C 38D6 0CE5 C3AE 7AA6 6D5A 35E1 86AF D4A5

To claim this, I am signing this object:

@jkubicek
jkubicek / birds.txt
Last active Aug 29, 2015
Print the names of all the birds
View birds.txt
Striated Pardalote
Elegant Crested Tinamou
Little Tinamou
Slaty-breasted Tinamou
Thicket Tinamou
Great Tinamou
Chilean Tinamou
Cinereous Tinamou
Brown Tinamou
Greater Rhea
You can’t perform that action at this time.