Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kimar's full-sized avatar
📱
Building and improving Mobile Products since 2009.

Marcus Kida kimar

📱
Building and improving Mobile Products since 2009.
View GitHub Profile
@kimar
kimar / publish-heroku.sh
Created January 10, 2020 22:30
Deploy Publish Static Site to Heroku or Dokku
#!/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 / Applicable.swift
Last active January 10, 2020 03:41
Implement `apply` on NSObject (and other types)
import Foundation
protocol Applicable {}
extension NSObject: Applicable {}
extension Applicable {
@discardableResult
func apply(_ closure: (Self) -> Void) -> Self {
closure(self)
return self
@kimar
kimar / Enum+UnknownCaseRepresentable.swift
Created July 29, 2019 14:01
Swift enum unknown case default value
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 / genymotionwithplay.txt
Created January 27, 2017 23:44 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
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 / availableTcpPort.m
Created July 3, 2013 09:31
Returns available TCP Port in Objective-C / Cocoa
- (int) availableTcpPort
{
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
addr.sin_port = 0;
inet_aton("0.0.0.0", &addr.sin_addr);
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
perror("socket()");
return -1;
@kimar
kimar / XcodeBumpBuild.sh
Created December 6, 2017 21:30
Use this as a Run-Script-Phase in Xcode to automatically bump the Build Number in your Info.plst
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 / A_Promise.swift
Created October 9, 2016 23:43 — forked from ChristianKienle/A_Promise.swift
simplest Promise framework possible?
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
#!/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 March 10, 2016 21:21
Fixes an issue in Git that leads to being able to delete the currently checked out branch
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 February 24, 2016 03:02
Use ffmpeg and giscicle to convert video to gif, add this to your .bashrc (or equivalent) and be happy
movToGif() {
TARGET="${2:-$1.gif}"
ffmpeg -i $1 -r 10 -f gif - | gifsicle --optimize=3 --delay=6 > $TARGET
}