Skip to content

Instantly share code, notes, and snippets.

View wuchuwuyou's full-sized avatar

Murphy wuchuwuyou

View GitHub Profile
@wuchuwuyou
wuchuwuyou / AppDelegate.m
Last active August 8, 2018 10:53
crash report 崩溃记录
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
InstallSignalHandler();
InstallUncaughtExceptionHandler();
}
typedef struct Test
{
int a;
int b;
}Test;
@wuchuwuyou
wuchuwuyou / osx_dmg_package
Created May 30, 2018 10:06 — forked from 44510/osx_dmg_package
mac osx 程序自动打包为 dmg 文件的脚本
set -e
title='千尋影視' # dmg 文件 mount 了之后在文件系统中显示的名称
background_picture_name='mac-dmg-bg.png' # dmg 文件在 mount 了之后界面中显示的背景图片路径
application_name='千尋影視.app' # 应用程序的名称
# Developer ID 证书的名称(名字的一部分即可,但是需要能在 Keychain Access 中唯一定位到该证书)
developer_id='Developer ID Application: Shanghai Truecolor Multimedia'
# dmg 窗口相关的一些设置,需要根据实际情况做变更
window_left=200 # 窗口位置的 x 坐标
@wuchuwuyou
wuchuwuyou / FileMD5
Created February 8, 2018 02:26
获取文件MD5
#define FileHashDefaultChunkSizeForReadingData 1024*8
#include <CommonCrypto/CommonDigest.h>
+ (NSString*)getFileMD5WithPath:(NSString*)path
{
return (__bridge_transfer NSString *)FileMD5HashCreateWithPath((__bridge CFStringRef)path, FileHashDefaultChunkSizeForReadingData);
}
CFStringRef FileMD5HashCreateWithPath(CFStringRef filePath,size_t chunkSizeForReadingData) {
// Declare needed variables
@wuchuwuyou
wuchuwuyou / compare_version
Created December 29, 2017 06:34
版本号比较
NSString *num1 = @"2.7.14.2345";
NSString *num2 = @"2.12.8.1234";
//2.7.14.2345
// 2.12.8.1234
if ([num1 compare:num2 options:NSNumericSearch] == NSOrderedDescending) {
NSLog(@"%@ is bigger",num1);
}else
{
NSLog(@"%@ is bigger",num2);
}
@wuchuwuyou
wuchuwuyou / FPSLabel.swift
Created November 16, 2017 08:28
FPSLabel
//
// FPSLabel.swift
// SAC
//
// Created by SAGESSE on 2/1/16.
// Copyright © 2016-2017 Sagesse. All rights reserved.
//
// Reference: ibireme/YYKit/YYFPSLabel
//
@wuchuwuyou
wuchuwuyou / NSRunLoop
Created November 16, 2017 08:22
runloop 阻塞线程
@implementation ViewController{
BOOL end;
}
– (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@”start new thread …”);
[NSThread detachNewThreadSelector:@selector(runOnNewThread) toTarget:self withObject:nil];
while (!end) {
@wuchuwuyou
wuchuwuyou / Accept-Language
Last active November 16, 2017 08:24
Accept-Language 设置HTTP Header 接受语言
[request setValue:[NSString stringWithFormat:@"%@", [[NSLocale preferredLanguages] componentsJoinedByString:@", "]], forHTTPHeaderField:@"Accept-Language"];
@wuchuwuyou
wuchuwuyou / UITextView placeHolder
Created November 3, 2017 07:59
UITextView placeHolder
UILabel *placeHolderLabel = [[UILabel alloc] init];
placeHolderLabel.text = LDLocalizedString(@"xxxxxxxxx");
placeHolderLabel.numberOfLines = 0;
placeHolderLabel.textColor = [UIColor lightGrayColor];
[placeHolderLabel sizeToFit];
[self.userTextView addSubview:placeHolderLabel];
// same font
placeHolderLabel.font = self.userTextView.font;
@wuchuwuyou
wuchuwuyou / dispath_queue_t
Created November 3, 2017 07:42
dispath_queue_t
static dispatch_queue_t get_queue() {
static dispatch_queue_t queue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dispatch_queue_attr_t attr = DISPATCH_QUEUE_SERIAL;
if (NSFoundationVersionNumber >= NSFoundationVersionNumber_With_QoS_Available) {
attr = dispatch_queue_attr_make_with_qos_class(attr, QOS_CLASS_BACKGROUND, 0);
}
queue = dispatch_queue_create("xxxx.yyy.zzz", attr);
});
@interface UIImage (fixOrientation)
- (UIImage *)fixOrientation;
@end