Skip to content

Instantly share code, notes, and snippets.

View annidy's full-sized avatar
💭
I may be slow to respond.

fengxing annidy

💭
I may be slow to respond.
View GitHub Profile
require 'xcodeproj'
project_path = Dir.glob("*.xcodeproj")[0]
project = Xcodeproj::Project.open(project_path)
project.targets.select {
|target| target.name.include? "InHouse"
}.each { |target|
puts "Process " + target.name + "..."
puts "Delete copy phases", target.copy_files_build_phases
target.copy_files_build_phases.each { |phases|
@annidy
annidy / libdispatch-efficiency-tips.md
Created February 27, 2020 01:37 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

I suspect most developers are using the libdispatch inefficiently due to the way it was presented to us at the time it was introduced and for many years after that, and due to the confusing documentation and API. I realized this after reading the 'concurrency' discussion on the swift-evolution mailing-list, in particular the messages from Pierre Habouzit (who is the libdispatch maintainer at Apple) are quite enlightening (and you can also find many tweets from him on the subject).

My take-aways are:

@annidy
annidy / textHeight.m
Created May 22, 2019 13:31 — forked from brennanMKE/textHeight.m
Text Height in Objective-C for NSString and NSAttributedString
- (CGFloat)heightForAttributedString:(NSAttributedString *)text maxWidth:(CGFloat)maxWidth {
if ([text isKindOfClass:[NSString class]] && !text.length) {
// no text means no height
return 0;
}
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading;
CGSize size = [text boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:options context:nil].size;
@annidy
annidy / Python3 HTTP Server.py
Created December 4, 2018 07:02 — forked from Integralist/Python3 HTTP Server.py
Python3 HTTP Server.py
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
HOST_NAME = 'localhost'
PORT_NUMBER = 9000
class MyHandler(BaseHTTPRequestHandler):
def do_HEAD(self):
self.send_response(200)
@annidy
annidy / fps.c
Created March 16, 2018 06:22
快速计算fps
static int counter;
static long counter_ms;
struct timeval time;
long now;
if (counter == 0) {
counter = 1;
gettimeofday(&time, NULL);
counter_ms = (time.tv_sec * 1000) + (time.tv_usec / 1000);
} else if (counter > 100) {
gettimeofday(&time, NULL);
@annidy
annidy / build.sh
Last active March 6, 2018 02:24
general build
#通用iOS工程静态库编译脚本
BUILD_PROJ=$1
BUILD_TARGET=$2
BUILD_OUTPUT=$3
BUILD_CONFIGURATION=$4
BUILD_BIN=xcodebuild
#获取SDK编译版本
BUILD_SDK_VERSION=$(${BUILD_BIN} -showsdks | grep iphoneos | sort -r | head -n 1 | grep -o '.\{4\}$')
if [[ ${BUILD_SDK_VERSION} = "" ]]; then
echo "Error: No iPhone SDK ..."
@annidy
annidy / patch.diff
Created August 15, 2017 02:45
patch for FFmpeg cache on iOS
diff --git a/libavutil/file_open.c b/libavutil/file_open.c
index 34070d933b..f96bdf11ac 100644
--- a/libavutil/file_open.c
+++ b/libavutil/file_open.c
@@ -28,6 +28,9 @@
#if HAVE_IO_H
#include <io.h>
#endif
+#if defined(__APPLE__)
+#include <CoreFoundation/CoreFoundation.h>
@annidy
annidy / AVAsset+VideoOrientation.h
Created April 25, 2017 06:26 — forked from luca-bernardi/AVAsset+VideoOrientation.h
Find the video orientation of an AVAsset. (Useful if you need to send the video to a remote server)
//
// AVAsset+VideoOrientation.h
//
// Created by Luca Bernardi on 19/09/12.
// Copyright (c) 2012 Luca Bernardi. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
typedef enum {
LBVideoOrientationUp, //Device starts recording in Portrait
@annidy
annidy / ctags.setup
Last active March 13, 2017 11:39 — forked from nazgob/ctags.setup
ctags setup on mac
# you have ctags but it does not work...
$ ctags -R --exclude=.git --exclude=log -f .tags *
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
#you need to get new ctags, i recommend homebrew but anything will work
$ brew install ctags
#alias ctags if you used homebrew
$ alias ctags="`brew --prefix`/bin/ctags"
@annidy
annidy / alias.sh
Created March 7, 2017 03:54
echo unicode paste board
alias pbecho='echo -e "`pbpaste`"'