This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/sysctl.h> | |
+ (NSString*)hardwareString | |
{ | |
int name[] = {CTL_HW,HW_MACHINE}; | |
size_t size = 100; | |
sysctl(name, 2, NULL, &size, NULL, 0); // getting size of answer | |
char *hw_machine = malloc(size); | |
sysctl(name, 2, hw_machine, &size, NULL, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <objc/runtime.h> | |
@implementation BaseViewController() | |
- (void)dealloc | |
{ | |
[CATransaction setCompletionBlock:nil]; | |
[NSObject cancelPreviousPerformRequestsWithTarget:self]; | |
[[NSNotificationCenter defaultCenter] removeObserver:self]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [url] : service url | |
// [parameters] : optional parameters | |
// [keyPath] : optional root key to retrieve data | |
// [class] : object class that should return in the array | |
// | |
// eg. [PRHTTPSessionManager loadWithURL:@"http://mioservizio.com" parameters:nil keyPath:nil class:[ProductModel class] completion:.... | |
// eg. [PRHTTPSessionManager loadWithURL:@"http://mioservizio.com" parameters:nil keyPath:@"products.list" class:[ProductModel class] completion:.... | |
// | |
+ (void)loadWithURL:(NSString*)url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UILabel correct way to padding left/right | |
#import <UIKit/UIKit.h> | |
@interface CustomLabel : UILabel | |
@property (nonatomic, assign) UIEdgeInsets edgeInsets; | |
@end | |
#import "CustomLabel.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// performance examination procedure | |
#ifdef DEBUG | |
double then, now; | |
now = CFAbsoluteTimeGetCurrent(); | |
#endif | |
// | |
// TODO: your code here | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <zlib.h> | |
- (NSUInteger)crc32 | |
{ | |
// the object requires NSObject-Coding https://github.com/priore/NSObject-Coding | |
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self]; | |
return crc32(0, data.bytes, data.length); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef dispatch_cancellable_block_h | |
#define dispatch_cancellable_block_h | |
#import <Foundation/Foundation.h> | |
// https://github.com/SebastienThiebaud/dispatch_cancelable_block/issues/2 | |
typedef void(^dispatch_cancelable_block_t)(BOOL cancel); | |
NS_INLINE dispatch_cancelable_block_t dispatch_after_delay(NSTimeInterval delay, dispatch_block_t block) { | |
if (block == nil) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ViewController () <UIScrollViewDelegate> | |
{ | |
CGFloat initialContentOffset; | |
CGFloat previousContentDelta; | |
} | |
@property (nonatomic, assign) CGFloat senseValue; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Danilo Priore on 18/08/12. | |
// Copyright (c) 2012 Prioregroup.com. All rights reserved. | |
// | |
- (UIImage*)addTextToImage:(UIImage*)img text:(NSString*)text1 XPos:(int)xpos YPos:(int)ypos fontName:(NSString*)fontName fontSize:(CGFloat)fontSize fontColor:(UIColor*)fontColor { | |
int w = img.size.width; | |
int h = img.size.height; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Before create a HTML file named mywidget.html and with content : | |
// <html> | |
// <head> | |
// <title></title> | |
// <script src="http://platform.twitter.com/widgets.js"> </script> | |
// </head> | |
// <body> | |
// <a class="twitter-timeline" height="%i" href="https://mobile.twitter.com/DaniloPriore" data-widget id="318522515175645184" data-chrome="noheader nofooter transparent" data-border-color="#cc0000" style="display:none"> </a> | |
// </body> | |
//</html> |