'Programming' 카테고리의 글 목록 (15 Page)
본문 바로가기

Programming218

ssh config 자주사용하는 ssh host가 있으면 .ssh/config에 등록하고 쉽게 사용하자 SSH config에 추가 vi ~/.ssh/config Host gpu HostName my-aws-ec2 User ec2-user IdentityFile ~/.ssh/{YOUR_PRIVATE_KEY} # config 추가 전 $ ssh -i ./aws.pem ec2-user@my-aws-ec2 # config 추가 후 $ ssh gpu pem, config 파일은 퍼미션 440으로 지정 $ chmod 440 ~/.ssh/config $ chmod 440 ~/.ssh/aws.pem 2020. 6. 20.
python 에서 redis를 메시지 queue로 사용 파이썬에서 redis를 message queue로 구현 redis class - redis_queue.py """RedisQueue class""" import redis class RedisQueue(object): """ Redis Lists are an ordered list, First In First Out Queue Redis List pushing new elements on the head (on the left) of the list. The max length of a list is 4,294,967,295 """ def __init__(self, name, max_size, **redis_kwargs): self.key = name self.max_size = max_size self.. 2020. 6. 19.
git force push local 로 remote 덮어쓰기 master branch에서는 하지 않기를 바란다 대부분 서브 브랜치에서 스쿼시 후에 많이 사용 $ git push -f 2020. 6. 18.
time 명령어를 이용한 간단한 처리 시간 측정 time 명령어를 이용한 간단한 시간 측정 $ /usr/bin/time -p python test_1.py real 64.38 # 경과된 시간 user 63.65 # cpu가 커널함수 외 작업에 소비한 시간 sys 0.36 # 커널함수를 수행하는데 소비한 시간 좀 더 자세한 정보는 -lp 옵션을 사용한다 $ /usr/bin/time -lp python test_1.py real 64.20 user 63.71 sys 0.28 7098368 maximum resident set size 0 average shared memory size 0 average unshared data size 0 average unshared stack size 2444 page reclaims 40 page faults 0 s.. 2020. 6. 17.
git stash - 작업 임시 저장 git stash 작업 중에 다른 브랜치로 체크아웃하거나 마스터를 리베이스할 경우에 사용하면 좋다 # without message > > > git stash > > > git stash save # git stash save > > > git stash save update tag > > > git stash list > > > stash@{0}: On branch\_name: update tag > > > stash@{1}: WIP on branch\_name: 49bf139 replace parenthesis # 0: git stash save update tag 결과 # 1: git stash # commit 한거, commit 안한거 모두 commit 안한거로 unstash > > > git s.. 2020. 6. 16.
파이썬 정규식(regular expression:regex) 사용 - 일부만 추출 파이썬에서 정규식 사용 정규식으로 찾고 일부만 추출하기 >>> import re >>> _str=" 65 0 0 -50 243 323 Tm\n asdfasdf" # 정규식에서 `()`로 싸여진 곳이 `group` >>> matches = re.finditer(r"^\d+ \d+ \d+ \-\d+ (\d+) \d+ Tm$",b,re.MULTILINE) >>> for match in matches: ... print(match.group()) ... group_num = len(match.groups()) ... print(match.group(group_num)) ... 65 0 0 -50 243 323 Tm 243 2020. 6. 15.