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
@annidy
annidy / map.lua
Last active May 4, 2018 02:37
Xcode link map文件的lua分析脚本
#!/usr/bin/env lua
-- http://www.jianshu.com/p/92a041b1b825
obj_tbl = {} -- {[3]={file, module}}
syb_tbl = {} -- {[3]=47}
filter_tbl = nil -- {'Test.o'}
appname = nil
function process_object(line)
@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`"'
static char *url_escape(char *path, int len) {
char *org_path = strdup(path);
memset(path, 0, len);
char *enc = path;
for (char *s = org_path; *s && (enc - path < len - 3); s++) {
if (strchr("!*'();:@&=+$,/?%%#[]", *s) != NULL) {
sprintf(enc, "%%%02X", *s);
} else {
sprintf(enc, "%c", *s);
}
@annidy
annidy / varint.lua
Last active August 16, 2016 12:44
sqlite变长整数
function varint_decode(...)
t = 0
l = 0
for _, i in ipairs{...} do
t = t*128 + bit32.extract(i, 0, 7)
l = l + 1
if bit32.btest(i, 7) == false then
break
end
end
@annidy
annidy / main.c
Last active May 13, 2016 15:45
leetcode binary tree loader
// create by annidy
// 2016-05-13
#include <stdio.h>
#include <utlist.h>
#include <string.h>
#include <stdlib.h>
struct TreeNode {
int val;
struct TreeNode *left;