티스토리 툴바

manywaypark's Blog
개발, 검색, 함수

문제:
lyx(tex)에서 셀이나 박스에 색상 넣었을 때 테이블, 박스 등 경계선이 제대로 안보인다.

해결:
\usepackage{color} 를  \usepackage{xcolor} 또는  \usepackage[xcdraw]{xcolor} 로 변경한다.
(없으면 추가)

refs: 
http://tex.stackexchange.com/questions/11769/box-border-lines-not-showing-properly-on-pdf 

happy hackin'
환경:

Mac OSX 10.6.8 (server)
Win7 SP1 desktop (client 1)
Win7 SP1 tablet (client 2)


문제:
현재 1.4.5 beta에서는 client 쪽 화면으로 넘어갔을 경우 modifier key들 중의 하나를 누르면 이 이상하게 눌려진 상태가 유지되면서 윈도우 메뉴나 단축키 메뉴가 수행되는 오류가 있다.

해결:
이미 issue tracker에 등록이되어 있고 패치도 나와 있었다.
http://synergy-foss.org/tracker/issues/3058

아래처럼 소스, 패치를 받은 후 적용, 컴파일 하면 된다.

$ svn checkout http://synergy-plus.googlecode.com/svn/branches/ synergy
$ cd synergy
$ wget http://synergy-foss.org/tracker/attachments/download/2953/stickykeys.patch
$ patch -p0 < stickykeys.patch
$ ./hm.sh conf -g1
$ ./hm.sh build
$ cd bin
$ synergys -c /path/to/conf


refs:
 - google keywords: synergy 1.4.5 mac server modifier key problem
 - http://synergy-foss.org/tracker/projects/synergy/wiki/Compiling

related:
 - Windows - 레지스트리에서 키보드 타입 변경 방법
 - shift + space 말고 한글 키 사용하게 소스 수정하는 방법

happy hackin'
1. 설치 미디어 준비
odd가 있는 장치에서 설치 디스크를 외장하드나 USB로 복사한다.
iso 이미지를 가지고 있다면 가상 드라이브로 마운트 한 후 복사한다.

2. 외장 미디어 부팅 가능하게 만들기
설치 디스크의 /boot/bootsect.exe를 다른 장소에 복사한 후
bootsect.exe /nt60 [외장 미디어 drive letter]

내 경우는  bootsect.exec:에 복사했고 외장 미디어는  F 드라이브로 잡혔으므로 다음과 같이 했다.
c:>bootsect.exe /nt60 F:
설치하고자하는 박스(아마 보통 놋북이겠지)를 재시작하고 BIOS 메뉴에 들어가서 USB/External HDD 부팅을 활성화하고 외장 매체로 부팅하면 윈도7 설치 화면이 뜬다. 끝!

note: 내 경우 P1620이라는 후지쯔의 노트북에 적용했는데  USB memory로 했을 때는 이상한 에러가 뜨면서 제대로 안됐고, 외장하드를 사용했을 경우는 정상적으로 설치가 되었다.
note2: bootsect.exe는 드라이브를 unmount한 후에 제대로 동작한다(MBR을 다시 쓰는 듯). 하여, 외장 매체에서 바로 자기 자신에게 적용할 수 없다. 마운트 해제가 안되기 때문에... 꼭 다른 곳에 복사한 후 실행해야만한다.
 
ref:
Bootsect Command-Line Options

happy hackin' 
delicious.com firefox extension data 파일에서 링크 정보 추출하기에 관해 설명한다.

opt in 어쩌구 하는 메시지는 가볍게 무시했었는데, 어느날 부터 서비스가 안되는 것이었다. Orz.
메시지 뿌려대기 시작할 때 무지무지 바빴는데, 바쁜게 끝났을 때는 메시지 무시하는 것이 버릇이 되어있었다.

