Skip to content

Instantly share code, notes, and snippets.

@JigsChanchiya
JigsChanchiya / macro.mm
Last active January 13, 2016 05:28
macro
typedef enum {
NotiContact=0,
NotiChatNoti,
NotiMyNoti
} NotiSelect;
//Colors
#define COLOR(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define COLOR_BACKGROUND [UIColor colorWithRed:(230.0/255) green:(224.0/255) blue:(202.0/255) alpha:1.0]
@JigsChanchiya
JigsChanchiya / suffixDate.mm
Last active January 28, 2016 02:52
date formatting with suffix
-(NSString *)StringFromDate:(NSDate *)DateLocal{
NSDateFormatter *prefixDateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[prefixDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[prefixDateFormatter setDateFormat:@"MMMM d., yyyy"];//June 13th, 2013
NSString * prefixDateString = [prefixDateFormatter stringFromDate:DateLocal];
NSDateFormatter *monthDayFormatter = [[[NSDateFormatter alloc] init] autorelease];
[monthDayFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[monthDayFormatter setDateFormat:@"d"];
int date_day = [[monthDayFormatter stringFromDate:DateLocal] intValue];
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@JigsChanchiya
JigsChanchiya / DBHelper+CoreData.mm
Created June 4, 2013 05:50
Coredata helper methods in objective-c
#pragma mark -
#pragma mark - Creating Object
-(id)createObjectForEntity:(NSString *)entityName
{
if (entityName!=nil || [entityName isEqualToString:@""])
{
return [NSEntityDescription
insertNewObjectForEntityForName:entityName
inManagedObjectContext:appDelegate.managedObjectContext];
@JigsChanchiya
JigsChanchiya / Scale+Rotate+UIImage.mm
Last active December 17, 2015 22:39
Scale and Rotate UIImage
# pragma mark -
# pragma mark - Scale and Rotate according to Orientation
- (UIImage *)scaleAndRotateImage:(UIImage *)image
{
int kMaxResolution = 450; // Or whatever
CGImageRef imgRef = image.CGImage;
CGFloat width = CGImageGetWidth(imgRef);