Skip to content

Instantly share code, notes, and snippets.

Avatar

Sergey makoni

View GitHub Profile
@makoni
makoni / gist:5953114
Last active December 19, 2015 12:09
Detecting Map Changing for Google Maps SDK for iOS
View gist:5953114
// где-то в коде проекта
panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(mapDidChange:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
GoogleMapsView.gestureRecognizers = @[panRecognizer]; // GoogleMapsView это гуглокарта, класс GMSMapView
//.. метод, реагирующий на отпускание касания
-(void)mapDidChange:(UIPanGestureRecognizer *)pan {
if ( panRecognizer.state == UIGestureRecognizerStateBegan ) {
// ничего не делать, но можно и что-нибудь делать
@makoni
makoni / gist:5952986
Last active December 19, 2015 12:09
uniqueIdentifier replacement
View gist:5952986
NSString *uuid = @"";
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
// This is will run if it is iOS6 or later
uuid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
id uuidId = [defaults objectForKey:@"deviceUuid"];
if (uuidId)
uuid = (NSString *)uuidId;
@makoni
makoni / gist:4541756
Created January 15, 2013 20:29
Simple CouchDB view function
View gist:4541756
function(doc) {
emit(doc.url, doc);
}
@makoni
makoni / gist:4345440
Last active December 9, 2015 23:39
simple php-script for couchdb views building. all views in all databases.
View gist:4345440
<?php
set_time_limit( 0 );
// all dbs
$ch = prepareCurlResource();
curl_setopt( $ch, CURLOPT_URL, 'http://localhost:5984/_all_dbs' );
$data = curl_exec( $ch );
$dbs = json_decode( $data );
@makoni
makoni / gist:4328922
Created December 18, 2012 15:24
AsynchronousUIImage loading
View gist:4328922
- (void)loadImageFromURL:(NSString *)anUrl {
anUrl = [anUrl stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:anUrl]
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30.0];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
@makoni
makoni / gist:2225182
Created March 28, 2012 10:07
jQuery Sticky Scroller Example
View gist:2225182
var scroller = new StickyScroller("#menu",
{
start: 270,
end: 50800,
interval: 200,
range: 100,
margin: 0
});
@makoni
makoni / gist:2127026
Created March 19, 2012 20:53
Detecting Retina Display on iPad
View gist:2127026
CGRect screenBounds = [[UIScreen mainScreen] bounds];
NSLog(@"%f x %f", screenBounds.size.width, screenBounds.size.height);
CGFloat screenScale = [[UIScreen mainScreen] scale];
NSLog(@"%f", screenScale);
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
NSLog(@"%f x %f", screenSize.width, screenSize.height);
@makoni
makoni / gist:1605260
Created January 13, 2012 09:21
Prefix.pch Example
View gist:1605260
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "YourEverywhereNeededClass.h"
View gist:1310439
#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@makoni
makoni / gist:1230490
Created September 20, 2011 21:42
Importing MapKit framework in controller
View gist:1230490
#import <UIKit/UIKit.h>
// импортируем фреймворк
#import <MapKit/MapKit.h>
// добавляем <MKMapViewDelegate> - протокол класса MKMapView
@interface mapKitViewController : UIViewController <MKMapViewDelegate> {
// создаём MKMapView в контроллере
MKMapView *mapView;
}