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

[WARN] maven encoding

tips & tricks 2011. 9. 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. 9. 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' 

maven에 3rd party jar 추가하기

tips & tricks 2011. 8. 12. 17:21 by manywaypark
local repository(~/.m2/repository)에 jar를 추가한다.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>


ref: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

happy hackin'
 
문제:
Qt의 QFile::copy()는 Windows와 Symbian에서만 native copy를 사용해 구현되어있다(2011-07-20 기준).
http://bugreports.qt.nokia.com/browse/QTBUG-10369
http://bugreports.qt.nokia.com/browse/QTBUG-10337
따라서 다른 platform에서 copy()를 사용하면 복사된 파일이 copy() 수행 시점의 timestamp를 가지게 된다.

해결:
지금 내 경우에는 생성시간의 유지가 중요한 상황이므로 다음과 같이 간단하게 회피하는 QFileFixed class를 만들어서 해결했다.

// file: QFileFixed.h

//! \author manywaypark at gmail.com http://manywaypark.tistory.com
 

class QFileFixed : public QFile

{

public:

    QFileFixed(const QString &name);

#if !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN))

    bool copy(const QString &newName);

    static bool copy(const QString &fileName, const QString &newName);

private:

    static void copyFileTime(const QFileInfo &srcInfo, const QString &dstPath);

#endif

};


// file: QFileFixed.cpp

//! \author manywaypark at gmail.com http://manywaypark.tistory.com


#if !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN))

#include <sys/time.h>

#endif


QFileFixed::QFileFixed(const QString &name)

    : QFile(name)

{}


#if !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN))

bool QFileFixed::copy(const QString &newName){

    bool r(QFile::copy(newName));

    if (r) copyFileTime(QFileInfo(*this), newName);

    return r;

}


bool QFileFixed::copy(const QString &fileName, const QString &newName)

{

    bool r(QFile::copy(fileName, newName));

    if (r) copyFileTime(QFileInfo(fileName), newName);

    return r;

}


void QFileFixed::copyFileTime(const QFileInfo &srcInfo, const QString &dstPath)

{

    QDateTime access(srcInfo.lastRead());

    QDateTime created(srcInfo.created()); /* created == modification?? */

    struct timeval time[2];

    time[0].tv_sec = access.toTime_t();

    time[0].tv_usec = access.time().msec() * 1000; /* millisecond to microsecond */

    time[1].tv_sec = created.toTime_t();

    time[1].tv_usec = created.time().msec() * 1000; /* millisecond to microsecond */

    int r = utimes(dstPath.toAscii().constData(), time);


    Q_ASSERT(r == 0);

}

#endif // !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)


Windows와 Mac OSX에서 테스트되었고, 내가 필요한 파일 생성 시간 유지는 잘 되는 것을 확인했다.

happy hackin'

문제
원래 Qt에서 단축키 추가는 너무 쉽다. 아래와 같이 하면 그냥 잘 된다.
action.setShortcut(QKeySequence(Qt::ALT + Qt::Key_C));
다만 문제는 MainWindow에서만 잘 된다는 것...   Orz
구글링을 해봐도 오래된 질문만 있고 답변은 없었다.

해결
처음에는 keyPressEvent 쪽에서 처리하는 다소 지저분한 방법을 쓰려했으나,
영 내키지 않던 차에 Qt Help에서 힌트를 얻을 수 있었다.
QShortcut이라는 클래스가 있었던 것이다.
QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_C), parent);
connect(shortcut, SIGNAL(activated()),
        &action, SLOT(trigger()));

동작은 잘 하는데 메뉴 등에 표시를 위해서는 action.setShortcut()도 해주어야한다.

happy hackin'

문제:
python에서 unittest 모듈을 써서 unit test를 할 때 다음과 같이 썼다.

if __name__ == '__main__':
unittest.main()


수행하면 다음과 같이 테스트케이스 다 실행하고 OK 뜬 후에 exception이 났다. 좀 찜찜했다.

......
......
Ran 2 tests in 12.545s

OK
Exception in thread "main" Traceback (most recent call last):
  File "D:\comms_share\csm-gui-test\sikuli\csmLogin.sikuli\csmLogin.py", line 11
1, in <module>
    unittest.main()
  File "D:\comms_share\csm-gui-test\sikuli-script.jar\Lib\unittest.py", line 768
, in __init__
  File "D:\comms_share\csm-gui-test\sikuli-script.jar\Lib\unittest.py", line 806
, in runTests
SystemExit: False


해결:
여기저기 뒤져봤더니 IDLE 문제라고 이미 알려져있었다.
다음과 같이 쓰면 된다.

class FooTest(unittest.TestCase) :
def setUp(self) :
......
def tearDown(self):
......
def testSomething() :
......

if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FooTest)  
unittest.TextTestRunner(verbosity=2).run(suite)


python 버전 정보는 다음과 같다

Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin


refs:
오류 상황:

git clone https://github.com/KentBeck/junit.git
Cloning into junit...
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/KentBeck/junit.git/info/refs

fatal: HTTP request failed


해결:
환경변수 GIT_SSL_NO_VERIFY를 true로 설정하면 된다.

GIT_SSL_NO_VERIFY=true


refs:

happy hackin'

MacPort 전체 정리

tips & tricks 2011. 4. 6. 18:32 by manywaypark
생각없이 쓰다보니 맥북의 하드가 꽉찼다. Orz
다운로드 폴더에서 이거 저거 지우다가 문득 든 생각... 어제 port upgrade outdated를 하고 나서 disk full이 난거같았다.
MacPort가 생성한 임시 파일들 정리하는 법은 의외로 간단했다.

$ sudo port clean --all all


추가적으로 비활성(inactive) 패키지 삭제(uninstall) :

$ sudo port uninstall inactive


다 하고 나니 약 4G 정도 늘어난듯...

refs:
Clean way to uninstall outdated inactive ports

happy hackin' 
간만에 방치(?)되어있던 테스트 박스에서 뭔가 작업을 하려고 했는데 버전이 좀 오래되어서 신경쓰였다.
버릇처럼 apt-get upgrade 했으나 필요한 파일들을 가지고 오지 못했다.
지원이 중단된 것이다. Orz.

해결은 배포판을 업그레이드 해야했다.
sudo do-release-upgrade

ref: http://www.ubuntu.com/desktop/get-ubuntu/upgrade

happy hackin'

[TIP] Erlang on Android

tips & tricks 2010. 12. 23. 19:24 by manywaypark
이제는 안드로이드 폰에서도 Erlang을 쓸 수 있다. ㅋㅋㅋ

refs:
http://www.burbas.se/artiklar/erlang-for-the-android-plattform/
http://www.erlang-solutions.com/section/72/packages

happy hackin'
1 ··· 9 10 11 12 13 14 15 16 
분류 전체보기 (306)
잡담 (20)
함수형 언어 (65)
emacs (16)
java (18)
tips & tricks (154)
사랑 (1)
가사 (0)
독서 (4)
mobile (6)
비함수형 언어 (2)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

05-05 00:47