Skip to content

Instantly share code, notes, and snippets.

@mnmaraes
mnmaraes / PaperAnimation
Last active May 23, 2017 15:30
Gist that seeks to emulate Paper's menu animation
//
// TUIViewController.m
// TestUIs
//
// Created by Murillo Nicacio de Maraes on 3/9/14.
// Copyright (c) 2014 m-one. All rights reserved.
//
#import "TUIViewController.h"
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@tomazsh
tomazsh / gist:4257206
Created December 11, 2012 09:05
Moving navigation bar in UINavigationController along with UIScrollView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CALayer *layer = self.navigationController.navigationBar.layer;
CGFloat y = scrollView.contentOffset.y+scrollView.contentInset.top;
if (y >= 0.0f) {
layer.transform = CATransform3DMakeTranslation(0.0f, -y, 0.0f);
} else {
layer.transform = CATransform3DIdentity;
}
}
@arnklint
arnklint / track-form-abandonment.md
Last active December 18, 2017 18:57
Track Form Abandonment in Google Analytics in five rows of javascript

Put this code on the page where the form you want to track resides. Some other examples are currently passed around the web with varying quality. This is one that will work as long as your form tag has an id= or name attribute.

You don´t have to change this code to be able to track form abandonment in your shopping cart, order form or whatever form you want.

This sends events to Google Analytics when a user focuses somewhere not in a field after having focused on a input field. You won´t know for how long users focused on respective fields, or the actual conversion rate in the form using this, but it might be a start.

A tool that provides more insight both over time and per field, is Form Analytics wich helps you optimize your online forms. For instance, it measures dropout rate, average field input length, conversion rate and average time per field. All which provides great insights in the most overlooked, yet important part of you site.

Anyway, here´s the code:

@hollance
hollance / Explanation.md
Last active September 25, 2017 03:35
Communicate between objects using channels

Communicate between objects using channels

When you have two objects A and B, say two view controllers, that you want to have talk to each other, you can choose from the following options:

  • NSNotificationCenter. This is anonymous one-to-many communication. Object A posts a notification to the NSNotificationCenter, which then distributes it to any other objects listening for that notification, including Object B. A and B do not have to know anything about each other, so this is a very loose coupling. Maybe a little too loose...

  • KVO (Key-Value Observing). One object observes the properties of another. This is a very tight coupling, because Object B is now peeking directly into Object A. The advantage of KVO is that Object A doesn't have to be aware of this at all, and therefore does not need to send out any notifications -- the KVO mechanism takes care of this behind the scenes.

  • Direct pointers. Object A has a pointer to Object B and directly sends it messages when something of interest h

@siffring
siffring / .htaccess
Created March 4, 2012 17:33
htaccess to password protect a specific server
# ----------------------------------------------------------------------
# Password protect staging server
# Use one .htaccess file across multiple environments
# (e.g. local, dev, staging, production)
# but only password protect a specific environment.
# ----------------------------------------------------------------------
SetEnvIf Host staging.domain.com passreq
AuthType Basic
AuthName "Password Required"
@hramos
hramos / upload-testflight.sh
Created January 11, 2011 03:51
Deploy builds to Testflight with this script. Use a git wrapper (i.e. git push-and-deploy) to invoke git push, then xcodebuild, then this script.
#!/bin/sh
FILE=@FILENAME.ipa
API_TOKEN='<api key under account>'
TEAM_TOKEN='<team token under specific team>'
NOTES='Buildscript'
ENDPOINT=http://testflightapp.com/api/builds.json
DISTRIBUTION_LISTS='Internal'
curl $ENDPOINT -F file=$FILE -F api_token=$API_TOKEN -F team_token=$TEAM_TOKEN -F notify=true -F distribution_lists=$DISTRIBUTION_LISTS -F notes=$NOTES