Skip to content

Instantly share code, notes, and snippets.

@mpvosseller
mpvosseller / gist:6969154
Last active Dec 25, 2015
Category on an NSArray to return n random elements.
View gist:6969154
@interface NSArray (MPV)
- (NSArray*) mpv_randomElements:(NSUInteger)maxElements;
@end
@implementation NSArray (MPV)
- (NSArray*) mpv_randomElements:(NSUInteger)maxElements {
NSUInteger numElementsToPick = MIN(self.count, maxElements);
@mpvosseller
mpvosseller / gist:c0d15fa497a1256977dc
Last active Aug 29, 2015
Updated shell script to install Charles's SSL CA certificate to the keychain for iOS 8 simulators. The change is to support the new path used in iOS 8 simulators. The original shell script is stored here: http://www.charlesproxy.com/documentation/faqs/ssl-connections-from-within-iphone-applications
View gist:c0d15fa497a1256977dc
#/bin/bash
install() {
if [ -f "$SQLITEDBPATH" ]; then
cp -n "$SQLITEDBPATH" "$SQLITEDBPATH.charlesbackup"
sqlite3 "$SQLITEDBPATH" <<EOF
INSERT INTO "tsettings" VALUES(X'189B6E28D1635F3A8325E1E002180DBA2C02C241',X'3123302106035504030C1A436861726C65732050726F78792053534C2050726F7879696E6731243022060355040B0C1B687474703A2F2F636861726C657370726F78792E636F6D2F73736C3111300F060355040A0C08584B3732204C74643111300F06035504070C084175636B6C616E643111300F06035504080C084175636B6C616E64310B3009060355040613024E5A',X'3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D225554462D38223F3E0A3C21444F435459504520706C697374205055424C494320222D2F2F4170706C652F2F44544420504C49535420312E302F2F454E222022687474703A2F2F7777772E6170706C652E636F6D2F445444732F50726F70657274794C6973742D312E302E647464223E0A3C706C6973742076657273696F6E3D22312E30223E0A3C61727261792F3E0A3C2F706C6973743E0A',X'3082045E30820346A003020102020101300D06092A864886F70D01010505003081913123302106035504030C1A436861726C65732050726F78792053534C2050726F7879696E67312430
@mpvosseller
mpvosseller / gist:4adac1e421d5c5e44f8e
Created Sep 26, 2014
Block based replacement for -[NSObject performSelector:withObject:afterDelay:]
View gist:4adac1e421d5c5e44f8e
// Block based replacement for
// -[NSObject performSelector:withObject:afterDelay:]
// because I can never remember how to do it with the dispatch_after & dispatch_time functions
//
// NSObject+MPV.h
// iFoodler
//
// Created by Michael Vosseller on 9/26/14.
@mpvosseller
mpvosseller / gist:8897b379f040e0ca1476
Created Jan 20, 2016
Xcode Build Phase Run Script to Disable AppTransportSecurity in DEBUG Simulator Builds
View gist:8897b379f040e0ca1476
#!/bin/sh
## Disable AppTransportSecurity in DEBUG Simulator Builds
if [[ ${CONFIGURATION} == "Debug" ]] && [[ $PLATFORM_NAME == *"simulator"* ]]; then
TARGET_INFOPLIST="${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"
## Delete NSAppTransportSecurity entry if it already exists
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" "${TARGET_INFOPLIST}" 2>/dev/null
@mpvosseller
mpvosseller / make-ios-icons
Created Feb 12, 2018
Given a 1024x1024 iOS app icon this script creates all the other requires sizes
View make-ios-icons
#!/bin/sh
convert Icon-1024.png -resize 20x20 Icon-20.png
convert Icon-1024.png -resize 40x40 Icon-20@2x.png
convert Icon-1024.png -resize 60x60 Icon-20@3x.png
convert Icon-1024.png -resize 29x29 Icon-29.png
convert Icon-1024.png -resize 58x58 Icon-29@2x.png
convert Icon-1024.png -resize 87x87 Icon-29@3x.png
convert Icon-1024.png -resize 40x40 Icon-40.png
convert Icon-1024.png -resize 80x80 Icon-40@2x.png
convert Icon-1024.png -resize 76x76 Icon-76.png
@mpvosseller
mpvosseller / example.swift
Last active Feb 28, 2018
When implementing a protocol property that returns an optional value you must explicitly declare the type (as an optional) in your implementation. See below comment for details.
View example.swift
protocol MyProtocol {
var name: String? { get }
}
extension MyProtocol {
var name: String? {
return "aDefaultName"
}
}
@mpvosseller
mpvosseller / gist:5749ad19d046cf14ebf24c837665dc25
Created May 28, 2018
Use Slack reminders to improve timely attendance
View gist:5749ad19d046cf14ebf24c837665dc25
/remind #general "Team meeting starts in 15 minutes https://meet.google.com/XXXXXXX" at 10:45AM every Monday
/remind #general "Team meeting starts in 5 minutes https://meet.google.com/XXXXXXX" at 10:55AM every Monday
/remind #general "Team meeting starts in 1 minute https://meet.google.com/XXXXXXX" at 10:59AM every Monday
You can’t perform that action at this time.