Skip to content

Instantly share code, notes, and snippets.

View PaulSolt's full-sized avatar

Paul Solt PaulSolt

View GitHub Profile
@joshavant
joshavant / observer_pattern.md
Created April 17, 2014 22:04
Handy little design pattern that lets you kick off processes in arbitrary objects + lets arbitrary dependencies add themselves into a notification chain

##XXAppDelegate.m, XXSomeView.m, some other object, etc##

...
[[XXSomeSingletonController sharedInstance] doThatThing];
...

##XXSomeSingletonControllerObserver.h##

@protocol XXSomeSingletonControllerObserver 
@jfro
jfro / re-create-sims.rb
Created March 9, 2015 20:47
re-creates simulators stuck in "Creating" state from Xcode 6.2 update
#!/bin/env ruby
deviceTypes = {
"iPhone 4s" => "com.apple.CoreSimulator.SimDeviceType.iPhone-4s",
"iPhone 5" => "com.apple.CoreSimulator.SimDeviceType.iPhone-5",
"iPhone 5s" => "com.apple.CoreSimulator.SimDeviceType.iPhone-5s",
"iPhone 6 Plus" => "com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus",
"iPhone 6" => "com.apple.CoreSimulator.SimDeviceType.iPhone-6",
"iPad 2" => "com.apple.CoreSimulator.SimDeviceType.iPad-2",
"iPad Retina" => "com.apple.CoreSimulator.SimDeviceType.iPad-Retina",
@ethanmick
ethanmick / Game.m
Created January 4, 2014 16:30
Loading the Menu from Cocos2D
- (void)openMenu:(CCMenuItem *)item;
{
// UI KITTTTTTTTTT
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"DMMainMenu_iPhone" bundle:nil];
UIViewController *menu = [storyboard instantiateViewControllerWithIdentifier:@"DMMainMenuNavigationController"];
menu.modalPresentationStyle = UIModalPresentationFullScreen;
menu.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
if (menu) {
[[CCDirector sharedDirector] presentViewController:menu animated:YES completion:^{
[[CCDirector sharedDirector] pause];
@mattbierner
mattbierner / image.html
Last active December 5, 2018 15:00
Automatic migration of ghost images to Jekyll
<figure class="image">
{% capture image_src %}{% if include.file %}/content/{{ page.path | remove_first:'_posts/' | split:'.' | first }}/{{ include.file }}{% else %}{{ include.url }}{% endif %}{% endcapture %}
<a href="{{ image_src }}">
<img src="{{ image_src }}" alt="{{ include.description }}" />
</a>
{% if include.description %}
<figcaption>{{ include.description }}</figcaption>
{% endif %}
</figure>
@fletcher
fletcher / default.keybinding
Last active August 28, 2019 16:26
MultiMarkdown Composer 4 Default Key Binding File
[{
"key": "P",
"action": "togglePreview:",
"modifiers": ["cmd", "ctrl"]
}, {
"key": "I",
"action": "toggleInfo:",
"modifiers": ["cmd", "shift"]
}, {
"key": "T",
@eternalstorms
eternalstorms / NSSharingServicePicker+ESSSharingServicePickerMenu.h
Created November 22, 2012 18:50
A category on NSSharingServicePicker to create a menu that can be used as a sharing submenu or main menu
//
// NSSharingServicePicker+ESSSharingServicePickerMenu.h
//
// Created by Matthias Gansrigler on 22.11.12.
// Copyright (c) 2012 Eternal Storms Software. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface NSSharingServicePicker (ESSSharingServicePickerMenu)
@JohnSundell
JohnSundell / OnboardingManager.swift
Last active May 21, 2020 08:19
An example of using #function for user defaults properties, and a test that guards against property name changes
import UIKit
class OnboardingManager {
private let userDefaults: UserDefaults
init(userDefaults: UserDefaults = .standard) {
self.userDefaults = userDefaults
}
func presentOnboardingControllerIfNeeded(in viewController: UIViewController) {
@froggomad
froggomad / NetworkService.swift
Last active June 24, 2020 16:22
Network Helper Class
import Foundation
protocol NetworkLoader {
func loadData(using request: URLRequest, with completion: @escaping (Data?, HTTPURLResponse?, Error?) -> Void)
}
extension URLSession: NetworkLoader {
/// Asyncronously load data using a URL Request
/// - Parameters:
/// - request: an unwrapped URLRequest