Skip to content

Instantly share code, notes, and snippets.

View PoomSmart's full-sized avatar
💻

Thatchapon Unprasert PoomSmart

💻
View GitHub Profile
@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;
}
@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 / 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 / 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 / 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 / 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 / commands.sh
Created July 8, 2018 11:09 — forked from JohnCoates/commands.sh
THEOS on Windows 10 with Linux subsystem
# Turn on Developer Mode
# Open Settings -> Update and Security -> For developers
# Don't reboot yet
# Run in powershell administrator:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# accept reboot
## Install Ubuntu
# run in powershell administrator:
@PoomSmart
PoomSmart / sort3.asm
Last active February 14, 2025 07:49
Shortest Code to Sort 3 Numbers known to man?
%include "asm_io.inc"
extern _printf
segment data align=4 class=data use32
EnterOne db "Enter number 1: ", 0
EnterTwo db "Enter number 2: ", 0
EnterThree db "Enter number 3: ", 0
FormattedAnswer db "%d %d %d", 0
@PoomSmart
PoomSmart / enable-text-recognition.sh
Last active August 19, 2021 04:53
Enable Live Text Recognition on Intel-based Mac running macOS Monterey (12.0b1)
#!/bin/bash
APP_TARGETS=(com.apple.Photos com.apple.Preview com.apple.quicklook.QuickLookUIService com.apple.Safari)
for APP_TARGET in "${APP_TARGETS[@]}"
do
defaults write /Users/$USER/Library/Containers/$APP_TARGET/Data/Library/Preferences/com.apple.VisionKit.InternalSettings com.apple.VisionKit.InternalSettings.overrideDeviceAvailability -bool yes
done
@PoomSmart
PoomSmart / ActionSheet.m
Created July 13, 2021 12:52
YouTube action sheet and notification things
@interface YTUIUtils : NSObject
+ (UIViewController *)topViewControllerForPresenting;
@end
@interface YTUIResources : NSObject
+ (UIImage *)iconCheckTemplateImage;
+ (UIImage *)actionsheetDefaultImage;
@end
@interface YTActionSheetAction : NSObject