12
sudo apt-get install python-pipsudo pip install shadowsocks
1234567891011121314151617181920
#!/bin/bashjson_file="/Users/fang/Lab/Shell/xcassets/Contents.json"orig_path="/Users/fang/Lab/Shell/xcassets/images"dest_path="/Users/fang/Lab/iOS/TestProject/Images.xcassets"imgs=`find $orig_path -name "*@2x.*"`for img in $imgs; do filename=`basename $img` img_name="${filename%@*}" folder="$dest_path/$img_name.imageset" if [ ! -d $folder ]; then mkdir $folder fi cp -r $img $folder cp -r $json_file $folder sed -e 's/\$FILE_NAME/'$img_name'/g' $json_file > "$folder/Contents.json"done
这里不讨论详细设计,只从项目开发角度考虑,关注点为开发效率和稳健性。
APP 使用中最不可容忍的莫过于闪退问题,而许多 crash 源于网络请求的返回值格式非法。
最近在玩 hexo 这个博客框架,有个需求是,在本地用 MarkDown 编辑好文章,能够高效地在服务端发表。于是使用 Shell 写了以下脚本。
hexo
MarkDown
Shell
1234567891011121314151617181920212223242526272829303132333435363738394041
inputFile=$1if [ ! -f $inputFile ]; then echo "缺少文件" exit fishiftwhile echo $1 | grep ^- > /dev/null; do eval $( echo $1 | sed 's/-//g' | tr -d '\012')=$2 shift shiftdonefileName=`basename $inputFile`path="/Users/fang/Workspace/Blog/trunk/hexo/$fileName"# 第一行内容为 ## XXX,其中 XXX 为标题first_line=`head -n 1 $inputFile`title=${first_line#\#\# }# 使用当前的时间作为发布时间myDate=`date "+%Y-%m-%d %H:%M:%S"`echo "title: $title" > $pathecho "date: $myDate" >> $path# 命令行可接受 tags 参数if [ ! -z $tags ]; then echo "tags: $tags" >> $pathfiecho "---" >> $path# 将此前 .md 文件中第一行忽略sed 1d $inputFile >> $pathscp $path xxx@xxxx.com:~/hexo/source/_postsssh xxx@xxxx.com "cd ~/hexo/; hexo generate -d"
参考链接: http://developer.android.com/reference/android/util/DisplayMetrics.html
http://developer.android.com/guide/practices/screens_support.html
脚本如下
123456789101112131415
#!/bin/bashset -efileName=$1if [ -z "$fileName" ]; then echo "Parameters error!" exit fiif [ ! -d classes ]; then mkdir classesficlassName=${fileName%%.*}javac $className.java -d ./classes/java -classpath ./classes $className
textSize 的单位一般使用 sp,sp 与系统字体大小相关,1sp 占据的大小相当于 1d p乘以 fontScale。系统字号为 normal 时,fontScale = 1;字号越大 fontScale 的值越大。
有些情境下,我们希望在 APP 中保持字体的缩放比,而不随系统字体变化而变化。做法有两种: