2014年1月21日 星期二

iOS Packet Tracking via USB

Get UDID
system_profiler SPUSBDataType
Serial Number: XXXXXXXXXXXXXXXXXXXXXXXXXX

List
rvictl -l

Start
rvictl -s XXXXXXXXXXXXXXXXXXXXXXXXXX

Stop
rvictl -x XXXXXXXXXXXXXXXXXXXXXXXXXX

ifconfig -l
lo0 gif0 stf0 en0 en1 fw0 en3 p2p0 bridge0 rvi0

if you don't have the interface rvi0 
ifconfig rvi0

Run tcpdump
tcpdump -i rvi0 -n -t -q -A tcp
tcpdump -i rvi0 -n -t -l -s 1024 -q -A 'tcp port 80'  > tcpdump

Just for GoogleAnalytics-iOS-SDK 2.x
// realtime tracking
[GAI sharedInstance].dispatchInterval = 0;
// print debug messages
[GAI sharedInstance].debug = YES;
// disable https
[GAI sharedInstance].defaultTracker.useHttps = NO;

[tcpdump]
[remote packet capture]

2013年11月19日 星期二

Full Browser SWF in Flash Gaia Framework

Basic swfobject setting:
100% width
100% height


in as3 code:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;


監聽 Event.RESIZE 事件
stage.addEventListener(Event.RESIZE, onResize);
onResize();


原始文件大小
Gaia.api.getWidth(): The fixed width of document size(1000)
Gaia.api.getHeight(): The fixed height of document size(600)


瀏覽器大小(dynamic)
stage.stageWidth: The width of browser stage(1920)
stage.stageHeight: The height of browser stage(1080)


2013年8月29日 星期四

Create a static library(framework) on ios

Create a static library(framework) on ios

如何在 xcode 上建立自己的 ios framework,
目前有好幾種解法,下列方法是我覺得目前問題最少且最有效率的方式。

2013年8月15日 星期四

Switching from bash to zsh on OSX

I switched from bash to zsh and installed oh-my-zsh.
Here are my dotfiles.

Screenshots:

console(ys theme)

How to stop a launchd process

osx 啟動服務都是由 launchd 來管理,

開機時會啟動下列目錄內的 plist
/System/Library/LaunchDaemons
/Library/LaunchDaemons

使用者登入後會啟動下列目錄內的 plist
/System/Library/LaunchAgents
/Library/LaunchAgents
~/Library/LaunchAgents

移除某個 service 可以用 launchctl 來控制 launchd
launchctl list
launchctl remove com.google.keystone.user.agent

這種做法重開機後,就失效,
解決辦法直接編輯 plist 加入
<key>Disabled</key>
<true/>

enjoy it~~

2013年5月3日 星期五

Convert mkv to mp4 for Apple TV

Install ffmpeg and MKVToolNix.

Check mkv tracks info.
mkvinfo -g

Result:
video: H264
audio: dts
subtitle: srt1
subtitle: srt2

2013年4月15日 星期一

mp4box: Adding Subtitles to mp4 Movies for Apple TV

Download and install mp4box on windows.

1. srt file use UTF-8 encoding
2. mp4box -ttxt origin.srt
3. try to change the font size
-<TextStreamHeader width="400" height="60" ...
+<TextStreamHeader width="video.width" height="video.height*20%" translation_x=0 translation_y="video.height*80%"
4. mp4box -add origin.ttxt:hdlr=sbtl:lang=eng -add origin.mp4 output.m4v

enjoy it...:)

2013年4月11日 星期四

FlashDevelop: getDefinitionByName ReferenceError: Error #1065: Variable ... is not defined.

When I was using getDefinitionByName to create dynamic class.
var myClass:Class = getDefinitionByName('Item1') as Class;

I usually got this error:
[Fault] exception, information=ReferenceError: Error #1065: Variable Item1 is not defined.

Fixed: just including complete library
assets.swf -> Add To Library -> Options -> Included library(include completely)

[ref]
http://www.flashdevelop.org/community/viewtopic.php?p=27575

2013年3月12日 星期二

Upgrade NME and Haxe3

After alias nme
sudo haxelib run nme setup

Got this error:
Called from native/media/SoundChannel.hx line 138
Called from native/Loader.hx line 63
Called from C:\Program Files (x86)\HaxeFoundation\haxe/std/neko/Lib.hx line 30
Uncaught exception - load.c(357) : Primitive not found : /usr/lib/haxe/lib/nmedev/3,6,0//ndll/Mac/nme@nme_sound_channel_set_position(2)

You need to rebuild native library to fixed it.
sudo haxelib run nme rebuild mac

2012年12月10日 星期一

Stage3D: 2D Particle Random Motion [optimized]

I just updated some code of my last demo and optimized it by reducing draw calls.
Now it can render over large number of particle(500,000+).

Here are some optimization:
  • reduce draw call
  • upload minimum of constants

2012年11月21日 星期三

Stage3D Limitation and Optimization

Stage3D AGAL Limitation:
  • The VertexBuffer is limited to 65535 vertex.
  • The IndexBuffer is limited to 983040 index.
  • In theory, you could have up to 983040/3 = 327680 triangle in one draw call.
  • In particle(using quads), you could have up to 65535/4 = 16383 particle max per draw call.
  • Shaders length can only contain a maximum of 200 opcodes.
  • The drawTriangles limited to 32768 calls per present call.

Optimization:
  • reduce draw call.
  • reuse material and batch rendering.
  • upload minimum number of constants.

2012年10月29日 星期一

Drop Multiple MySQL tables

You can show tables with wildcard character on MySQL server.
ie: SHOW TABLES LIKE 'PREFIX_%';

But can't drop multiple tables with '%'.

[HowTo]
For shell script:

for T in `echo "SHOW TABLES" |mysql db|grep "^PREFIX_"`; do echo "DROP TABLE $T;"|mysql db;done

enjoy it.
:D

2012年10月18日 星期四

How to play Away3D on mobile phone

Last week I played Away3D on my old iphone 3GS for fun(see my previous post).
Now, you can download the full source from here,
or get ipa and apk file to test on your mobile.

Here is the web demo.



2012年10月17日 星期三

How to monitor google analytics for iOS and Android

目前監控 mobile app tracking traffic 常用 proxy monitor 的方式,
不過這種方式常常會出現很謎的狀況,
ie: 有時有抓到資料,有時沒有...
造成開發者與分析師間鬼打牆的狀況...

最準確的方式還是用老方法直接截取封包,
以前用 tcpdump 很苦還要自己解析資料,
幸好現在有 ngrep 好用...XD