Skip to content

Instantly share code, notes, and snippets.

@daviddulak
daviddulak / Pass Keyboard Events to PhoneGap Webview
Last active December 25, 2015 12:28
A way to notify a PhoneGap webview when the keyboard shows or hides and include the keyboard height. Should be placed in MainViewController.m for use with PhoneGap.
- (void)keyboardWillShowOrHide:(NSNotification*)notif
{
CGRect keyboardFrame = [notif.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];
CGFloat height = keyboardFrame.size.height;
BOOL showing = [notif.name isEqualToString:UIKeyboardWillShowNotification];
NSString *showingString = showing ? @"true" : @"false";
NSString *jsString = [NSString stringWithFormat:@"$(window).trigger(jQuery.Event('keyboardToggle', {showing: %@, height: %f}));", showingString, height];
@daviddulak
daviddulak / Set ViewController Base StatusBar to Hidden in iOS6 & iOS7
Created October 14, 2013 14:13
This handles ViewController based StatusBar hiding in iOS6 and iOS7
// Place in the ViewController
-(BOOL)prefersStatusBarHidden {
return YES;
}
// Place in viewWillAppear or viewDidLoad
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; // iOS 7
} else {
@daviddulak
daviddulak / Notify PhoneGap app that Google Maps App is Installed
Created October 14, 2013 14:15
This is a simple way to let your PhoneGap app know if Google Maps App is installed on the device
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) {
NSString *jsString = @"window.googleMapsAppInstalled = true;";
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
}
@daviddulak
daviddulak / PromiseToRetry.js
Created November 20, 2015 21:53
Static utility for retrying a jQuery Deferred promise
define(function(require) {
var $ = require('$');
/**
* Static utility for retrying a promise
* @class PromiseToRetry
*/
/**
* A promise based helper function
@daviddulak
daviddulak / MinimumDelayedPromise.js
Created November 20, 2015 22:53
Static utility for forcing a minimum return time for a jQuery Deferred promise
define(function(require) {
var $ = require('$');
/**
* Static utility for forcing a minimum return time for a promise
* @class MinimumDelayedPromise
*/
/**
* A promise based helper function
@daviddulak
daviddulak / Find Unused Images for Projects
Last active October 25, 2017 19:25
This searches for unused images in a project
var TextSearch = require('rx-text-search');
var walk = require('walk');
var colors = require('colors');
var Promise = require('bluebird');
// *************************************************
// Required Node Packages
//