Skip to content

Instantly share code, notes, and snippets.

View frijole's full-sized avatar
🌯

Ian Meyer frijole

🌯
View GitHub Profile
// NEW RANDOM ACTION
NSString *lineSources = [[NSBundle mainBundle] pathForResource:@"quotes" ofType:@"plist"];
NSDictionary *lines = [[NSDictionary alloc] initWithContentsOfFile:lineSources];
NSMutableArray *line1Strings = [lines valueForKey:@"line1"];
NSMutableArray *line2Strings = [lines valueForKey:@"line2"];
NSMutableArray *line3Strings = [lines valueForKey:@"line3"];
NSMutableArray *line4Strings = [lines valueForKey:@"line4"];
NSMutableArray *line5Strings = [lines valueForKey:@"line5"];
@frijole
frijole / RikerIpsum.h
Last active December 15, 2015 04:29
the best placeholder text ever
//
// RikerIpsum.h
//
// Based on http://www.rikeripsum.com
// Created by @frijole on 3/19/13.
//
#import <Foundation/Foundation.h>
@interface RikerIpsum : NSObject
Enoch:~ ian$ iostat -n9 -w1
disk0 disk1 disk2 disk3 disk4 cpu load average
KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us sy id 1m 5m 15m
26.76 4 0.10 1722.13 0 0.00 1750.15 0 0.00 15.35 0 0.00 319.46 0 0.00 1 1 97 0.86 1.11 1.24
0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 597.33 6 3.49 4 4 92 0.86 1.11 1.24
8.00 7 0.05 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 718.29 7 4.90 7 7 86 0.86 1.11 1.24
0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 2470.40 5 12.04 14 8 78 0.86 1.11 1.24
0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 1480.00 2 2.89 4 4 92 0.86 1.11 1.24
0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 808.57 7 5.52 8 7 85 0.79 1.09 1.23
0.00 0 0.00 0.00 0 0.00
// from: current location
float fLat = (currentLocation.coordinate.latitude / 180.0) * M_PI;
float fLng = (currentLocation.coordinate.longitude / 180.0) * M_PI;
// to: waypoint location
float tLat = (waypoint.locationLat / 180.0) * M_PI;
float tLng = (waypoint.locationLon / 180.0) * M_PI;
// calculate it!
float locationHeading = atan2(sin(tLng-fLng)*cos(tLat), cos(fLat)*sin(tLat)-sin(fLat)*cos(tLat)*cos(tLng-fLng));
@frijole
frijole / gist:5629307
Created May 22, 2013 17:25
UIImageView subclass method for setting up and animating an image sequence
- (void)setFramesWithFirstFrame:(NSString *)fileName;
{
// DLog(@"firstFrame: %@",fileName);
[self setImage:[UIImage imageNamed:fileName]];
// split the `fileName` into a base and number. then incrememnt the number until imageNamed returns nil.
// check for numbers in the filename
NSRange pngRange = [fileName rangeOfString:@".png"];
NSRange numberRange;
@frijole
frijole / gist:6258380
Created August 17, 2013 19:32
helios, gems, and activesupport oh my
/* via http://helios.io
Use the following commands to install Helios, create a new app, and start running the app locally at http://localhost:5000
$ gem install helios
$ helios new app
$ cd app && helios start
*/
Enki-II:utility-sportsapp-ios ian$ sudo gem install helios
Password:
@frijole
frijole / ScrollDirection.m
Created September 13, 2013 15:02
track a UIScrollView's direction, based on http://stackoverflow.com/a/16953031
typedef NS_ENUM(NSInteger, UIScrollViewScrollDirection) {
UIScrollViewScrollDirectionDown = -1,
UIScrollViewScrollDirectionNone = 0,
UIScrollViewScrollDirectionUp = 1,
};
@interface FRJViewController ()
@property (nonatomic) UIScrollViewScrollDirection scrollDirection;
@frijole
frijole / CountdownLabel.M
Created October 7, 2013 22:01
excerpt from a uilabel subclass that counts down to a date
- (void)update
{
// check interval and update text
if ( _running ) {
// do the update
NSTimeInterval tmpInterval = [self.date timeIntervalSinceNow];
int tmpMins = tmpInterval/60;
int tmpSecs = tmpInterval-(tmpMins*60);
@frijole
frijole / gist:3eafc99cfbc5bd2e96ae
Last active August 29, 2015 14:07
supportedInterfaceOrientations implementation that allows all orientations on iPad, all but upside-down on the iPhone 6 Plus, and portrait-only for others. But it feels dirty...
- (NSUInteger)supportedInterfaceOrientations
{
UIInterfaceOrientationMask rtnOrientationMask = UIInterfaceOrientationMaskPortrait;
if ( UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad ) {
rtnOrientationMask = UIInterfaceOrientationMaskAll;
} else if ( [UIScreen mainScreen].bounds.size.height > 600.0f || [UIScreen mainScreen].bounds.size.width > 600.0f ) {
rtnOrientationMask = UIInterfaceOrientationMaskAllButUpsideDown;
} else {
rtnOrientationMask = UIInterfaceOrientationMaskPortrait;
@frijole
frijole / DynamicCollectionView.m
Created February 4, 2016 14:36
Resize a collection view to its content with AutoLayout via http://stackoverflow.com/a/26232188
@interface DynamicCollectionView : UICollectionView
@end
@implementation DynamicCollectionView
- (void) layoutSubviews
{
[super layoutSubviews];