Skip to content

Instantly share code, notes, and snippets.

View tangzhen's full-sized avatar
🎯
Focusing

Zhen Tang tangzhen

🎯
Focusing
  • Chengdu, Sichuan, China
View GitHub Profile
@tangzhen
tangzhen / Count lines of code in Xcode project
Created July 27, 2017 06:42 — forked from Tokuriku/Count lines of code in Xcode project
Count lines of code in SWIFT Xcode project
1. Open Terminal
2. cd to your Xcode project
3. Execute the following when inside your target project:
find . -name "*.swift" -print0 | xargs -0 wc -l
# Check out editorconfig.org for the deets
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@tangzhen
tangzhen / optional.feature
Created July 10, 2016 01:18 — forked from basti1302/optional.feature
Use an optional parameter in Cucumber
Feature: Optional parameter
Scenario: Use an optional parameter
When I execute a step
When I execute a step with the optional parameter whatever
@tangzhen
tangzhen / ObjectMapper+Alamofire+RxSwift
Last active June 21, 2016 22:05 — forked from billwang1990/ObjectMapper+Alamofire+RxSwift
ObjectMapper+Alamofire+RxSwift
//
// RxAlamofireObjectMapper.swift
//
// Edit by TangZhen on 06/19/16.
// Forked from https://gist.github.com/billwang1990/a0e20919e7add7aafd8e
// Copyright © 2016 ztang.pub All rights reserved.
//
import Foundation
import Alamofire
@tangzhen
tangzhen / image.resize.in.github.flavored.markdown.md
Created February 28, 2016 10:59 — forked from uupaa/image.resize.in.github.flavored.markdown.md
image resize in github flavored markdown.

Image source

https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png

Try resize it!

  • ![](https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png | width=100)
@tangzhen
tangzhen / better-nodejs-require-paths.md
Created January 10, 2016 04:12 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@tangzhen
tangzhen / ServerUtil.java
Last active November 16, 2015 14:12 — forked from dominicbartl/ServerUtil.java
Inject dynamic host IP address in with Gradle
private static final String HOST_EMULATOR = "10.0.2.2";
private static final String HOST_PRODUCTION = "example.com";
public static String getHost() {
if (BuildConfig.DEBUG) {
return (Build.PRODUCT).contains("sdk") ? HOST_EMULATOR : BuildConfig.LOCAL_IP;
}
return HOST_PRODUCTION;
}
@tangzhen
tangzhen / atom_package.txt
Last active August 29, 2015 14:17
atom package
apm install angularjs
apm install atom-alignment
apm install autocomplete-plus
apm install autoprefixer
apm install change-case
apm install color-picker
apm install csscomb
apm install csslint
apm install editor-stats
apm install editorconfig
diff --git a/cordova-lib/src/cordova/platformsConfig.json b/cordova-lib/src/cordova/platformsConfig.json
index d8f85d0..4aa53e8 100644
--- a/cordova-lib/src/cordova/platformsConfig.json
+++ b/cordova-lib/src/cordova/platformsConfig.json
@@ -5,6 +5,12 @@
"url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git",
"version": "3.7.0"
},
+ "osx" : {
+ "hostos" : ["darwin"],
@tangzhen
tangzhen / promise-loop.js
Last active September 5, 2021 14:00
javascript promise while loop
'use strict';
// ref: http://blog.victorquinn.com/javascript-promise-while-loop
var q = require('bluebird');
var promiseWhile = function (condition, action) {
var resolver = q.defer();
var loop = function () {