Skip to content

Instantly share code, notes, and snippets.

View brennanMKE's full-sized avatar

Brennan Stehling brennanMKE

View GitHub Profile
{
"USA" : {
"AZ" : ["Phoenix", "Tucson"],
"CA" : ["Fresno", "Inland Empire", "Los Angeles", "Modesto", "Orange County", "Sacramento",
"San Diego", "San Francisco", "Santa Barbara", "Silicon Valley"],
"CO" : ["Colorado Springs", "Denver"],
@brennanMKE
brennanMKE / FullScreen.m
Last active November 28, 2017 10:06
FullScreen interaction for setting the top bars to be clear until content is scrolled up and the background has to be opaque.
#pragma mark - Hide and Show
#pragma mark -
- (void)prepareAnimationForNavigationBarWithDuration:(CGFloat)duration {
// prepare animation for navigation bar
CATransition *animation = [CATransition animation];
[animation setDuration:duration];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[animation setType:kCATransitionFade];
[self.navigationController.navigationBar.layer addAnimation:animation forKey:nil];
@brennanMKE
brennanMKE / isMobile.js
Created June 18, 2014 23:21
JavaScript to detect mobile browser and platform.
var isMobile = {
Android: function() {
return /Android/i.test(navigator.userAgent);
},
BlackBerry: function() {
return /BlackBerry/i.test(navigator.userAgent);
},
iOS: function() {
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
},
@brennanMKE
brennanMKE / app-redirect.html
Created July 1, 2014 16:45
Website to App Redirect
<html><head><title>MyApp Redirect</title></head>
<script type="text/javascript">
var isAndroid = /Android/i.test(navigator.userAgent);
var isiOS = /iPhone|iPad|iPod/i.test(navigator.userAgent);
if (isiOS) {
location.href = "https://itunes.apple.com/us/app/myapp/id99999999?mt=8";
}
else if (isAndroid) {
location.href = "https://play.google.com/store/apps/details?id=com.myapp.myapp";
@brennanMKE
brennanMKE / tumblrGist.js
Created July 2, 2014 16:40
Embed GitHub Gists in Tumblr
$(function() {
var gistPrefix = 'https://gist.github.com/';
var embedGists = function() {
$('a[href^="' + gistPrefix + '"]').each(function(index, anchor) {
var href = $(anchor).attr('href');
var gistId = href.substring(gistPrefix.length);
var url = gistPrefix + gistId + '.json?callback=?';
$.getJSON(url, function(gistData) {
@brennanMKE
brennanMKE / BaseViewController.h
Last active August 29, 2015 14:03
iOS Keyboard Handling with a Base View Controller
#import <UIKit/UIKit.h>
@interface BaseViewController : UIViewController
#pragma mark - Keyboard Methods
#pragma mark -
- (void)hideKeyboardWithoutAnimation;
- (void)keyboardWillShowWithHeight:(CGFloat)height duration:(CGFloat)duration animationOptions:(UIViewAnimationOptions)animationOptions;
- (void)keyboardWillHideWithHeight:(CGFloat)height duration:(CGFloat)duration animationOptions:(UIViewAnimationOptions)animationOptions;
@brennanMKE
brennanMKE / addShadow.m
Created July 16, 2014 23:08
iOS Shadow View
// add a shadow
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:view.bounds];
view.layer.masksToBounds = NO;
view.layer.shadowColor = [UIColor blackColor].CGColor;
view.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
view.layer.shadowOpacity = 0.45f;
view.layer.shadowRadius = 10.0f;
view.layer.shadowPath = shadowPath.CGPath;
@brennanMKE
brennanMKE / TappableTextView.m
Created July 31, 2014 01:42
Tappable UITextView in a UICollectionView
@implementation TappableTextView
- (instancetype)init {
self = [super init];
if (self) {
[self setup];
}
return self;
}
@brennanMKE
brennanMKE / shortener.sh
Last active November 24, 2020 18:10
Bitly Command-line Shortener
#!/bin/sh
# Note: Be sure to set BITLY_LOGIN and BITLY_APIKEY in .bash_profile
# .bash_profile
#
# export BITLY_LOGIN=REPLACE_WITH_LOGIN
# export BITLY_APIKEY=REPLACE_WITH_KEY
#
# Then run "source ~/.bash_profile" to update your current shell.
@brennanMKE
brennanMKE / buildnumber.sh
Created September 20, 2014 01:06
Automatically updating the build number in Xcode
appBuild=`date "+%Y.%m.%d.%H%M%S"`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
echo "Updated ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"