Skip to content

Instantly share code, notes, and snippets.

View crespoxiao's full-sized avatar

Chengfei Xiao crespoxiao

View GitHub Profile
@crespoxiao
crespoxiao / gist:e5ec18352d6f59dadf482620dbc53894
Created January 31, 2018 08:38
Showing TODO as warning in Xcode project
1. solution 1 --- add run script
TAGS="TODO:|FIXME:|XXX:"
echo "searching patch is ${SRCROOT}"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
2. solution 2 --- by code
#define STRINGIFY(S) #S
@crespoxiao
crespoxiao / gist:79043445cbfff77bf6cb07ef822bb8cf
Created December 5, 2017 01:54
iOS 命令行获取设备 UDID
1. 获取真机 udid
1)
system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'
2)
system_profiler SPUSBDataType | sed -n -E -e '/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)/\1/p'
3)
#!/bin/bash
@crespoxiao
crespoxiao / gist:28c7267cf50fdd87ca30691312c92987
Created November 13, 2017 12:30
bitcode opencore-amr-iOS
#!/bin/sh
### Modified from http://blog.csdn.net/favormm/article/details/6772097
set -xe
DEVELOPER=`xcode-select -print-path`
DEST=`pwd .`"/opencore-amr-iOS"
ARCHS="i386 x86_64 armv7 armv7s arm64"
LIBS="libopencore-amrnb.a libopencore-amrwb.a"
# Note that AMR-NB is for narrow band http://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec
@crespoxiao
crespoxiao / gist:fbd900cf537229fdcf736dfa377d5c7b
Created September 22, 2017 12:10
fix App Icons not included in build from Xcode 9 With CocoaPods
post_install do |installer|
copy_pods_resources_path = "Pods/Target Support Files/Pods-XXX/Pods-XXX-resources.sh"
string_to_replace = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"'
assets_compile_with_app_icon_arguments = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${BUILD_DIR}/assetcatalog_generated_info.plist"'
text = File.read(copy_pods_resources_path)
new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
File.open(copy_pods_resources_path, "w") {|file| file.puts new_contents }
end
#!/bin/bash
#
# 需要安装 Ghostscript,brew install gs
# 使用示例 ./pdf2png.sh xx.xcassets
# TODO: 递归遍历目录,实现全自动化
if [[ $# < 1 ]]; then
echo "Usage:" >&1
echo " convert-assets /assets " >&1
exit 1
@crespoxiao
crespoxiao / gist:d39b31eb96afcd03e6ab7adfa67dcc2c
Created April 21, 2017 10:28 — forked from floriankugler/gist:6870499
Mapping of NSURLConnection to NSURLSession delegate methods. Created by Mattt Thompson.
NSURLConnection | NSURLSession
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connectionShouldUseCredentialStorage: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler:
| N
#!/bin/sh
PROGNAME=$(basename "$0")
PROGDIR=$(dirname "$0")
usage()
{
echo "Usage: $PROGNAME [option] -p path-of-project"
echo ""
echo "-p Specifyed the path of your project"
#import <Foundation/Foundation.h>
@interface NSString (CFXValidateURL)
- (BOOL)cfx_validateUrl;
- (BOOL)cfx_validateUrl_RegEx;
@end
import tinify
import os
import os.path
import sys
print "file name:", sys.argv[0]
for i in range(1, len(sys.argv)):
print "para:", i, sys.argv[i]
sourceFilePath = sys.argv[1] # source path
@crespoxiao
crespoxiao / gist:3d033f71e9a94ce7b5a9bb48ca29dc34
Last active September 7, 2016 03:34
example shell for batch rename files (change the first 4 char of file name to DRC)
#!/bin/bash
currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
echo "current path is:"$currentDir;
list_alldir(){
for file2 in `ls -a $1`
do
if [ x"$file2" != x"." -a x"$file2" != x".." ];then