Skip to content

Instantly share code, notes, and snippets.

View fatuhoku's full-sized avatar

Hok Shun Poon fatuhoku

View GitHub Profile
// Taken from:
// All of these functions here are inspired/ported from PivotalCoreKit
import UIKit
import Nimble
// emulates a tap on a bar button item. Does not support customViews
//func tap(barButtonItem: UIBarButtonItem) {
// SelectorProxy(target:, withObject: barButtonItem)
fatuhoku / parse_thumbnail
Created November 17, 2015 21:51 — forked from lukejohnjones/parse_thumbnail thumbnail creation retaining aspect ratio
var Image = require("parse-image");
Parse.Cloud.beforeSave("_User", function(request, response) {
var user = request.object;
if (!user.get("profilePhoto")) {
response.error("Users must have a profile photo.");
if (!user.dirty("profilePhoto")) {
fatuhoku / .gitignore
Created November 13, 2015 23:25
.gitignore for iOS projects
# Xcode
fatuhoku / JHGradientView.swift
Last active November 12, 2015 23:47 — forked from jhays/JHGradientView.swift
GradientView - Editable in Interface Builder
// JHGradientView.swift
// Gradient View editable in Interface Builder
// Created by JHays on 2/20/15.
// Copyright (c) 2015 Orbosphere. All rights reserved.
import Foundation
import UIKit
fatuhoku / AppDelegate.m
Last active August 29, 2015 14:25
Default React Native AppDelegate implementation
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
#import "AppDelegate.h"
fatuhoku / Auto-adjust popover size based on preferredSize of topViewController
Created November 4, 2014 23:31
Make popover resize according to the preferredSizes of ViewControllers
// Conform to UINavigationControllerDelegate and then implement this:
// Especially if the topViewController is a RBStoryboardLink or something.
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
// NB: Using navigationController.preferredContentSize would be better here, but it doesn't reset properly when navigating back so we manually add on the height of the navbar instead.
CGSize size = viewController.preferredContentSize;
CGFloat navbarHeight = navigationController.navigationBar.frame.size.height;
<topViewController>.preferredContentSize = CGSizeMake(size.width, size.height + navbarHeight);