Skip to content

Instantly share code, notes, and snippets.

@wenghengcong
wenghengcong / .eslintrc-parameter-instruction.js
Created November 23, 2019 12:13 — forked from rswanderer/.eslintrc-parameter-instruction.js
ESLint配置文件.eslintrc参数说明
/*
* ESLint的JSON文件是允许JavaScript注释的,但在gist里显示效果不好,所以我把.json文件后缀改为了.js
*/
/*
* ESLint 配置文件优先级:
* .eslintrc.js(输出一个配置对象)
* .eslintrc.yaml
* .eslintrc.yml
@wenghengcong
wenghengcong / 系统宏
Last active July 11, 2019 10:41
SDWebImage
#import <TargetConditionals.h>
#ifdef __OBJC_GC__
#error SDWebImage does not support Objective-C Garbage Collection
#endif
// Seems like TARGET_OS_MAC is always defined (on all platforms).
// To determine if we are running on macOS, use TARGET_OS_OSX in Xcode 8
#if TARGET_OS_OSX
#define SD_MAC 1
@wenghengcong
wenghengcong / Dispatch
Last active July 11, 2019 12:08
宏和关键字
1. 主线程安全执行- source:SDWebImage
dispatch_main_async_safe
#ifndef dispatch_main_async_safe
#define dispatch_main_async_safe(block)\
if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue())) {\
block();\
} else {\
dispatch_async(dispatch_get_main_queue(), block);\
}
[textField setValue:[UIFont systemFontOfSize:25.0] forKeyPath:@"_placeholderLabel.font"];
获取空间内部属性:
unsigned int count = 0;
objc_property_t *properties = class_copyPropertyList([UITextField class], &count);
for (int i = 0; i < count; i++) {
objc_property_t property = properties[i];
const char *name = property_getName(property);
NSLog(@"name:%s",name);
}
# Type a script or drag a script file from your workspace to insert its path.
# Sets the target folders and the final framework product.
# 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME
# 例如: FMK_NAME = "MyFramework"
FMK_NAME=${PROJECT_NAME}
# Install dir will be the final output to the framework.
# The following line create it in the root folder of the current project.
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework
# Working dir will be deleted after the framework creation.
@wenghengcong
wenghengcong / 创建
Created May 17, 2019 01:36
WKWebView
NSString *backGroundColorSource = @"document.body.style.background = \"#ffffff\"";
WKUserScript *backGroundColorUserScript = [[WKUserScript alloc] initWithSource:backGroundColorSource injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
WKUserContentController *userController = [[WKUserContentController alloc] init];
[userController addUserScript:backGroundColorUserScript];
WKPreferences *preference = [[WKPreferences alloc] init];
preference.minimumFontSize = 25;
@wenghengcong
wenghengcong / 规则
Created May 10, 2019 02:09
[ShadowSocks 自定义规则]
规则大概描述如下
通配符支持,如 *.example.com/* 实际书写时可省略 * 如 .example.com/ 意即 *.example.com/*
正则表达式支持,以\开始和结束, 如 [\w]+://example.com\
例外规则 @@,如 @@.example.com/ 满足@@后规则的地址不使用代理
匹配地址开始和结尾 |,如 |http://example.com、example.com| 分别表示以 http://example.com 开始和以 example.com 结束的地址
|| 标记,如 ||example.com 则 http://example.com 、example.com 、ftp://example.com 等地址均满足条件,只用于匹配地址开头
注释 ! 如 ! Comment
分隔符^,表示除了字母、数字或者 _ - . % 之外的任何字符。如 http://example.com^ ,http://example.com 和 http://example.com:8000 均满足条件,而 http://example.com.ar 不满足条件
如何使用自定义规则
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if (!self.isUserInteractionEnabled || self.isHidden || self.alpha <= 0.01) return nil;
CGFloat inset = 45.0f - 78.0f;
CGRect touchRect = CGRectInset(self.bounds, inset, inset);
if (CGRectContainsPoint(touchRect, point)) {
for (UIView *subview in [self.subviews reverseObjectEnumerator]) {
CGPoint convertedPoint = [subview convertPoint:point fromView:self];
UIView *hitTestView = [subview hitTest:convertedPoint withEvent:event];
@wenghengcong
wenghengcong / 语法
Created May 7, 2019 13:07
Block #Objective-C
As a local variable:
returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
As a property:
@property (nonatomic, copy, nullability) returnType (^blockName)(parameterTypes);
As a method parameter:
- (void)someMethodThatTakesABlock:(returnType (^nullability)(parameterTypes))blockName;
https://www.yiibai.com/sql/sql-having.html
Where和Having的异同
(1)where是查询返回结果之前进行过滤的
(2)having是查询返回结果之后,对结果进行过滤的
(3)在SQL中增加 HAVING 子句原因是,where关键字无法与聚合函数一起使用,having子句常跟group by一同使用,过滤分组后的数据