Skip to content

Instantly share code, notes, and snippets.

View zhaozzq's full-sized avatar
😜
I may be slow to respond.

Zhao zhaozzq

😜
I may be slow to respond.
View GitHub Profile
@zhaozzq
zhaozzq / UIView+ZQPlus.h
Created April 1, 2017 03:53
UIView Category
#import <UIKit/UIKit.h>
@interface UIView (ZQPlus)
@property (assign, nonatomic) CGFloat x;
@property (assign, nonatomic) CGFloat y;
@property (assign, nonatomic) CGFloat width;
@property (assign, nonatomic) CGFloat height;
@property (assign, nonatomic) CGSize size;
- (void)addGradientLayerWithColors:(NSArray *)cgColorArray locations:(NSArray *)floatNumArray startPoint:(CGPoint )startPoint endPoint:(CGPoint)endPoint;
@zhaozzq
zhaozzq / 打电话
Last active July 10, 2017 06:48
Generated by Xgist (https://github.com/Bunn/Xgist) at 2017年7月10日 下午2:45:32
+ (void)callNumber:(NSString *)number
{
NSURL *tel = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",number]];
if (OSLeastIOS10) {
[[UIApplication sharedApplication] openURL:tel options:@{} completionHandler:nil];
}else{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] openURL:tel];
#pragma clang diagnostic pop
  • 添加 origin
git remote add origin path/to/repository
  • If you want to merge project-a into project-b:
cd path/to/project-b
git remote add project-a path/to/project-a
git fetch project-a
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge
@zhaozzq
zhaozzq / inject.markdown
Last active March 30, 2021 12:39
Inject js to WKWebView
WKWebViewConfiguration *configuration = [WKWebViewConfiguration new];
NSString *eruda = @"(function () { var script = document.createElement('script'); script.src='//cdn.jsdelivr.net/npm/eruda'; document.body.appendChild(script); script.onload = function () { eruda.init() } })();";
WKUserScript *script = [[WKUserScript alloc] initWithSource:eruda injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO];
[configuration.userContentController addUserScript:script];
_webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];

or

NSString *jsPath = [[NSBundle mainBundle] pathForResource:@"vConsole" ofType:@"js"];
@zhaozzq
zhaozzq / codeshortcuts.py
Created June 27, 2018 03:13
VS Code 快捷键
# Duplicate Lines
# Shift + Option + Up Down Arrow Keys
# Move line up or down
# Alt / Option + Up Down Arrow Keys
# Write on multiple lines (without mouse)
# Shift + Option + Command + Up Down Arrow Keys
# Write on multiple lines (with mouse)
@zhaozzq
zhaozzq / UIButton+VerticalLayout.m
Created August 17, 2018 02:31 — forked from lucaspang/UIButton+VerticalLayout.m
iOS UIButton center Image and Text Vertically
@interface UIButton (VerticalLayout)
- (void)centerVerticallyWithPadding:(float)padding;
- (void)centerVertically;
@end
@implementation UIButton (VerticalLayout)
- (void)centerVerticallyWithPadding:(float)padding
func switchRootViewController(rootViewController: UIViewController, animated: Bool, completion: (() -> Void)?) {
if animated {
UIView.transitionWithView(window, duration: 0.5, options: .TransitionCrossDissolve, animations: {
let oldState: Bool = UIView.areAnimationsEnabled()
UIView.setAnimationsEnabled(false)
self.window!.rootViewController = rootViewController
UIView.setAnimationsEnabled(oldState)
}, completion: { (finished: Bool) -> () in
if completion {
completion!()
@zhaozzq
zhaozzq / open_xcode_project.sh
Created March 6, 2019 08:11
SourceTree Custom Action
#仓库路径
REPO_PATH=$1
#文件的类型
# OPEN_TYPE=$2
LIST=`find "$REPO_PATH" -name "*.xcworkspace" | grep -v ".xcodeproj/project.xcworkspace"`
if [ -z "$LIST" ] ; then
LIST=`find "$REPO_PATH" -name "*.xcodeproj" | grep -v "Pods.xcodeproj"`
fi
@zhaozzq
zhaozzq / 设置git代理.md
Last active January 26, 2024 10:53 — forked from chuyik/README.md
macOS 给 Git(Github) 设置代理(HTTP/SSH)
@zhaozzq
zhaozzq / Dictionary+KeyPaths.swift
Created July 31, 2019 10:14
Accessing Dictionaries with Key Paths
//
// DictionaryExtension.swift
// Haiyu
// zhao_zzq2012@163.com
// Created by zhaozzq@github on 2019/7/31.
// Copyright © 2019 Haiyu. All rights reserved.
// https://oleb.net/blog/2017/01/dictionary-key-paths/
// https://swift.gg/2017/01/25/dictionary-key-paths/
import Foundation