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:@","];
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(keyboardWillHide:)
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;
@logicaroma
logicaroma / CLLocation(Strings) an Object-C Category for returning NSString values used iOS Sample Project LocateMe
Created April 8, 2011 09:37
A Helper Class which is used in the iOS Sample Project LocateMe. It basically extends the CLLocation with NSString representation.
#import "CLLocation (Strings).h"
@implementation CLLocation (Strings)
- (NSString *)localizedCoordinateString {
if (self.horizontalAccuracy < 0) {
return NSLocalizedString(@"DataUnavailable", @"DataUnavailable");
}
NSString *latString = (self.coordinate.latitude < 0) ? NSLocalizedString(@"South", @"South") : NSLocalizedString(@"North", @"North");
// 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 / Valid xhtml 1.0 Strict Table Template
Created April 12, 2011 15:31
You can read more about xhtml table markup in HTML Dog’s Table Section. I have tested the tables below in Mozilla Firefox 3, IE 6 and 7, Opera 9.x and Safari.
<!-- Table markup-->
<table id="...">
<!-- Table header -->
<thead>
<tr>
<th scope="col" id="...">...</th>
...
@logicaroma
logicaroma / print.css
Created April 13, 2011 15:00
Stylesheet Template for printing a page import using: <link rel="stylesheet" href="print.css" type="text/css" media="print" />
/*
*
* R.Mohammadi
* 13-04-2011
import using: <link rel="stylesheet" href="print.css" type="text/css" media="print" />
*/
/* Remove unwanted elements */
#header, #nav, .noprint
{
display: none;