기본 콘텐츠로 건너뛰기

글

[python] how to extract (unicode) code point

reference: http://stackoverflow.com/questions/7291120/python-and-unicode-code-point-extraction #python3 for i in range(1,100000): # try range(44032,55203) for Korean     print(i, chr(i), repr(chr(i)), repr(chr(i).encode('utf8')))     if i%30==0:         input("Enter to continue") #python2 for i in range(1,100000):     print i, unichr(i), repr(unichr(i)), repr(unichr(i).encode('utf8'))     if i%30==0:         raw_input("Enter to continue") #result 1 u'\x01' '\x01' 2 u'\x02' '\x02' 3 u'\x03' '\x03' 4 u'\x04' '\x04' 5  u'\x05' '\x05' 6 u'\x06' '\x06' 7  u'\x07' '\x07' 8 u'\x08' '\x08' ...snipped... 241 ñ u'\xf1' '\xc3\xb1' 242 ò u'\xf2' '\xc3\xb2' 243 ó u'\xf3' '\xc3\xb3' 244 ô u'\xf4' '\xc3\xb4' ...

[python] PYTHON REPR AND STR - THE DIFFERENCE

source: http://satyajit.ranjeev.in/2012/03/14/python-repr-str.html This is usually a question asked in many Python interviews: What is the difference between the __str__  and  __repr__  methods of a Python object. The same question was asked by one of my colleagues, which got me researching. In short  __repr__  goal is to be unambigous and  __str__  is to be readable. The official Python documentation says  __repr__  is used to  compute the “official” string representation of an object  and  __str__  is used to  compute the “informal” string representation of an object . The  print  statement and  str()  built-in function uses  __str__  to display the string representation of the object while the  repr()  built-in function uses  __repr__ to display the object. Using this definition let us take an example to understand what the two methods actually do. Lets create a...

[linux] 뻔하지 않은 파일 퍼미션(file permissions) 끄적임. 정말 속속들이 아니?

1. [특수w]내 명의의 디렉토리라면 제아무리 루트가 만든 파일에 rwxrwxrwx 퍼미션이라 할지라도 맘대로 지울 수 있다. 즉 내 폴더안의 파일은 뭐든 지울 수 있다. 2. [일반rx]하지만 읽기와 쓰기는 other의 권한을 따른다. 3.[일반rwx]단 남의 계정 폴더는 그 폴더의 퍼미션을 따른다. 4.[일반]만약 굳이 sudo로 내 소유로 파일을 넣어놓더라도 달라지는건 없고, 단지 그 폴더의 other퍼미션에 write권한이 있으면 파일을 만들고 삭제할 수 있다. 5.디렉토리의 r권한은 내부의 파일이름 정도만 볼 수있다. 하지만 ls 명령의 경우 소유자, 그룹, 파일크기 등의 정보를 보는 명령어므로 정상적인 실행은 불가능하고, 부분적으로 실행됨. frank@localhost:/export/frankdir$ ls rootdir/ ls: cannot access rootdir/root: 허가 거부 ls: cannot access rootdir/fa: 허가 거부 fa  root #이처럼 속한 파일(폴더)만 딸랑 보여준다. frank@localhost:/export/frankdir$ ls -al rootdir/ # al옵션이 모두 물음표 처리된다.. ls: cannot access rootdir/root: 허가 거부 ls: cannot access rootdir/..: 허가 거부 ls: cannot access rootdir/.: 허가 거부 ls: cannot access rootdir/fa: 허가 거부 합계 0 d????????? ? ? ? ?             ? . d????????? ? ? ? ?             ? .. -????????? ? ? ? ?             ? fa -????????? ? ? ? ?     ...

[GIT] How to checkout a remote branch

source: http://stackoverflow.com/questions/1783405/git-checkout-remote-branch question: I am trying to checkout a remote branch: Somebody pushed a branch called  test  with  git push origin test  to a shared repository. I can see the branch with  git branch -r . But how can I get this branch? git checkout test  does nothing git checkout origin/test  does something, but  git branch  says  * (no branch) . I am on no branch? How do I share branches via a public repository? answer: Before you can start working locally on a remote branch, you need to fetch it as called out in answers below. To fetch a branch, you simply need to: git fetch origin This will fetch all of the remote branches for you. You can see the branches available for checkout with: git branch -v -a With the remote branches in hand, you now need to check out the branch you are interested in, giving you a local working copy: git checkout -b test or...

