Skip to content

Instantly share code, notes, and snippets.

View PoomSmart's full-sized avatar
💻

Thatchapon Unprasert PoomSmart

💻
View GitHub Profile
@PoomSmart
PoomSmart / ContainsEmoji.m
Last active April 7, 2023 02:08
Detect if string contains emoji (Using Objective-C and Swift)
#import <UIKit/UIKit.h>
#import <CoreFoundation/CoreFoundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreText/CoreText.h>
@interface EmojiUtilities : NSObject
+ (CFMutableCharacterSetRef)emojiCharacterSet;
+ (BOOL)containsEmoji:(NSString *)emoji;
@end
@PoomSmart
PoomSmart / ProximityLandscape.m
Created June 26, 2015 13:26
Proximity Sensor in Landscape mode.
static void setLandscapeProximityEnabled(BOOL enabled)
{
UIDevice *dev = [UIDevice currentDevice];
if (enabled) {
[dev _setExpectsFaceContactInLandscape:YES];
dev.proximityMonitoringEnabled = YES;
} else {
dev.proximityMonitoringEnabled = NO;
[dev _setExpectsFaceContactInLandscape:NO];
}
@PoomSmart
PoomSmart / FakePush.m
Created May 31, 2015 07:27
Fake Push Notifications for iOS 7+
#import <Foundation/Foundation.h>
// ApplePushService.framework
@interface APSMessage : NSObject
- (id)initWithTopic:(NSString *)topic userInfo:(NSDictionary *)userInfo;
@end
@interface APSIncomingMessage : APSMessage
@end
@PoomSmart
PoomSmart / FlatImageWithColor.m
Last active June 29, 2017 11:29
Reversed function of -[UIImage _flatImageWithColor:] on iOS 7+
#import <UIKit/UIKit.h>
@interface UIImage (FlatImageWithColor)
- (UIImage *)_flatImageWithColor:(UIColor *)color;
@end
@implementation UIImage (FlatImageWithColor)
- (UIImage *)_flatImageWithColor:(UIColor *)color {
UIImage *flatImage = nil;
@PoomSmart
PoomSmart / Method.h
Created March 2, 2015 07:48
A private AVCaptureStillImageOutput method
#import <AVFoundation/AVFoundation.h>
@interface AVCaptureStillImageOutput (PrivateAPI)
- (void)captureStillImageSurfaceAsynchronouslyFromConnection:(AVCaptureConnection *)connection completionHandler:(void (^)(IOSurfaceRef photoSurfaceRef, NSInteger photoSurfaceSize, IOSurfaceRef photoPreviewSurfaceRef, NSInteger photoPreviewSurfaceSize, CFDictionaryRef photoProperties))completionHandler;
@end
@PoomSmart
PoomSmart / CheckRunning.m
Last active August 29, 2015 14:12
(iOS 7+) Check if an application is running by its bundle identifier.
BOOL isRunning(NSString *bundleID)
{
BKSSystemService *systemService = [[BKSSystemService alloc] init];
pid_t pid = [systemService pidForApplication:bundleID];
[systemService release];
return pid != 0;
}