Skip to content

Instantly share code, notes, and snippets.

Avatar

Chengfei Xiao crespoxiao

View GitHub Profile
@crespoxiao
crespoxiao / gist:e5ec18352d6f59dadf482620dbc53894
Created Jan 31, 2018
Showing TODO as warning in Xcode project
View gist:e5ec18352d6f59dadf482620dbc53894
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
View gist:79043445cbfff77bf6cb07ef822bb8cf
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
View gist:28c7267cf50fdd87ca30691312c92987
#!/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 Sep 22, 2017
fix App Icons not included in build from Xcode 9 With CocoaPods
View gist:fbd900cf537229fdcf736dfa377d5c7b
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
View gist:82c2fcc0fd08132e8b49e5116b282ab8
#!/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 Apr 21, 2017 — forked from floriankugler/gist:6870499
Mapping of NSURLConnection to NSURLSession delegate methods. Created by Mattt Thompson.
View gist:d39b31eb96afcd03e6ab7adfa67dcc2c
NSURLConnection | NSURLSession
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connectionShouldUseCredentialStorage: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler:
| N
View Find Unused Images in Xcode Project
#!/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"
View gist:b3ff8014d14b467a18a5f1394653c2cc
#import <Foundation/Foundation.h>
@interface NSString (CFXValidateURL)
- (BOOL)cfx_validateUrl;
- (BOOL)cfx_validateUrl_RegEx;
@end
View gist:59d42266d7f7d8bd217c2947dc54755f
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 Sep 7, 2016
example shell for batch rename files (change the first 4 char of file name to DRC)
View gist:3d033f71e9a94ce7b5a9bb48ca29dc34
#!/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