Skip to content

Instantly share code, notes, and snippets.

@bitwit
bitwit / gist:9122514
Created February 20, 2014 20:27
Only open RFRateMe after a # of app uses
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
int timesOpened = [defaults integerForKey:@"timesOpened"];
NSLog(@"App has been opened %d times", timesOpened);
if(timesOpened >= 4){
[RFRateMe showRateAlert];
}
[defaults setInteger:(timesOpened+1) forKey:@"timesOpened"];
[defaults synchronize];
- (void)setupShadowForView:(UIView *)view {
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:view.frame cornerRadius:10];
CALayer *viewLayer = view.layer;
[viewLayer setShadowColor:[UIColor blackColor].CGColor];
[viewLayer setShadowOpacity:1.0f];
[viewLayer setShadowRadius:10.0f];
[viewLayer setShadowPath:[path CGPath]];
}
@bitwit
bitwit / app.js
Last active August 29, 2015 14:03
Angular data preloading
angular.module('appModule')
//app initialization
.constant('MY_CONFIG', {})
.config(['MY_CONFIG', function(MY_CONFIG){
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
var script = scripts[i];
if(script.type === 'text/preloaded'){
var data = JSON.parse(script.innerHTML);
angular.extend(MY_CONFIG, data);
@bitwit
bitwit / index.html
Last active August 29, 2015 14:03
Angular js data example
<html>
<head>
<script type="text/preloaded">{"preloaded":true}</script>
</head>
<body>
<div ng-app="appModule"></div>
</body>
</html>
@bitwit
bitwit / BasicMarkdownParserExample.js
Last active November 25, 2015 20:18
A functional javascript approach to a basic markdown parser. Inspired by a real interview question.
var _ = require('underscore')
var lines = [
"#The test",
"###Hello World",
"This is a new paragraph.",
"It has a second line",
"",
"This is my new paragraph"
];
@bitwit
bitwit / gist:4322561
Created December 17, 2012 21:42
iOS Web App apple-touch-start-image meta data for all device possibilities.
<!-- iPhone SPLASHSCREEN-->
<link href="/img/ios/iphone-splash.jpeg" media="screen and (max-device-width: 320px)" rel="apple-touch-startup-image">
<!-- iPhone (Retina) SPLASHSCREEN-->
<link href="/img/ios/iphone-splash@2x.jpeg" media="(device-height: 480px) and (-webkit-min-device-pixel-ratio: 2)" rel="apple-touch-startup-image">
<!-- iPhone 5 SPLASHSCREEN -->
<link href="/img/ios/iphone5-splash.jpeg" media="(device-height: 568px) and (-webkit-min-device-pixel-ratio: 2)" rel="apple-touch-startup-image">
<!-- iPad (portrait) SPLASHSCREEN-->
<link href="/img/ios/ipad-portrait-splash.jpeg" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)" rel="apple-touch-startup-image">
<!-- iPad (landscape) SPLASHSCREEN-->
@bitwit
bitwit / index.html
Last active December 12, 2015 03:08
The HTML, CSS and JS from my blog entry An iOS5 Ready Native Web App Template http://www.bitwit.ca/blog/an-ios5-ready-native-web-app-template/
<!doctype html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="style.css">
<script src="jquery-1.6.2.min.js"></script>
<script defer src="script.js"></script>
</head>
<body id="body">
@bitwit
bitwit / WebViewControllerDelegate.h
Last active December 12, 2015 03:08
The Objective-C WebViewControllerDelegate from my blog entry An iOS5 Ready Native Web App Template http://www.bitwit.ca/blog/an-ios5-ready-native-web-app-template/
/**
* WebViewController is responsible for all
* messages that can be used in HTML
*/
@class WebViewController;
@interface WebViewControllerDelegate : NSObject <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (nonatomic, weak) WebViewController *webViewController;
@bitwit
bitwit / WebViewController.h
Last active December 12, 2015 03:08
The Objective-C WebViewController from my blog entry An iOS5 Ready Native Web App Template http://www.bitwit.ca/blog/an-ios5-ready-native-web-app-template/
#import <UIKit/UIKit.h>
@class WebViewControllerDelegate;
@interface WebViewController : UIViewController <UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) WebViewControllerDelegate *functionDelegate;
-(void)loadPageWithURL:(NSString *)url;
-(void)loadPageFromFile:(NSString *)html;
@bitwit
bitwit / ViewController.h
Created February 4, 2013 01:18
The Objective-C ViewController from my blog entry An iOS5 Ready Native Web App Template http://www.bitwit.ca/blog/an-ios5-ready-native-web-app-template/
#import <UIKit/UIKit.h>
#import "WebViewController.h"
@interface ViewController : WebViewController
@end