[GIT] How do I revert from my current state to a snapshot made on a certain commit?

source: http://stackoverflow.com/questions/4114095/revert-to-previous-git-commit question: How do I revert from my current state to a snapshot made on a certain commit? If I do  git log , I get the following output: [root@me dev]# git log commit a867b4af366350be2e7c21b8de9cc6504678a61b` Author: Me Date: Thu Nov 4 18:59:41 2010 -0400 blah blah blah... commit 25eee4caef46ae64aa08e8ab3f988bc917ee1ce4 Author: Me Date: Thu Nov 4 05:13:39 2010 -0400 more blah blah blah... commit 0766c053c0ea2035e90f504928f8df3c9363b8bd Author: Me Date: Thu Nov 4 00:55:06 2010 -0400 And yet more blah blah... commit 0d1d7fc32e5a947fbd92ee598033d85bfc445a50 Author: Me Date: Wed Nov 3 23:56:08 2010 -0400 Yep, more blah blah. How do revert to the commit from November 3? answer: This depends a lot on what you mean by "revert". If you want to  temporarily go back to it, fool around, then come back to where you are , all you have to do is check out the desired commit: ...

[GIT] How do I delete a Git branch on a remote server?

source: http://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-remotely As of  Git v1.7.0 , you can delete a  remote  branch using git push origin --delete <branchName> which is easier to remember than git push origin :<branchName> which was added in  Git v1.5.0  "to delete a remote branch or a tag." Therefore, the version of Git you have installed will dictate whether you need to use the easier or harder syntax. Original Answer from 5-Jan-2010 From Chapter 3 of  Pro Git  by Scott Chacon: Deleting Remote Branches Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s master branch (or whatever branch your stable codeline is in). You can delete a remote branch using the rather obtuse syntax  git push [remotename] :[branch] . If you want to delete your serverfix branch from the server, you run t...

[api hooking] API Hooking 요점정리

source: http://blog.bagesoft.com/255 API Hooking 요점정리 이 글이 상당히 좋은 글임에도 불구하고 보시는 분마다 스트레스(?)를 받는것은 그냥... 좀 어려운내용이 길~게 있으니깐 그럴것입니다. 해서리.. 제가 초간단으로 요점을 간추려서 제 스타일로 다시 설명을 해보겠습니다... 쩝....(이런건 또 첨해보넹.. --;) API후킹이란?... 1. API는 DLL파일안에 들어있습니다.  API함수를 사용한다는것은 윈도우가 제공하는 DLL안에 들어있는 함수를 사용하는겁니다. 그러므로 API후킹을 한다는것은 다른 프로그램이 DLL의 함수를 사용하는것을 내가 가로채는것을 말합니다. API 후킹의 목적... 2. 가로채서? 그 다음은 그 함수의 기능을 사용하지 못하게 할수도 있고 어떻게 사용하는지 감시만 할 수도 있고 전혀 다른 내용으로 바뀌게끔 할 수도 있습니다. 그러므로 이것을 이용해서 할 수 있는 일을 두가지 정도로만 야그해보면...  3. 다른 프로그램을 디버깅하거나 리버스엔지니어링들을 위해서 사용할 수 있습니다. API함수만 알아가지고 뭘 알수 있겠냐라고 생각할 수도 있겠지만.. 사실 우리가 사용하는 모든 델파이 문법과 라이브러리는 결국 API함수를 사용하기위한 과정에 불과합니다. 윈도우는 디바이스에 내용을 출력하고 키보드 마우스로 입력받고, 다른 장비와 통신하고하는 모든 과정을 API, 메세지, ActiveX 이 세가지로 다 합니다. 4. API후킹을.. 디버깅하는데만 사용하지는 않고 어떤 특별한 기능을 구현할때도 사용합니다. 가장 좋은 예로 노클릭 영한사전이 있습니다. 글씨에 커서를 가져가면 번역을 보여주는.. 그런것을 할때도 API후킹이 필요합니다. 그때는 Text에 관련된 함수들을 후킹하겠지요.. 5. DLL의 구조를 좀 알아야합니다. 여기서 DLL의 구조를 안다는것을 PE포맷을 알아야 한다는것과 유사한데 그렇다고 핵사에디터로 DLL을 열어서 바이너리를 들여다 보라는 야그가 ...