Skip to content

Instantly share code, notes, and snippets.

@susuyan
susuyan / .travis.yml
Created December 3, 2019 09:04 — forked from aterribili/.travis.yml
iOS + Travis + Fastlane continuous delivery
language: objective-c
os: osx
xcode_workspace: {workspace-name}.xcworkspace
xcode_scheme: {workspace-name}
xcode_sdk: iphonesimulator9.0
osx_image: xcode8
before_install:
- |
brew update
gem install xcpretty -N --no-ri --no-doc
/** A pthread-based recursive mutex lock. */
public class Mutex {
private var mutex: pthread_mutex_t = pthread_mutex_t()
public init() {
var attr: pthread_mutexattr_t = pthread_mutexattr_t()
pthread_mutexattr_init(&attr)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)
let err = pthread_mutex_init(&self.mutex, &attr)
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@susuyan
susuyan / AppVersion.sh
Created August 15, 2019 06:32
Launchscreen.stroyboard 动态版本号
# ON/OFF Script Toggle (script ON with #, script OFF without #)
#exit 0
# Increment Build Number Bool (Increment ON with true, increment OFF with false)
shouldIncrement=true
# App vesion / Build version constants
versionNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
@susuyan
susuyan / Test.h
Created March 9, 2019 09:42
方法执行耗时
clock_t start_time = 0;
clock_t end_time = 0;
start_time = clock();
[self addMultiVatlue:self.phoneNumbers andLabels:self.labels];
end_time = clock();
NSLog(@"PERF: Write one record took %f seconds.", (double)(end_time - start_time) / (double)CLOCKS_PER_SEC);
import UIKit
fileprivate let kRotationAnimationKey = "kRotationAnimationKey.rotation"
open class VGPlayerLoadingIndicator: UIView {
fileprivate let indicatorLayer = CAShapeLayer()
var timingFunction : CAMediaTimingFunction!
var isAnimating = false
@susuyan
susuyan / rows.swift
Created December 18, 2018 09:41
计算行数
let r = entity.eventImage.count % 3
let row = r == 0 ? entity.eventImage.count / 3 : entity.eventImage.count / 3 + 1
@susuyan
susuyan / StringExtenions.swift
Created December 11, 2018 06:20
String nilIfEmpty
extension Optional where Wrapped == String {
var nilIfEmpty: String? {
guard let strongSelf = self else {
return nil
}
return strongSelf.isEmpty ? nil : strongSelf
}
}
guard let title = textField.text.nilIfEmpty else {
import UIKit
protocol UITagViewDelegate: class {
func tagView(_ tagView: UITagView, didTapAt index: Int)
}
class UITagView: UIView {
// 每行數量
@susuyan
susuyan / CustomView.swift
Created November 2, 2018 07:28
自定义 view
class WelfareBuyExchangeView: UIView {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initialize()
}
override init(frame: CGRect) {
super.init(frame: frame)
initialize()