Skip to content

Instantly share code, notes, and snippets.

View peerasak-u's full-sized avatar

Peerasak Unsakon peerasak-u

View GitHub Profile
@peerasak-u
peerasak-u / NSShadow Example
Created August 1, 2013 07:29
NSShadow Example
NSShadow *textShadow = [[NSShadow alloc] init];
textShadow.shadowColor = [UIColor darkGrayColor];
textShadow.shadowBlurRadius = 1.2;
textShadow.shadowOffset = CGSizeMake(1,1);
NSDictionary *attributes = @{NSForegroundColorAttributeName: [UIColor blackColor],
NSShadowAttributeName: textShadow
};
@peerasak-u
peerasak-u / NSNumber1
Created August 1, 2013 15:58
NSNumber
NSNumber *number = [NSNumber numberWithInt:512];
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
//iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
//iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
#import <UIKit/UIKit.h>
@interface UILabel (TextKerning)
- (void) setText:(NSString *)text withKerning:(CGFloat)kerning;
- (void) setKerning:(CGFloat)kerning;
@end
#import <UIKit/UIKit.h>
@interface UILabel (TextKerning)
- (void) setText:(NSString *)text withKerning:(CGFloat)kerning;
- (void) setKerning:(CGFloat)kerning;
@end
@peerasak-u
peerasak-u / isBetweenDate
Created August 8, 2013 12:09
How to Check if an NSDate occurs between two other NSDates ?
+ (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate
{
if ([date compare:beginDate] == NSOrderedAscending)
return NO;
if ([date compare:endDate] == NSOrderedDescending)
return NO;
return YES;
}
NSAttributedString *attrStr = ... // your attributed string
CGFloat width = 300; // whatever your desired width is
CGRect rect = [attrStr boundingRectWithSize:CGSizeMake(width, 10000) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
@peerasak-u
peerasak-u / DelegateHelper.h
Created August 23, 2013 05:32
เวลาจะใช้ก็แค่เรียก [[DelegateHelper sharedInstance].delegate delegateHelperSomething]; จบข่าว
#import <Foundation/Foundation.h>
@class DelegateHelper;
@protocol DelegateHelperDelegate <NSObject>
- (void) delegateHelperSomething;
@end
@interface DelegateHelper : NSObject
URL ที่ใช้ Search ในตัวอย่างใช้คำว่า "ลืมไปเลย"
https://www.se-ed.com/product-search/ลืมไปเลย.aspx?keyword=ลืมไปเลย&search=name
URL ของภาพปกหนังสือ
https://se-edws.se-ed.com/Storage/Originals/978616/716/9786167164816L.jpg
ให้ 9786167164816 = หมายเลข ISBN ของหนังสือ
https://se-edws.se-ed.com/Storage/Originals/(ISBN[0->5])/(ISBN[6-8])/(ISBN)L.jpg
@peerasak-u
peerasak-u / soccersuck
Created August 29, 2013 18:15
adBlock List
soccersuck.com##div[style="margin: 0px 0px 2px 10px;"]
soccersuck.com##div[style="margin:2px 0px 0px 2px;"]
soccersuck.com##div[style="width:470px;height:250px;"]
soccersuck.com##div[style="margin:5px 0px 0px 0px;float:left;"]
soccersuck.com##div[class*="adv_A"]
soccersuck.com##div[class*="advD"]
soccersuck.com/ss/ads/*
soccersuck.com/2008/images/banner/*