Skip to content

Instantly share code, notes, and snippets.

@edwardean
edwardean / Podfile
Created September 26, 2023 10:16 — forked from Lomiren/Podfile
Inhibit warnings developer pods iOS
# inhibit_all_warnings!
# If you enable inhibit_all_warnings, we will not see warnings from our developer Pods.
# inhibit_all_warnings Оключает отображение warning во всех подключенных Pods. И мы не видим предупреждение в наших developer Pods
# Solution: Disable warning only for third party Pods
# Решение: Отключить показ warning только для сторонних подов
# Solution: for custom pods https://stackoverflow.com/a/44530816
# Решение: для выборочного отключения https://stackoverflow.com/a/44530816
@edwardean
edwardean / UIImage+Draw.m
Created August 6, 2020 11:39 — forked from dklinzh/UIImage+Draw.m
UIImage图形扩展
@implementation UIImage (Draw)
//画一个直角矩形图片
+ (UIImage *)drawRectImageWithColor:(UIColor *)color size:(CGSize)size {
CGRect rect = CGRectMake(0, 0, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
@edwardean
edwardean / NSData+stream.m
Created November 24, 2018 14:09 — forked from fel-cesar/NSData+stream.m
Convert NSInputStream to NSData
+(NSData*) dataWithInputStream:(NSInputStream*) stream {
NSMutableData * data = [NSMutableData data];
[stream open];
NSInteger result;
uint8_t buffer[1024]; // BUFFER_LEN can be any positive integer
while((result = [stream read:buffer maxLength:1024]) != 0) {
if(result > 0) {
// buffer contains result bytes of data to be handled
@edwardean
edwardean / main.m
Created November 24, 2018 02:53 — forked from michaeleisel/main.m
#import <sys/sysctl.h>
static CFTimeInterval processStartTime() {
size_t len = 4;
int mib[len];
struct kinfo_proc kp;
sysctlnametomib("kern.proc.pid", mib, &len);
mib[3] = getpid();
len = sizeof(kp);
@edwardean
edwardean / gist:31b883bd75bd57fbb4d432fc25dff96b
Created September 16, 2018 12:02 — forked from 4PixelsDev/gist:7074661
IOS: Take screenshot
- (UIImage*)screenshot
{
// Create a graphics context with the target size
// On iOS 4 and later, use UIGraphicsBeginImageContextWithOptions to take the scale into consideration
// On iOS prior to 4, fall back to use UIGraphicsBeginImageContext
CGSize imageSize = [[UIScreen mainScreen] bounds].size;
if (NULL != UIGraphicsBeginImageContextWithOptions)
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
else
UIGraphicsBeginImageContext(imageSize);
@edwardean
edwardean / xcode-dev-generate-warnings.sh
Created July 28, 2018 14:28
xcode-enhancement-scripts
# Under the projects folder -> Build Phases -> click on add new build phase on top left corner -> select New Run Script Phase
# Select the Run Script from the dropdown of Build Phase
# let the Shell be the default (/bin/sh)
# Paste below code in the place provided
# This code run every time the project is build
# To create warning (TODO, FIXME) & error msgs (ERROR) comment tags
TAGS="TODO|FIXME"
ERRORTAG="ERROR"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | \
BOOL PSPDFSystemFunctionOverriddenInCategory(Class theClass, SEL selector, NSString *__autoreleasing* categoryName) {
NSCParameterAssert(theClass);
NSCParameterAssert(selector);
Dl_info info;
if (dladdr(class_getMethodImplementation(theClass, selector), &info)) {
// /System/Library/Frameworks is a common denominator, some methods are in /usr/lib/libobjc.A.dylib
// Custom app is in /private/var/mobile/Containers/Bundle/Application/<UID>/PSPDFCatalog.app/PSPDFCatalog
if (!strstr(info.dli_fname, "/System/Library") && !strstr(info.dli_fname, "/usr/lib")) {
if (categoryName) *categoryName = @(info.dli_sname);
@edwardean
edwardean / PSPDF_KEYPATH.m
Created February 6, 2018 05:50 — forked from steipete/PSPDF_KEYPATH.m
PSPDF_KEYPATH without all the warnings
#define PSPDF_KEYPATH(object, property) (^{ \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunreachable-code\"") \
_Pragma("clang diagnostic ignored \"-Wimplicit-retain-self\"") \
return ((void)(NO && ((void)object.property, NO)), @#property); \
_Pragma("clang diagnostic pop") \
}())
@edwardean
edwardean / PSPDFEnvironment.m
Created February 6, 2018 05:50 — forked from steipete/PSPDFEnvironment.m
Example for DISPATCH_SOURCE_TYPE_MEMORYPRESSURE (Mac only, since 10.9) ... Since we share code between iOS and mac, I'm trying to be a good system citizen and reimplement the equivalent of UIApplicationDidReceiveMemoryWarningNotification on the Mac.
NSString *const PSPDFApplicationDidReceiveMemoryWarningNotification = @"PSPDFApplicationDidReceiveMemoryWarningNotification";
// Test with sudo memory_pressure -l critical. Don't forget to re-set afterwards!
__attribute__((constructor)) static void PSPDFInstallLowMemoryNotificationWarningMac(void) {
static dispatch_source_t source;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
dispatch_source_set_event_handler(source, ^{
dispatch_source_memorypressure_flags_t pressureLevel = dispatch_source_get_data(source);
@edwardean
edwardean / linkmap.js
Created February 2, 2018 06:38 — forked from bang590/linkmap.js
XCode Linkmap Parser
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {