Skip to content

Instantly share code, notes, and snippets.

bitwit / Int+ARKitMetricConversions.swift
Created Aug 7, 2018
Easy metric conversions for ARKit Floats using Int extensions
View Int+ARKitMetricConversions.swift
import ARKit
// Example usage:
// let twentyCentimeters: Float =
// let twoMeters: Float = 2.m
// let oneMillimeter: Float =
// let extent: float3 = float3(,, 1.m)
extension Int {
var mm: Float {
bitwit / BasicMarkdownParserExample.js
Last active Nov 25, 2015
A functional javascript approach to a basic markdown parser. Inspired by a real interview question.
View BasicMarkdownParserExample.js
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 / index.html
Last active Aug 29, 2015
Angular js data example
View index.html
<script type="text/preloaded">{"preloaded":true}</script>
<div ng-app="appModule"></div>
bitwit / app.js
Last active Aug 29, 2015
Angular data preloading
View app.js
//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);
View ios view add shadow
- (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 / gist:9122514
Created Feb 20, 2014
Only open RFRateMe after a # of app uses
View gist:9122514
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];
bitwit / Makefile
Last active Dec 17, 2015
Bridging Python and SMILE C++ Libraries For Linux Smile library availiable at: version used: Linux (x64) / gcc 4.4.5, March 6th 2013
View Makefile
CXX= g++
CXXFILES= pysmilebridge.cpp
CXXINTERMEDIATE= pysmilebridge.o
CXXFLAGS= -O3 -DNDEBUG -ffast-math -Wall -fPIC
LIBS = -L/path/to/smile/ -lsmile
all: lib
bitwit / ViewController.h
Created Feb 4, 2013
The Objective-C ViewController from my blog entry An iOS5 Ready Native Web App Template
View ViewController.h
#import <UIKit/UIKit.h>
#import "WebViewController.h"
@interface ViewController : WebViewController
bitwit / WebViewControllerDelegate.h
Last active Dec 12, 2015
The Objective-C WebViewControllerDelegate from my blog entry An iOS5 Ready Native Web App Template
View WebViewControllerDelegate.h
* 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 / WebViewController.h
Last active Dec 12, 2015
The Objective-C WebViewController from my blog entry An iOS5 Ready Native Web App Template
View WebViewController.h
#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;
You can’t perform that action at this time.