Skip to content

Instantly share code, notes, and snippets.

View jkubicek's full-sized avatar

Jim Kubicek jkubicek

View GitHub Profile
@jkubicek
jkubicek / git-checkout-main
Last active February 8, 2021 21:02
Git Tools
git checkout (git-main)
git pull
@jkubicek
jkubicek / script_runner.md
Last active July 28, 2017 04:25
Script running Fish script

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 June 30, 2017 18:29
Dispatch Alert Queue for iOS
//: Playground - noun: a place where people can play
import Foundation
import PlaygroundSupport
class AlertQueue {
private let queue = DispatchQueue(label: "com.collectivehealth.alertqueue")
typealias Completion = () -> ()
@jkubicek
jkubicek / formatting.swift
Created June 15, 2016 19:01
Swift Formatting
import UIKit
//: # Collections
// This is bad
let badArray = ["one", "two", "apple",
"orange", "elephant", "orangutan"]
// This is good
let goodArray = ["one",
"two",
import Foundation
struct ExpensiveType {
init(name: String) {
print("This is expensive: \(name)")
}
}
class MyType {
@jkubicek
jkubicek / open-in-gmail.scpt
Created February 25, 2016 17:57
Applescript to open the currently selected Mail message in Gmail
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 November 3, 2015 18:17
Fix embedded framework version numbers
# 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 July 2, 2015 04:45
managed object creation extension
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 August 29, 2015 14:12
Swift nil-check compound assignment operator.
infix operator ??= {}
func ??=<T>(inout optional: T?, value: T) {
if optional == nil {
optional = value
}
}
var id: Int? = nil
@jkubicek
jkubicek / keybase.md
Created December 16, 2014 21:50
Keybase Validation

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: