Saturday, February 23, 2013

apk get package 명


import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class APKAnalyzer {
private static int bufferSize = 4096;
public static void main(String[] args) throws Exception {
System.out.println( findPackageNameFromAPK("c:/sample/1.apk") );
}

private static String findPackageName( String str )
{
int index1 = str.indexOf("manifest") + "manifest".length();
int index2 = str.indexOf("application");

if( index1 == -1 || index2 == -1 ) return null;

boolean isStart = false, isFinish = false;
for( int i = index1 ; i < index2 ; i++ )
{
isFinish = true;
char d = str.charAt(i);
//패턴은 되도록 쓰지말라는 권고에 따라서 아스키값으로 비교
if( 46 <= d && d <= 122 )
{
isStart = true;
isFinish = false;
}

if( isStart == false ) index1++;
if( isStart && isFinish) {
index2 = i;
break;
}
}
return str.substring(index1, index2);
}

public static String findPackageNameFromAPK( String path ) throws IOException
{
FileInputStream fis = new FileInputStream(path);
ZipInputStream zis = new ZipInputStream(fis);

ZipEntry zentry;
String fileName;
String packageName = null;
while( (zentry = zis.getNextEntry()) != null )
{
fileName = zentry.getName();
if( zentry.getName().equalsIgnoreCase("AndroidManifest.xml") )
{
BufferedInputStream bis = new BufferedInputStream( zis );
int c = 0;
int b = 0xFFFFFFFF ;


byte[] buffer1 = new byte[bufferSize];
byte[] buffer2 = new byte[bufferSize];

int cnt1=0, cnt2=0;
while( (c = bis.read()) != -1 )
{
if ( ( b ^= 0xFFFFFFFF ) == 0)
{
buffer1[cnt1++] = (byte)c;
}
else
{
buffer2[cnt2++] = (byte)c;
}

if( cnt1 == bufferSize || cnt2 == bufferSize  ) break;
}

String str1 = new String( buffer1 );

if((packageName = findPackageName(str1)) != null )
{
break;
}
String str2 = new String( buffer2 );
packageName = findPackageName(str2);
break;
}
}
return packageName;

}
}

Wednesday, February 20, 2013

Monday, February 18, 2013

open ssl install

http://dimdim.tistory.com/entry/openssl%EC%9D%84-%EC%9D%B4%EC%9A%A9%ED%95%9C-Tomcat-HTTPS-%EC%84%A4%EC%A0%95-PKCS12-%ED%8F%AC%EB%A7%B7

1.  access webSite

http://www.openssl.org/source/

2. use wget in linux and download

3. unzip gz file
  - gzip -d xxxx.tar.gz

4. tar
 tar -xvf xxxx.tar

5. ./config shared --prefix=/the folder to be installed/

6. make

7. make install



want to know if it exists

Sunday, February 17, 2013

Singleton_3


/* Singleton with Private Members, step 3. */
MyNamespace.Singleton = (function() {
// Private members.
var privateAttribute1 = false;
var privateAttribute2 = [1, 2, 3];
function privateMethod1() {
...
}
function privateMethod2(args) {
...
}
return { // Public members.
publicAttribute1: true,
publicAttribute2: 10,
publicMethod1: function() {

},
publicMethod2: function(args) {
...
}
};
})();

Singleton_2


/* Singleton with Private Members, step 1. */
MyNamespace.Singleton = (function() {
return {};
})();

Singleton_1


/* Singleton as an Object Literal. */
MyNamespace.Singleton = {};

You will now use a function, executed immediately, to provide the same thing:

/* Singleton with Private Members, step 1. */
MyNamespace.Singleton = function() {
    return {};
}();


Wednesday, February 6, 2013

how to analyze table index


analyze table document compute statistics
ex) DOCUMENT Table 만 Analyze
 
analyze index xpkdocbox compute statistics
ex) XPKDOCBOX Index 만 Analyze




select 'analyze table ' || table_name || ' estimate statistics;' from user_tables



select 'analyze index || index_name || estimate statistics;' from user_indexes


Friday, February 1, 2013

Make static class


function foo() {
  var a = 10;
  function bar() {
 a *= 2;
}
bar();
return a;
}
In this example, a is defined in the function foo, but the function bar can access it because
bar is also defined within foo. When bar is executed, it sets a to a times 2. It makes sense that bar
can access a when it is executed within foo, but what if you could execute bar outside of foo?
function foo() {
var a = 10;
function bar() {
a *= 2;
return a;
}
return bar;
}