Skip to content

Instantly share code, notes, and snippets.

Avatar
📱
Building and improving iOS Apps since 2009.

Marcus Kida kimar

📱
Building and improving iOS Apps since 2009.
View GitHub Profile
@kimar
kimar / publish-heroku.sh
Created Jan 10, 2020
Deploy Publish Static Site to Heroku or Dokku
View publish-heroku.sh
#!/bin/bash
echo 'https://github.com/vapor-community/heroku-buildpack' > .buildpacks
echo '5.1.3' > .swift-version
echo 'web: MySiteName && cd Output && python -m SimpleHTTPServer $PORT' > Procfile
@kimar
kimar / Enum+UnknownCaseRepresentable.swift
Created Jul 29, 2019
Swift enum unknown case default value
View Enum+UnknownCaseRepresentable.swift
protocol UnknownCaseRepresentable: RawRepresentable, CaseIterable where RawValue: Equatable {
static var unknownCase: Self { get }
}
extension UnknownCaseRepresentable {
init(rawValue: RawValue) {
let value = Self.allCases.first(where: { $0.rawValue == rawValue })
self = value ?? Self.unknownCase
}
}
@kimar
kimar / Applicable.swift
Last active Jan 10, 2020
Implement `apply` on NSObject (and other types)
View Applicable.swift
import Foundation
protocol Applicable {}
extension NSObject: Applicable {}
extension Applicable {
@discardableResult
func apply(_ closure: (Self) -> Void) -> Self {
closure(self)
return self
@kimar
kimar / XcodeBumpBuild.sh
Created Dec 6, 2017
Use this as a Run-Script-Phase in Xcode to automatically bump the Build Number in your Info.plst
View XcodeBumpBuild.sh
if [ $CONFIGURATION == Release ] || [ $CONFIGURATION == TestFlight ]; then
echo "Bumping build number..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}
# increment the build number (ie 115 to 116)
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "No build number in $plist"
exit 2
fi
@kimar
kimar / genymotionwithplay.txt
Created Jan 27, 2017 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
View genymotionwithplay.txt
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
@kimar
kimar / A_Promise.swift
Created Oct 9, 2016 — forked from ChristianKienle/A_Promise.swift
simplest Promise framework possible?
View A_Promise.swift
public struct Promise<T> {
typealias Fulfiller = (T) -> (Void)
typealias Rejecter = (Void) -> (Void)
typealias Resolver = (_ fulfill: @escaping Fulfiller, _ reject: @escaping Rejecter) -> (Void)
let resolver: Resolver
init(_ resolver: @escaping Resolver){
self.resolver = resolver
}
func then<U>(_ execute: @escaping ((T) -> U)) -> Promise<U> {
return Promise<U>({(fulfill, reject) in
View swiftybeaver.sh
#!/bin/bash
BASE_PATH="${SRCROOT}/swiftybeaver"
PLIST_NAME="SwiftyBeaver.plist"
PLIST="${BASE_PATH}/${PLIST_NAME}"
SCRIPT="${BASE_PATH}/vars.sh"
if [ ! -d $BASE_PATH ]; then
mkdir -p $BASE_PATH
fi
@kimar
kimar / git-delete-patch.diff
Created Mar 10, 2016
Fixes an issue in Git that leads to being able to delete the currently checked out branch
View git-delete-patch.diff
diff --git a/builtin/branch.c b/builtin/branch.c
index 7b45b6b..46bde61 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -215,7 +215,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
int flags = 0;
strbuf_branchname(&bname, argv[i]);
- if (kinds == FILTER_REFS_BRANCHES && !strcmp(head, bname.buf)) {
+ if (kinds == FILTER_REFS_BRANCHES && !strcasecmp(head, bname.buf)) {
@kimar
kimar / movToGif.sh
Last active Feb 24, 2016
Use ffmpeg and giscicle to convert video to gif, add this to your .bashrc (or equivalent) and be happy
View movToGif.sh
movToGif() {
TARGET="${2:-$1.gif}"
ffmpeg -i $1 -r 10 -f gif - | gifsicle --optimize=3 --delay=6 > $TARGET
}
@kimar
kimar / hello_name.swift
Created Jun 25, 2015
More advanced Hello World Swift CLI App
View hello_name.swift
#!/usr/bin/xcrun swift
import AppKit
struct Hello {
static func talk (name: String!) {
println("Hello \(name)!")
}
}