Skip to content

Instantly share code, notes, and snippets.

View logicaroma's full-sized avatar

Ramin Mohammadi logicaroma

View GitHub Profile
// Method: What is Nearer helper function
// Pre-requisite: dataset loaded in the app delegate
-(NSDictionary *) whatIsNearer:(CLLocation *)currentLocation {
whichway_ipadAppDelegate *appdelegate = (whichway_ipadAppDelegate *)[[UIApplication sharedApplication] delegate];
float closest_distance;
int linecnt = 1;
NSDictionary *tmpDict = [[[NSDictionary alloc] init] autorelease];
for (NSDictionary *store in appdelegate.dataset) {
NSString *latlong = [store objectForKey:@"LatLong"];
NSArray *latlongarray = [latlong componentsSeparatedByString:@","];
function Timer(millis, callback, _params) {
var params = $.extend(_params,{repeat: true,context: this})
this.interval = millis;
this.repeat = params.repeat;
this.context = params.context;
this.args = params.args;
this.onTimer = callback;
this.callback = $.proxy(this._onTimer, this);
this.single = false;
this._reqs = 0;
// A small variant of Jeff Lamarche code as seen here : http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html
//
// CustomAlertView.m
// Custom Alert View
//
// Created by jeff on 5/17/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if(_reachedEndOfFeed) return;
if(!_dynamicFeed) return;
DLog();
if (!reloading)
{
checkForRefresh = YES; // only check offset when dragging
}
//CORE DATA
//FETCHING PROCESS SNIPPET
NSManagedObjectContext *sharedContext = [(AppDelegate_Shared *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Currency" inManagedObjectContext:sharedContext];
[request setEntity:entity];
currencies = [[NSArray alloc ] initWithArray:[sharedContext executeFetchRequest:request error:nil]];
@logicaroma
logicaroma / LocationServices
Created April 8, 2011 13:07 — forked from nickcharlton/gist:779831
An Objective-C Object for LocationServices
// LocationServices.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface LocationServices : NSObject <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
CLLocation *currentLocation;
@logicaroma
logicaroma / SCAppUtils.h
Created May 11, 2011 22:50 — forked from scelis/SCAppUtils.h
Add a background image to your UINavigationBar.
#import <UIKit/UIKit.h>
#define kSCNavigationBarBackgroundImageTag 6183746
#define kSCNavigationBarTintColor [UIColor colorWithRed:0.54 green:0.18 blue:0.03 alpha:1.0]
@interface SCAppUtils : NSObject
{
}
+ (void)customizeNavigationController:(UINavigationController *)navController;
@logicaroma
logicaroma / gist:967566
Created May 11, 2011 22:50
Remove all the subviews
NSEnumerator *enumerator = [itemViewContainer.subviews objectEnumerator];
UIView *subview;
while (subview = [enumerator nextObject]) {
[subview removeFromSuperview];
}
@logicaroma
logicaroma / Rakefile
Created July 28, 2011 00:38 — forked from jfgomez86/Rakefile
Raketask for generating jsdoc documentation
desc "Generate Documentation"
task :doc do
root = File.dirname __FILE__
perl = %x[which perl].chomp
jsdoc_options = [
"--recursive",
"--directory #{root}/doc",
"--project-name AwesomeProject"
].join(" ")
@logicaroma
logicaroma / gist:1318638
Created October 27, 2011 02:30 — forked from yahelc/gist:1004702
Simpler Twitter Intents / Google Analytics Script
(function(){
var event_names = {
"click" : "" ,
"tweet" : "",
"retweet" : "source_tweet_id",
"follow" : "screen_name",
"favorite" : "tweet_id"
};
for(var event_name in event_names)