Skip to content

Instantly share code, notes, and snippets.

"use strict";
const cors = require("cors");
const express = require("express");
const smartcar = require("smartcar");
const app = express().use(cors());
const port = 8000;
const client = new smartcar.AuthClient({
@kleneway
kleneway / gist:6171650
Created August 7, 2013 06:14
Example of drawing a pie chart slice from Haiku Deck using Core Graphics
- (UIBezierPath*)slicePathForDataPoint:(DataPoint*)dataPoint forCompleted:(float)completed forTotal:(float)total {
if(!total) {
return nil;
}
float percentOfTotal = (completed+fabsf([dataPoint.number floatValue]))/total;
float percentCompleted = completed/total;
percentOfTotal *= self.animationScaleFactor;
percentCompleted *= self.animationScaleFactor;
@kleneway
kleneway / gist:6171372
Created August 7, 2013 05:10
Using NSLinguisticTagger to stem Haiku Deck tags
// use the built-in ios linguistics functionality to stem the tags
+ (NSMutableArray *)stemTags:(NSMutableArray*)originalTags {
NSLinguisticTagger *tagger = [[NSLinguisticTagger alloc]
initWithTagSchemes:[NSArray arrayWithObjects:NSLinguisticTagSchemeLemma, nil]
options:(NSLinguisticTaggerOmitWhitespace | NSLinguisticTaggerOmitPunctuation)];
NSMutableArray *stemmedTags = [[NSMutableArray alloc] init];
// convert tags to string
[tagger setString:[originalTags componentsJoinedByString:@" "]];
@kleneway
kleneway / gist:6171311
Created August 7, 2013 04:58
UIPanGestureRecognizer for creating parallax effect on an image view with text view
- (IBAction)handlePanGesture:(UIPanGestureRecognizer*)gesture
{
CGPoint translation = [gesture translationInView:self.view];
if (gesture.state == UIGestureRecognizerStateChanged) {
// user is swiping, translate the view for the image by 1/4 the translation, and the text by 1/2 the translation to give parallax effect
self.currentSlide.imageView.frame = CGRectMake(self.currentSlide.imageView.frame.origin.x+translation.x/4,0,self.currentSlide.imageView.frame.size.width, self.currentSlide.imageView.frame.size.height);
self.currentSlide.slideText.view.frame = CGRectMake(self.currentSlide.slideText.view.frame.origin.x+translation.x/2,0,self.currentSlide.slideText.view.frame.size.width, self.currentSlide.slideText.view.frame.size.height);
// save the cumulative translation and reset the local translation
self.panTranslation += translation.x;
@kleneway
kleneway / gist:6171239
Created August 7, 2013 04:44
Animated Shadow on UICollectionViewCell
/**
* Code to add an animated shadow to a UICollectionViewCell
*/
//
// HAIMainMenuCollectionViewCell.m
// app-haikudeck
//
// Created by Kevin Leneway
@kleneway
kleneway / gist:3709815
Created September 12, 2012 20:50
My implementation of FPPickerController didFinishPickingMediaWithInfo
-(void)FPPickerController:(FPPickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// first check for image from camera roll or camera
UIImage *image = [info objectForKey:@"FPPickerControllerOriginalImage"];
// if not found, check to see if the image has been downloaded
if(!image) {
NSData *localData = [NSData dataWithContentsOfURL:[info objectForKey:@"FPPickerControllerReferenceURL"]];
if(localData) {
image = [UIImage imageWithData:localData];
}