서비스가 안되는 시점에 여러 검색을 해봤지만 뾰족한 방법이 없었다.
이상한 베타 블로그(http://deliciousengineering.blogspot.com/2011/09/welcome-to-delicious-beta-status-blog.html)에서 곧 조치를 취할거니 기다려 달라는 이야기만 있었다.

그래서 기다리는 중에 또 정신 없이 바빠졌다. 
시간이 좀 지나서 검색해보니 방법들이 있었다.
그런데 아래 링크대로 해봤지만 안됐다.
한시적인 서비스인 것도 있었고, dns 속여서 이전 서비스 접속하는 것도 안됐다.
http://www.avos.com/how-to-get-old-bookmarks-from-yahoo/
http://gabrielleabelle.livejournal.com/337468.html
https://www.delicious.com/settings/ws/import/bookmarks

욕이 나오기 시작했다.
한국 욕을 하면 못알아먹으니 영어로해야할것만 같은 생각도 두어번 들었다.

약간의 오기로 조금 뒤지기 시작했다.
의외로 간단히 firefox의 데이터 파일을 찾을 수 있었다.
C:\Documents and Settings\[UserId]\Application Data\Mozilla\Firefox\Profiles\rwiin5gt.default\ybookmarks.sqlite

혹시 모르니 데이터 파일 백업후 플러그인만 업글해보기로했다.
nsYDelLocalStore.js가 신나게 돌며 전부 삭제해버렸다. 미치기 직전이다.

ybookmarks.sqlite를 delicious.com의 import/export 에 쓰는 html(대충 보니 netscape 형식인듯)로 변환해서 해결하기로 방향을 정하고 다음과 같은 erlang 프로그램으로 모든 link들을 html 파일로 변경한 다음에 import 하니 해결되었다.

출력파일을 보면 제대로 동작해야할 것같은데 현재로서는 다음과 같은 문제가 있다:
  1. 한글이 모조리 없어지는 문제. 
  2. utf-8로 인코딩된 url이 delicious.com에서 redirect될 때 제대로 되지 않는 문제
    (%EC가 URL 내에 있다면, 실제 제목에 걸린 링크에서 redirect시키면서 %25EC로 된다).
일단 상기 문제는 delicious.com에 problem으로 등록했다.

%%%-------------------------------------------------------------------
%%% File    : to_html.erl
%%% Author  : M.W. Park <manywaypark@gmail.com>
%%% Description : converts delicious bookmark data file into html file for import.
%%%   1. install sqlite-erlang3(https://github.com/alexeyr/erlang-sqlite3).
%%%   2. copy ybookmarks.sqlite as delicious.db in current dir.
%%%   3. elrc to_html.erl
%%%   4. erl -noshell -pa [path/to/sqlite-erlang/ebin/] -run to_html doIt -run init stop
%%%   5. import output file(delicious.html) at http://export.delicious.com/settings/bookmarks/import
%%%
%%% Known Problems (for now) :
%%%   1. Hangul(Korean letters) is ignored by delicious (i registered ths issue).
%%%   2. UTF-8 encoded urls are not working (an odd 25 is added(%EC->%25EC) when delicious redirects it, so can't connect to the right url).
%%%
%%% Created : 2011-12-09 Friday by M.W. Park
%%%-------------------------------------------------------------------

-module(to_html).
-export([doIt/0]).

doIt() ->
    {ok,Output}=file:open("delicious.html",[write]),
    io:format(Output, "~s~n", [prefix()]),
    sqlite3:open(delicious), % open 'delicious.db'
    [{columns, _Columns}, {rows, Bookmarks}] = sqlite3:sql_exec(delicious, "select rowid,name,url,added_date,shared,description from bookmarks;"), % for all bookmarks
    lists:foreach(fun(Bookmark) ->
 %%io:format("row=~p~n", [Bookmark]),
 io:format(Output, "~s~n", [xmerl_ucs:to_utf8(bookmark(Bookmark))])
 end,
 Bookmarks),
    sqlite3:close(delicious),
    io:format(Output, "~s~n", [postfix()]),
    file:close(Output).

bookmark(Bookmark) ->
    {RowId, Name, Url, Date, Shared, Desc} = Bookmark,
    io_lib:format("<DT><A HREF=\"~s\" ADD_DATE=\"~ts\" PRIVATE=\"~p\" TAGS=\"~ts\">~ts</A>
<DD>~ts", [Url, re:replace(integer_to_list(Date), "000000$", "", [{return,list}]), if <<"true">> =:= Shared -> 0; true -> 1 end, get_tags(RowId), xmerl_ucs:from_utf8(Name), xmerl_ucs:from_utf8(Desc)]).

get_tags(RowId) ->
    Q = io_lib:format("select * from tags where rowid in (select tag_id from bookmarks_tags where bookmark_id=~p);", [RowId]),
    [{columns, _Columns}, {rows, Tags}] = sqlite3:sql_exec(delicious, Q),
    string:join(lists:map(fun({Tag}) -> xmerl_ucs:from_utf8(Tag) end, Tags), ",").

prefix() ->
    io_lib:format("<!DOCTYPE NETSCAPE-Bookmark-file-1>~n"
     "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">~n"
     "<!-- This is an automatically generated file.~n"
     "It will be read and overwritten.~n"
     "Do Not Edit! -->~n"
     "<TITLE>Bookmarks</TITLE>~n"
     "<H1>Bookmarks</H1>~n"
     "<DL><p>", []).

postfix() ->
    io_lib:format("</DL><p>", []).

 happy hackin'

[Android] process is bad

tips & tricks 2011/11/04 01:04 by manywaypark
멀쩡히 잘 돌던 앱이 이상해졌다.
Activity Manager가 process is bad라는 괴상한 에러를 내고 intent를 처리하지 못했다.
결론은 앱을 제거하고 리부팅하면 해결되는....
아... 돌겠다. Orz.

ref:
http://stackoverflow.com/questions/3253676/how-to-fix-process-is-bad-error-for-an-android-widget 
 
유틸이 있다.

tsshutdn


happy hackin' 

[WARN] maven encoding

tips & tricks 2011/09/26 13:42 by manywaypark
문제
maven을 사용해서 빌드할 때 다음과 같은 무시무시한(?) 경고가 나온다면, 인코딩 설정이 제대로 안된 것이다.
내 경우는 맥을 사용했으므로 MacRoman으로 fallback 되었다는 이야기다.

$ mvn package or something
...
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
...
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
...

해결
기본적으로 platform에 종속적이게되므로, 소스/리소스의 인코딩을 하나로 통일하고 다음과 같이 사용한 인코딩을 pom.xml에 적시하면 문제가 해결된다.
<project>
.....
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
......
</project>

refs:
http://maven.apache.org/general.html
http://maven.apache.org/plugins/maven-resources-plugin/examples/encoding.html

happy hackin'

git merge

tips & tricks 2011/09/23 15:50 by manywaypark
예전에 sqlite의 erlang connector관련해서 github에서 작업한 적이 있었다.
한참 방치하다가 들어가 보니 alexeyr님 및 다른 개발자들이 많이 발전시켜 놓은 상태였다(rebar 적용 등).
내쪽에 merge를 하고 싶었는데 문제는 내가 git에 별로 익숙치 않다는 것... Orz.
검색 및 삽질을 통해 merge하는 데에는 성공했는데, 역시 아직 손에 익지는 않은 듯하다.
일단 성공한 로그를 남겨둔다.
 
$ git clone git@github.com:mwpark/sqlite-erlang.git
$ cd sqlite-erlang
$ git branch # local branches
* master
$ git branch -a # all branches
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/gh-pages
  remotes/origin/master
$ git remote add alexeyr https://github.com/alexeyr/erlang-sqlite3.git
$ git remote -v
alexeyr https://github.com/alexeyr/erlang-sqlite3.git (fetch)
alexeyr https://github.com/alexeyr/erlang-sqlite3.git (push)
origin git@github.com:mwpark/sqlite-erlang.git (fetch)
origin git@github.com:mwpark/sqlite-erlang.git (push)
$ git checkout -b alexeyr/master
Switched to a new branch 'alexeyr/master'
$ git branch -r
  origin/HEAD -> origin/master
  origin/gh-pages
  origin/master
$ git pull alexeyr master:HEAD
$ git checkout master
NOTE: 여기서 conflict 생기면 add/rm 등을 해야함 (처음 checkout 시에 메시지 나오며, git status로 다시 확인 가능).
conflict 해결 후 다시 git checkout master 해서 branch 변경에 성공해야함.
$ git commit -m "merged https://github.com/alexeyr/erlang-sqlite3.git"
......
$ git push
Counting objects: 30, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (26/26), 127.78 KiB, done.
Total 26 (delta 2), reused 16 (delta 0)
To git@github.com:mwpark/sqlite-erlang.git
   a2e6238..61e929f  master -> master

refs:
http://gitref.org/branching/#merge
http://markosullivan.ca/how-to-handle-a-pull-request-from-github/
http://www.viget.com/extend/i-have-a-pull-request-on-github-now-what/

happy hackin' 
TAG git, github, Merge
Erlang의 풍부한 표현 방법을 보여주기 위한 간단한 예제를 만들었다.
lists:map에 전달하는 첫번째 파라미터(함수) 부분의 표현 방법을 보면 된다. 

by_...
function은  리스트를 입력받아 각 요소가 홀수인지 짝수인지 판별한다 (에러 처리 포함).
@spec (by_...([integer() | any()]) -> [odd | even | error].

기본적으로 유념해야 할 것은,
  • if는 guard expression을 사용하고, case는 pattern matching을 사용한다.
  • if는 마지막에 truecase는 마지막에 underscore(_) 또는 Any를 사용하여 default(catch all) 조건을 만든다.
  • guard의 and는 comma(,)이고, or는 semicolon(;)이다.

자세한 것은 코드 참조.

%%% -*- mode: erlang; tab-width: 4; indent-tabs-mode: nil -*-
%%%-------------------------------------------------------------------
%%% File    : expressions.erl
%%% Author  : M.W. Park <manywaypark@gmail.com>
%%% Description : an erlang example (to explain expressions)
%%%               ref: http://www.erlang.org/doc/reference_manual/expressions.html
%%%
%%% Created : 2011-09-22 목요일 by M.W. Park
%%%-------------------------------------------------------------------

-module(expressions).
%% -export([]).
%% -import(, []).
-compile(export_all).

%% using guard inside 'if'
by_if(L) when is_list(L) ->
    lists:map(fun(X) ->
                      if
                          is_integer(X),
                          X rem 2 =:= 0 -> even;
                          is_integer(X) -> odd;
                          true          -> error
                      end
              end,
              L).

%% nested 'case'
by_case(L) when is_list(L) ->
    lists:map(fun(X) ->
                      case is_integer(X) of
                          true ->
                              case X rem 2 of
                                  0 -> even;
                                  _ -> odd
                              end;
                          _ -> error
                      end
              end,
              L).

%% 'case' w/ guards
by_case_with_guard(L) when is_list(L) ->
    lists:map(fun(X) ->
                      case X of
                          _ when is_integer(X),
                                 X rem 2 =:= 0 -> even;
                          _ when is_integer(X) -> odd;
                          _                    -> error
                      end
              end,
              L).

%% 'case' w/ exception
%% 'rem' operator may throw an exception.
by_case_with_ex(L) when is_list(L) ->
    lists:map(fun(X) ->
                      try 
                          case X rem 2 of
                              0 -> even;
                              _ -> odd
                          end
                      catch
                          _:_ -> error
                      end
              end,
              L).

%% pattern matching functions
'what?'(X) when is_integer(X), X rem 2 =:= 0 ->
    even;
'what?'(X) when is_integer(X) ->
    odd;
'what?'(_) ->
    error.

%% passing function name as a parameter
by_passing_fun(L) when is_list(L) ->
    lists:map(fun 'what?'/1, L).

%% anonymous function w/ guards
by_anonymous_fun(L) when is_list(L) ->
    lists:map(fun(X) when is_integer(X),
                          X rem 2 =:= 0 -> even;
                 (X) when is_integer(X) -> odd;
                 (_)                    -> error
              end,
              L).

%% mixture of anonymous function w/ a guard and 'case'
by_mix(L) when is_list(L) ->
    lists:map(fun(X) when is_integer(X) ->
                      case X rem 2 of
                          0 -> even;
                          _ -> odd
                      end;
                 (_) -> error
              end,
              L).

%%%-------------------------------------------------------------------
%%% Unit Tests
%%%-------------------------------------------------------------------
-include_lib("eunit/include/eunit.hrl").

-define(BASIC(FunName), ?_assertEqual([odd, even], FunName(lists:seq(1, 2)))).
-define(ERROR(FunName), ?_assertEqual([error, error], FunName([0.1, atom]))). 

by_if_test_() ->
    [
     ?BASIC(by_if),
     ?ERROR(by_if)
    ].

by_case_test_()->
    [
     ?BASIC(by_case),
     ?ERROR(by_case)
    ].

by_case_with_guard_test_() ->
    [
     ?BASIC(by_case_with_guard),
     ?ERROR(by_case_with_guard)
    ].

by_case_with_ex_test_() ->
    [
     ?BASIC(by_case_with_ex),
     ?ERROR(by_case_with_ex)
    ].

by_passing_fun_test_() ->
    [
     ?BASIC(by_passing_fun),
     ?ERROR(by_passing_fun)
    ].

by_anonymous_fun_test_() ->
    [
     ?BASIC(by_anonymous_fun),
     ?ERROR(by_anonymous_fun)
    ].

by_mix_test_() ->
    [
     ?BASIC(by_mix),
     ?ERROR(by_mix)
    ].

happy hackin'
Erlang Opcode
참고 문서에는 otp_src_R14B01/lib/compiler/src/beam_opcodes.erl에 있다고 설명하고있으나,
최신 소스에는 otp/dialyzer/test/options1_SUITE_data/src/compiler/beam_opcodes.erl에 있고 주석에 보면 beam_makeops를 이용해서 만들어졌다고 되어있다.
beam_makeopsotp/erts/emulator/utils에 있고 perl script이다.

erlang source(.erl)을 assembly code(.S)로 컴파일 할 수 있는데 아래처럼 compile flag에 "+'S'"를 추가 하면 된다.
파일 내용을 확인해보면 opcode들이 난무(?)한다. 
$ erlc "+'S'" foo.erl

BEAM file format
TBD - 아래 링크 참고

happy hackin'
 
refs:
1 2 3 4 5  ... 14 
분류 전체보기 (140)
잡담 (17)
함수형 언어 (36)
emacs (9)
java (14)
tips & tricks (50)
사랑 (1)
가사 (0)
독서 (4)