Sunday, November 29, 2015

Android Facebook SDK hash key

public void printHashKey() {
        try {
            PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String hashKey = new String(Base64.encode(md.digest(), 0));
                Log.i(TAG, "printHashKey() Hash Key: " + hashKey);
            }
        } catch (NoSuchAlgorithmException e) {
            Log.e(TAG, "printHashKey()", e);
        } catch (Exception e) {
            Log.e(TAG, "printHashKey()", e);
        }
    }

원격제어 VNC, RDP 차이

요즘 원격 접속 제어 등에 관심이 생겨서 그러는데,

VNC와 RDP 차이가 어떤 점일까요...?
기술적으로 어떤게 다른지 알면 더 좋을 것 같네요.

예를 들면, VNC는 다중 접속이 가능하고 RDP는 그렇지 않다던가...
VNC는 화면 캡쳐 기반이고 RDP는 가상 채널 기반이라던가...
(실제로 맞는지 모릅니다. 그냥 대충 적어놓은 거에요. ㅠㅠ_

확실히 서로 다른 솔루션이고 장단점이 있을 것 같은데 정확히는 잘 모르겠네요.
RDP는 윈도우용이고 VNC는 서버 프로그램을 설치하면 윈도우, 맥, 리눅스 등 다 사용가능하다던지...

혹시 잘 아시는 분 계세요..?


RDP는 마이크로소프트에서 만든 것으로 서버로는 윈도우만 가능하고 클라이언트는 윈도우, 맥, 리눅스 모두 가능합니다. 속도나 성능, 기능적인 측면에서 좋은 편입니다. 서버 버전이 아닌 윈도우에서는 다중 접속이 안 되는 단점이 있으나 약간의 패치로 수정이 가능하기도 합니다.
VNC는 멀티플랫폼이 된다는 게 가장 큰 장점입니다.


RDP를 제외한 나머지류는 화면 전체를 캡쳐해서 인코딩하여 보내는 방식인지라 다양한 운영체제에서 사용이 가능한 반면에, 역으로 좀 느립니다. MS RDP는 MS의존적인 반면에 단순 압축이 아니라 경우에 따라 간소화된 프로토콜을 이용하여 좀 더 빠릅니다. 다만 MS RDP가 항상 MS OS에서만 사용 가능한 것은 아니고, 어디까지나 단순 이미지를 전송하는 방식도 있기 때문에 Virtualbox같은 경우에는 모든 OS에 대하여 접속이 가능하도록 설정할 수 있습니다.
그리고 또 VNC는 원격 접속류이기 때문에 해당 대상 컴퓨터의 콘솔 세션에만 접근이 가능한 반면, RDP는 비 콘솔 세션에 접근할 수 있지요.

Thursday, November 26, 2015

Android immersive fullscreen toggle

    /**
     * Detects and toggles immersive mode (also known as "hidey bar" mode).
     */
    public void toggleHideyBar() {

        // BEGIN_INCLUDE (get_current_ui_flags)
        // The UI options currently enabled are represented by a bitfield.
        // getSystemUiVisibility() gives us that bitfield.
        int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
        int newUiOptions = uiOptions;
        // END_INCLUDE (get_current_ui_flags)
        // BEGIN_INCLUDE (toggle_ui_flags)
        boolean isImmersiveModeEnabled =
                ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
        if (isImmersiveModeEnabled) {
            Log.i(TAG, "Turning immersive mode mode off. ");
        } else {
            Log.i(TAG, "Turning immersive mode mode on.");
        }

        // Navigation bar hiding:  Backwards compatible to ICS.
        if (Build.VERSION.SDK_INT >= 14) {
            newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }

        // Status bar hiding: Backwards compatible to Jellybean
        if (Build.VERSION.SDK_INT >= 16) {
            newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
        }

        // Immersive mode: Backward compatible to KitKat.
        // Note that this flag doesn't do anything by itself, it only augments the behavior
        // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample
        // all three flags are being toggled together.
        // Note that there are two immersive mode UI flags, one of which is referred to as "sticky".
        // Sticky immersive mode differs in that it makes the navigation and status bars
        // semi-transparent, and the UI flag does not get cleared when the user interacts with
        // the screen.
        if (Build.VERSION.SDK_INT >= 18) {
            newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }

        getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
        //END_INCLUDE (set_ui_flags)
    }

CLion에서 사용하는 CMakeLists.txt 간단 강좌

리눅스에서 프로그래밍할때 IntelliJ 기반의 CLion이라는 툴을 사용해보았다. CLion은 Makefile이 아닌 범용 maketool인 CMake를 사용한다. 그래서 Makefile 대신에 CMakeLists.txt를 만들어줘야 빌드가 된다.

1. 아래는 long string에 대한 에러가 날때 사용한다. CFLAGS옵션 이다.
Makefile
FLAGS = -g -O3 -fpermissive -w

CMakeLists.txt
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")

2. 아래는 include directory에 대해서 설정이다. I옵션이다.
Makefile
INCS = -I/usr/include -I/usr/local/mysql/include -I/usr/local/include

CMakeLists.txt
include_directories(/usr/include)
include_directories(/usr/local/mysql/include)
include_directories(/usr/local/include)

3. 아래는 AnsiC에 대한 옵션이다.
set(CMAKE_C_FLAGS "-std=c99")

4. 아래는 define 정의이다. FLAGS+= -D와 같다.
add_definitions(-DREGION_KR=1)
add_definitions(-DMODE_REAL=1)
add_definitions(-DDB_REAL=1)

5. 아래는 static library에 대한 옵션이다.
Makefile
LIBS = -lc -lssl -lpthread -L'/usr/local/mysql/lib/mysql' -lmysqlclient -lz -lcrypt -lnsl -lm -ldl -lrt

CMakeLists.txt
add_executable(dark_server ${SOURCE_FILES})

#link must be after add_executable
target_link_libraries(dark_server c)
target_link_libraries(dark_server ssl)
target_link_libraries(dark_server pthread)
target_link_libraries(dark_server mysqlclient)

Tuesday, November 17, 2015

Linux binary executable bit check

실행파일 바이너리의 비트수를 체크하는 명령은 다음과 같다.

file <filename>

root@3bd49b29-5448-41da-a3e1-581280f439e0:~/dark_server/src# file mgs_dark
mgs_dark: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x1b8c7bd92afcb4134444103f026ddb336cff19c4, not stripped
root@3bd49b29-5448-41da-a3e1-581280f439e0:~/dark_server/src#

Monday, November 9, 2015

iOS Please verify that your device’s clock is properly set, and that your signing certificate is not expired.

Please verify that your device’s clock is properly set, and that your signing certificate is not expired. (0xE8008018).

Xcode -> Preferences -> Accounts -> View Details -> Download All

Tuesday, November 3, 2015

Android 5.0 WebView image not shown

// Android 5.0에서는 그림이 안보이니 이걸 해주어야 한다.
        if(Build.VERSION.SDK_INT >= 21) {
            mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }

Sunday, November 1, 2015

gem eventmachine openssl/ssl.h not found

bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
bundle install

Mac openssl 설치

./config (32bit)
./Configure darwin64-x86_64-cc (64bit)

make
sudo make install