2014年10月28日星期二

AngularJS 2.0 is coming soon...

  上週 ng-europe 介紹了 angularJS 2.0 的 spec。才正想要好好寫一篇關於 directive 的文章,看完 angularJS 2.0 的介紹後.... 只能說還沒開始用 angularJS 又想要用的人似乎可以暫緩一下腳步了... 因為 2.0 和 1.3 是道道地地的不一樣阿...

2014年4月1日星期二

AngularJS 和卡卡女神說再見!

  不知道大家會不會有這個問題,AngularJS 在開發上雖然很方便,可是當資料量大到一個程度,網頁就會整個大卡。為了不要因為 ngRepeat 變成卡卡網站,最近研究了如何優化 angularJS ngRepeat 的效能。以下來跟大家稍稍分享小小心得。使用 ng-repeat 會導致網頁反應遲緩的原因有兩個,下面整理給大家:

2014年3月22日星期六

AngularJS $q deferred 和 promise

  剛接觸 AngularJS 時,每次看到 $q 和 promise,就開始亂用,久了之後唯一的想法就是:「QQ,不會用有再多保證也沒用阿!」。在耐心看完一些網路資料和書的範例後,才知道 $q 實在是一個簡單又好用的東西,只是不懂為什麼大部分的資料似乎都把它講的很玄...,因此決定在這邊記錄和分享一下。

2014年1月5日星期日

AngularJS Service, Factory, Provider 差別

   初學 AngularJS 時,看到 service, factory, provider, 常讓人摸不著頭腦。在網路上survey了一陣,StackOver flow 上最被推崇的一篇:Angular.js: service vs provider vs factory?*1 看了之後還是不解其惑。直到最近在閱讀Pawel 的 Mastering Web Application Development with AngularJS*2,裡面有了詳細的說明,讓我瞬間有豁然開朗之感。以下是一些小小的整理。

2013年1月14日星期一

Add code column in Blogger

References:
http://code.google.com/p/syntaxhighlighter/
http://oneqonea.blogspot.tw/2012/04/how-do-i-add-syntax-highlighting-to-my.html
http://www.vixual.net/blog/archives/198

Decompress (extract) .tgz file in Java

To handle .tgz file, here is a method to handle it in java like handle Zip file.
Use GZIPInputStream to read .tgz file.
Use TarInputStream to read the the GZIPInputStream.
Therefore we can get TarEntry and handle the .tgz file.

Here is an example that we would like to get file named version in a .tgz file.
package test;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarInputStream;

public class GZipTest {

 public static void main(String[] args) {
  byte[] buffer = new byte[1024];
  String fileSorce = "/Users/Desktop/testgzip.tgz";

  try {
   // get the zip file content
   TarInputStream zis = new TarInputStream(new GZIPInputStream(
     new FileInputStream(new File(fileSorce))));
   // get the zipped file list entry
   TarEntry ze = zis.getNextEntry();

   while (ze != null) {
    String fileName = ze.getName();
    if (fileName.contains("version")) {
     StringBuffer strBuffer = new StringBuffer();
     while (zis.read(buffer) > 0) {
      strBuffer.append(new String(buffer));
     }
     System.out.println(strBuffer.toString());
    }
    ze = zis.getNextEntry();
   }

   zis.close();
  } catch (IOException e) {
   System.out.println(e);
  }
 }
}

2012年8月21日星期二

Get Android source code from .apk

To get Android source code from .apk, you need following tools:

  1. dex2jar - the tool helps we decode .apk to .class files
  2. JD-gui or JDEclipse - the tool helps we read the .class files. JD-gui can help you save all .class to .java at one time.
  3. android-apktool - the tool helps we get res and other properties in the .apk.

The steps to get the source code of XXX.apk:

The environment I used is Fedora 16. android-apktool was installed under /usr/local/bin directory.

First, we are going to take the .java files.
     1.  Use dex2jar to get the .class files.
          # sh dex2jar.sh XXX.apk
     Then we will get a file named "XXX.apk.dex2jar.jar". 
     2. Open JD-gui and open "XXX.apk.dex2jar.jar" file. (File -> OpenFile -> indicate XXX.apk.dex2jar.jar ).
     3. Save all sources (File -> Save all sources -> to where you want to save the sources and make a name). Then you will get a zip file. Here we named it XXX.zip.

Now we have .java files in XXX.zip.
     
Second, we are going to get other files such as res directory and .xml files in XXX.apk.
     1.  Use android-apktool to get the files.
           # apktool d XXX.apk XXX_dir
     apktool will create XXX_dir. Then in XXX_dir, we have the files. 
     
Finally, we can unzip XXX.zip to XXX_dir/src. And everything is done.

References: