2014년 12월 7일 일요일

(퍼옴) 미루는습관고치기

Q: 머리 속에는 해야 할이 꽉 차있지만 정작 실행에 옮기지 못하고 일을 자꾸 미루는 습관이 있어요. 막상 일을 시작해도 마무리 짓지 못하고, 다 른 사소한 일에 매달리는 경우도 많구요. 미루는 만큼 쌓여가는 일들이 많아지다보니, 점점 더 하기 싫어지고 무기력해지는 것 같아요. 어떻게 하 면 좋을까요?

A: 조금씩 일을 미루다 보면 작은 일들이 산더미처럼 쌓여 마음을 더 짓누르게 되지요. 그래도 미루는 습관을 고치겠다는 마음을 가지셨으니 시작 이 반입니다. 이제부터 저와 함께 미루는 습관에서 벗어나는 길을 찾아 보아요.

첫째, 모든 것을 완벽하게 하겠다는 강박관념 때문에 일을 미루고 있다면, 기대수준을 조금 낮춰보세요. 실수하지 않고 완벽하게 처리하려면, 챙겨 야 할 게 참 많아집니다. 혹시라도 빠트리는 것이 있을까봐, 이것 저것 챙기다 보니 정작 중요한 일에 손을 대지 못하고 시간을 흘려 보냅니다. 결 과도 완벽할 것을 기대하니, 마음에 드는 성과가 드러날 것 같지 않으면 아예 시작도 못하는 경우가 많지요. 정작 일을 시작해놓고도, "내가 잘하고 있는가?, 제대로 하고 있는 걸까?"라는 자기검열의 생각 때문에 주춤주춤 거리고 일의 속도가 안납니다. 따라서, 100% 완전하게 해내겠다는 마음보다는 일단 70-80%만 도달해보자는 마음을 가져 보면 좋겠지요. 또, 큰 목표를 작은 덩어리로 나눠서 작 은 일부터 시작해보셔도 좋겠습니다. 집 전체를 다 정리하려고 하면 엄두가 나지 않지요. 하지만 방 하나, 혹은 방의 한쪽 일부분만 치운다는 마음 으로 시작하는 겁니다. 마치 지렛대의 원리처럼, 모든 일을 다 할 수는 없더라도, 작은 일을 하나 시작함으로써, 미뤄뒀던 큰 일을 하게 되는 시작 이 되는거지요.

둘째, 일을 미루면서 무기력한 상태에 빠져있다면, 작은 시도를 할 수 있도록 자기 자신을 격려해주세요. 누구나 마음 속에는 "네 이놈.. 똑바로해 야지"라고 높은 가치기준이나 도덕적 명령에 도달하도록 자신을 부추기는 상전의 목소리가 있습니다. 상전은 항상 "~~해야만 한다"고 명령하며, 하인의 게으름을 질타하고 몰아부칩니다. 하인이란 억압된 인격의 측면으로, 늘 꾸지람을 듣는 내면의 아이를 나타냅니다. 건강하지 못한 인격은 내면에서 상전과 하인이 서로의 입장을 존중하지 못하고 분열되어 팽팽한 싸움을 하며, 창조적인 에너지를 고갈시키게 됩니다. 이러한 상태를 신 경증적인 '자기고문게임'이라 하지요. 상전은 완벽을 추구하기에 하인이 도달할 수 없는 이상을 요구하며 하인을 야단치고, 하인은 다음에는 잘하 겠다고 하면서도 역시 말뿐 행동은 오히려 꾸물거리고 일을 회피함으로써 결국 상전과의 게임에서 승리를 합니다. 상전이 시키는 일이 하기 싫어 늦장을 부리거나 딴짓을 해서 속을 태우는거지요. 혹시 내가 어떤 일을 미루고 있다면, 내 안에서 저항하고 있는 것은 아닌지, 이러한 자기고문게 임에서 무기력한 상황에 빠져있는 것은 아닌지 살펴보시기 바랍니다. 만일 그렇다면, 스스로를 따뜻한 시선으로 바라봐주십시오. 마치 걸음마를 처음 배우는 어린아이가 비록 넘어지더라도 따뜻한 미소로 박수쳐주는 엄마의 시선처럼요. 자신의 부족하고 서툰 시도를 아무런 평가나 비판없이 바라보고, 뭐라도 시작했다는 것에 스스로를 격려하시기 바랍니다. 남 과 비교하지 말고, 적어도 내가 어제 시도하지 못했던 것을 오늘 해보았다는 것 만으로도 자신을 축하해주세요. 작은 시도와 작은 성공이 다음 발 걸음으로 이어지니까요.

셋째, 너무 많은 것을 고려하면서 결정을 미루고 있다면 선택의 가짓수를 제한해보세요. 예전에는 물건을 하나 사더라도 한정된 몇가지 중에 고르 면 그만이었지만, 이제는 최선의 선택을 위해 인터넷검색과 다양한 매체를 통해 관련 상품정보와 가격대를 비교하며 결정을 하게 됩니다. 최상의 선택을 하려고 애쓰면 애쓸수록 더 많은 선택의 가짓수를 넓히게 되고, 결국 선택을 미룰 수 밖에 없어집니다. 최선의 선택을 위해 시간을 미루는 것이 신중하다고 볼 수도 있지만, 선택을 미룸으로써 얻게 되는 손실도 생각해야겠지요. 예를 들어 새로운 컴퓨터를 구입하기 위해 온갖 사양을 비 교검토하느라 한두달을 지연하다보면, 더 업그레이드된 제품이 나올때마다 의사결정은 더 어려워집니다. 필요한 상황에 컴퓨터를 사용하지 못하 면서 제품비교에 들이는 시간비용까지는 고려한다면, 차라리 내가 필요한 그 순간에 적절한 사양과 가격에 맞는 제품을 구입하여 사용하는 것이 더욱 경제적인 선택이겠지요. 따라서 되도록 선택의 가짓수를 제한하는 것이 좋습니다. 시행착오를 겁내지 말고, 실험을 해본다는 마음으로 선택에 임하는 것도 좋을 것입니다. 생활을 단순화시키는 것도 일을 미루는 습관에서 벗어날 수 있는 방법입니다. 너무 많은 것을 관리하는데 들이는 시간을 줄일 수 있으니까요.

넷째, 벼락치기에 익숙해져 습관적으로 일을 미루고 있다면, 나만의 데드라인을 설정해보세요. 마감이 코앞에 닥치면 압박감 때문에 아드레날린이 분비되면서 광적인 에너지로 막판투혼을 펼칠 수 있습니다. 짧은 기간에 고도의 집중력을 발휘 하여 일을 해치우기도 하지요. 이러한 성취감에 '어떻게든 나는 해낸다'는 생각이 은연중에 쌓이면서 미루는 습관이 강화되기도 합니다. 또한 조금 부족한 결과에 대해 변명거리도 제공합니다. " 능력이 부족해서가 아니라 시간이 부족했을 뿐이라고" 변명하면서도 그 다음에 일을 할 때도 다시 미루는 습관은 여전합니다. 하지만, 이런 일이 반복되면 내성이 생기면서 끝낼 시간이 다가와도 더 이상 긴장되지 않고 집중력도 발휘되지 않습니 다. 넉넉한 시간이 주어져도 결국 끝내야 할 시간에 맞춰 일을 시작하기 때문에 미루기가 고질적인 습관으로 변하기도 합니다. 따라서, 마감일과 별도로 나만의 데드라인(Dedline), 즉 사선(死線)을 정해 보는 겁니다. 최종마감일 전에 중간 데드라인을 만들어두는 것도 좋겠 죠. 월말까지 마쳐야 할 보고서라면, 중순까지는 최소한 전체개요를 작성해 보는거지요. 또한 일을 끝내는 시점이 아닌, 일을 시작할 시간, 즉 개시 데드라인을 정해놓는 것도 유용한 방법입니다. 나중에 해야지 라고 막연하게 미루기보다는 다음 주 월요일까지는 어떻게든 시작하겠다고 마음 먹 는 거지요. 시작이 반이니까요. 단숨에 일을 해치울 수 없어 마냥 미루고만 있다면, 우선 한 시간 만 혹은 30분만 해보자고 마음먹고 시작해 보는 겁니다. 완성을 목표로 하는 것이 아니라, 정해진 시간 안에서 얼마나 해내는지 확인할 수 있으니, 좀더 현실적인 계획을 세울 수도 있겠지요.

이제 11월입니다. 얼마 남지 않은 한 해를 바라보며, 지금까지 내가 뭘 했지?라고 반문하고 계시지는 않으신가요? 쫓기는 마음에 허둥대다가 정작 중요한 일을 또 다시 미루고 있지는 않으신가요? 지금 이순간, 무엇을 하고 싶은지, 어떤 일을 해야 하는지 살펴보시고, 작은 것이라도 시작해보시 기 바랍니다. 미루는 습관 역시 단번에 완벽하게 고쳐지는 것은 아니까요. 일단 나 자신을 실험을 해본다는 마음으로 작은 시도를 해보세요. 당신의 작은 실험이 성공하시길 바랍니다.

칼럼리스트 : 이상희 삼성생활문화센터 상담실장

2014년 11월 26일 수요일

Brain teaser

This problem may look trivial, but actually it took some time for me to solve.
It was fun in a way. So, the problem is


The answer is

2014년 10월 18일 토요일

ssh 로 특정 폴더/디렉토리로 바로 접속하기 및 설정


ssh -t [id@][xxx.xxx.xxx.xxx] "cd [destination] ;exec \$SHELL -l"

# 오래된 서버에 접속하려니 ssh-rsa 나 ssh-dss 를 사용하라고 할 경우

(1) 설정파일 만들기 "~/.ssh/config" file에 아래 내용 추가 
HOST [hostname]
     HostName [address]
     User [user_id]
     HostKeyAlgorithms=+ssh-dss
(2) 이제 ssh [hostname] 으로 접속할 수 있다. 
    

2014년 9월 1일 월요일

젓가락과 숟가락

요즘에 사람들이 밥먹는 모습을 보면 숟가락을 보다는 젓자락을 사용하여 밥을 먹는 모습이 많이 보인다. 국이나 비빔밥같이 젓가락을 사용하기 어려운 경우를 제외하고는 대부분의 경우 젓가락을 사용하여 밥을 먹는 것 같다. 예전에는 그렇지 않았던 것 같은데, 왜 일까? 쌀을 주식으로 하는 아시아의 많은 나라에서 젓가락을 도구로 사용하는 것은 흔하지만, 숟가락을 이용하여 쌀을 먹는 것은 우리나라만의 특징이 아닐까 생각한다. (다른 나라에서 그렇게 먹는 경우를 보지 못한 것 같다.) 그런데, 왜 그러한 모습을 보기가 힘들어 지는 것일까?( 적어도 공공 식당에서 내가 관찰한 바로는 그렇다.)

생각나는 이유는

(1) 숟가락을 밥을 떠서 먹는 것이 보기 안 좋아서?
(2) 숟가락과 젓가락을 함께 쓰는 것이 귀찮아서?
(3)  외국(일본, 중국)의 영향?
(4) 건강을 위해서? ( 젓가락을 사용하면, 국물의 섭취가 적어지므로  나트륨 섭취를  줄일 수 있고, 조금씩 먹게 되므로 소식에 도움이 된다고 생각할 수 있다.)

내 경우에는 (1), (2) 번이 복합적인 것 같다. 다른 사람들은 어떤지 궁금하다.

2014년 8월 3일 일요일

ipython autoreload

Class 나 file 을 import 한 뒤에 수정한 뒤 다시 import 를 해도 수정된 결과가 적용이 안되는 경우 ipython 에서는 쉽게 해결할 수 있다.
다음과 같이 autoreload 라는 ipython magic 을 사용하면 된다.


In [1]: %load_ext autoreload

In [2]: %autoreload 2

In [3]: from foo import some_function

In [4]: some_function()
Out[4]: 42

In [5]: # open foo.py in an editor and change some_function to return 43

In [6]: some_function()
Out[6]: 43

2014년 7월 24일 목요일

Making a tuple by iteration 여러개의 tuple을 하나의 tuple로 만들기

예를 들어 a=(1,2) 과 b=3 을 c=(1,2,3) 으로 바꾸고 싶다면 어떻게 할까?

+ operator for tuple 을 사용하면 된다. 단, tuple+tuple 의 형태가 되어야한다. 따라서
b 대신, (b,) 으로 tuple로 바꾸어서 더해준다.

예를 들어
a=(1,2)
b=3
c=a+(b,) ==> gives (1,2,3)


한편, 이렇게 만든 tuple을 function의 argument로 사용하기 위해서는
tuple unpack 을 해주어야한다.

예를 들어, argument 가 3개인 함수에 tuple을 사용하려면,

tuple=(1,2,3)
func(tuple) ==> gives ERROR
func(*tuple)==> equivalent to func(tuple[0],tuple[1],tuple[2])





2014년 7월 23일 수요일

VMWARE 에서 마우스 위치가 일치하지 않는 문제

어느 순간부터 VMWARE PLAYER 의 host 와 guest 사이에
마우스 포인터가 일치하지 않는 문제가 생겼다.

guest에 click을 했을때 mouse 의 시작 위치가 host 에서 클릭한 위치와 다르게 되어서
매번 다시 클릭을 해야하는 것이다.

이것은 아래와 같은 내용을 vmx file에 추가하는 것으로 해결되었다.

mouse.vusb.enable = "TRUE"
mouse.vusb.useBasicMouse = "FALSE"
usb.generic.allowHID = "TRUE"



2014년 7월 22일 화요일

black screen after login screen 로긴 화면 다음에 검은 화면이 나오는 문제

display problem after update/upgrade ubuntu

우분투를 사용하면서 무심코 업데이트를 시켰는데,
리부팅후 로그인 후 갑자기 화면이 검게 변하면서 아무런 반응을 보이지 않는 현상이 생겼다.
인터넷을 찾아보니 다음과 같은 방법으로 해결할 수 있었다. 하지만, 여전히 문제가 완전히 해결된 것인지는 확실하지 않다.

증상: 로그인 화면까지는 정상적으로 나타난다. 하지만, 로그인을 하고 나면 black screen으로 변한다.
2014/12/11: Nvidia driver 를 update 한 뒤 비슷한 문제가 다시 생겼다.

해결책: 확실하지는 않지만, 일단 다음과 같은 방법으로 로그인후 정상적인 화면이 나타나도록 되었다.

(1) 로그인 화면에서 CTRL+ALT+F1 을 누른다. 그러면 terminal과 비슷한 text 화면이 나타난다. (Emergency text/command terminal)
(2) 로그인 후, 다음 명령으로 xserver-xorg를 제거한다.

    sudo apt-get remove --purge xserver-xorg

2014/12/11: Nvidia driver 를 제거했다. 
    sudo apt-get remove --purge nvidia-*

(3) CTRL+ALT+DEL 을 눌러 리부팅한다.
(4) 리부팅 후 다시 CTRL+ALT+F1으로 prompt 상태로 바꾸어 로그인한다. (원래 설명에서는 UBUNTU logo 와 그 밑의 다섯개 점이 움직이는 동안에 해야만 하고, 로그인 스크린이 나오기 전에 해야만 한다고 하는데, 나의 경우에는 상관이 없었다.
(5) 로그인후 다음 명령으로 xserver-xorg를 다시 install 한다.

sudo apt-get install xserver-xorg

(6) xorg 설정을 다시 한다.

sudo dpkg-reconfigure xserver-xorg

(7) 리부팅 후 로그인하면, 문제가 해결되었다. (원래 설명에서는 startx 를 사용하여 GUI 로 바꾸라고 되어 있는데, 상관 없는 듯 하다.)


2014년 7월 9일 수요일

Python: 길이를 모르는 리스트에 format 사용하기.


python format string을 길이를 정하지 않은 일반적인 리스트에 적용해야 할 경우 다음과 같은 방법을 사용한다.

Using string format for unknown length of argument, tuple, list

예를 들어 함수에 임의의 argument를 받은 다음, argument를 정해진 format에 따라 출력하고 싶다고
하자.

먼저, 함수에 arbitrary number of argument를 사용하려면 * 를 사용한다.
>>> def StartDance(*args):
        return "%d, %d, %d, %d!" % tuple(args)

>>> StartDance(5, 6, 7, 8)
'5, 6, 7, 8!'
하지만, 위의 경우 argument의 갯수가 4개의 경우만 format이 정해져 있기 때문에 다른 수의 argument를 넣으면 (예를 들어 (1,2) 나 (1,2,3,4,5) ) Error 가 발생한다.  
이럴 때, string multiplication 과 join 을 이용할 수 있다.
>>> def StartDance(*args):
        return (", ".join(["%d"] * len(args))+"!") % tuple(args)
>>> StartDance(5, 6, 7, 8)
'5, 6, 7, 8!'
>>> StartDance(5, 6, 7, 8, 9, 10)
'5, 6, 7, 8, 9, 10!'
>>> StartDance(1)
'1!'

여기서, 
(1) ["%d"]*5 는 ['%d', '%d', '%d', '%d', '%d'] 과 같다.
(2) ", ".join(['%d', '%d', '%d', '%d', '%d'] ) 는  '%d, %d, %d, %d, %d' 와 같다.
S.join(iterable) -> string                                                                                                                            
Return a string which is the concatenation of the strings in the                                                                
iterable.  The separator between elements is S.                                                                                      
(3) +"!" 는 string의 마지막에 ! 를 붙여준다.
(4) tuple(args)는 주어진 args를 tuple (1,2,3,4) 로 바꾸어 준다.


아래 방법은 일일이 ['1,','2,','3,'..] 으로 list를 먼저 만든 다음에 하나의 string으로 만드는 것이고
print ' '.join(['%-2s' % (i,) for i in lst])
아래는 fotmat을 먼저 '%s %s %s ...'  식으로 만들어서 print 하는 것이다.
print ('%-2s ' * len(l))[:-1] % tuple(lst)
일반적으로 string multiplication을 이용하는 것이 효율적이다.


2014년 7월 6일 일요일

Linux 에서 Path 지정하기 (Original page http://www.cyberciti.biz/faq/unix-linux-adding-path/)

UNIX / Linux: Set your PATH Variable Using set or export Command


Finding out your current path

 
echo "$PATH"
 
OR
 
printf "%s\n" "$PATH"
 
How do I modify my path?
Bash, Sh, Ksh shell syntax to modify $PATH
If you are using bash, sh, or ksh, at the shell prompt, type:
## please note 'PATH' is CASE sensitivity and must be in UPPERCASE ##
export PATH=$PATH:/path/to/dir1
export PATH=$PATH:/path/to/dir1:/path/to/dir2
 
OR
## please note 'PATH' is CASE sensitivity and must be in UPPERCASE ##
PATH=$PATH:/path/to/dir1; export PATH
 
Tcsh or csh shell syntax to modify $PATH
If you are using tcsh or csh, shell enter:
 ## please note 'path' is case sensitivity and must be in lowercase ##
set path = ($path /path/to/dir1)
set path = ($path /path/to/dir1 /path/to/dir2)
 
OR
## please note 'PATH' is CASE sensitivity and must be in UPPERCASE ##
setenv PATH $PATH:/path/to/dir1
setenv PATH $PATH:/path/to/dir1:/path/to/dir2
 
To make these changes permanent, add the commands described above to the end of your~/.profile file for sh and ksh shell, or ~/.bash_profile file for bash shell:
## BASH SHELL ##
echo 'export PATH=$PATH:/usr/local/bin'  >> ~/.bash_profile
 
KSH/sh shell user try:
## KSH / SH SHELL ##
echo 'export PATH=$PATH:/usr/local/bin'  >> ~/.profile
 
In this final example add /usr/local/bin/ and /scripts/admin/ to your path under csh / tcsh shell, enter:
 
set path = ($path /usr/local/bin /scripts/admin)
 
OR
 
setenv PATH $PATH:/usr/local/bin:/scripts/admin
 
To make these changes permanent, add the commands described above to the end of your~/.cshrc file:
 
echo 'set path = ($path /usr/local/bin /scripts/admin)'  >> ~/.cshrc
 
OR
 
echo 'setenv PATH $PATH:/usr/local/bin:/scripts/admin'  >> ~/.cshrc
 
To verify new path settings, enter:
$ echo $PATH

2014년 6월 12일 목요일

Linux Library 사용하기

Linux 에서 사용하는 library는 크게 두가지로 나뉜다.


  • Static library
  • Shared library(or Dynamical library)


Ubuntu software center 에서 library 를 찾아보면 static 인 경우도 있고 shared 인 경우도 있다. 초보자의 입장에서는 별로 상관이 없고, 사용법만 알 면 될 것 같은데,
문제는 경우에 따라 다운 받은 library를 사용하는 데 compiler 가 library를 못찾는 경우가 있다.

저장되는 library는 3가지 중에 하나의 이름을 가진다.

  • linker 가 사용하는 이름: 'lib' 로 시작하고 '.a' 나 '.so' 로 끝나는 이름. '.a' 는 static library 인 경우이고 '.so'는 shared object library인 경우이다. (예: libpthread.so) 이것은 Dynamic library 라고 불린다. 
  • Fully qualified name or soname: linker 가 사용하는 이름과 같지만, 마지막에 버전 넘버가 붙는다. (예: libpthread.so.1) 
  • Real name : 버전 넘버 뒤에 마이너 버전 넘버가 붙는 경우.(예: libpthread.so.1.1 )


library를 다운 받으면 보통 다음 3개 directory 중 하나에 저장된다고 한다.

  • /lib   : 처음 linux start up 에서 사용되거나 root file system이 사용하는 library들이 위치한다.
  • /usr/lib : 대부분의 user 가 사용하거나 system 이 internally 사용하는 library들이 위치한다. 
  • /usr/local/lib : standard libary가 아닌 대부분의 library가 위치한다.

이러한 표준 directory에 저장된 경우 특별한 위치 지정이 없어도 library를 컴파일러가 알아서 찾지만, 그 이외의 특별한 위치에 저장되면 그 위치를 알려 주어야만 library를 사용할 수 있다.  

보통 지정해 주어야하는 directory는 linker 가 사용하는 이름인 *.a 나 *.so 가 있는 곳이다.

gcc -L/usr/lib -llapack -lmathlib

gcc 에서 -L 은 디렉토리 위치를 추가하기 위한 것이고, -l 은 library를 불러오기 위한 것이다.
여기서 -l 뒤에 library의 이름을 붙이는데 library 이름 중 lib 는 뺀다. (예를 들어 원래 library 이름이 liblapack.a 일 때 lapack 만 사용한다.)

2014년 6월 11일 수요일

Ubuntu Setting Up

내가 항상 vmware 로 새로운 우분투를 깔 때마다 새로 설정해야하는 사항들을 모아보자.

1. 우분투 설치하기 및 update

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install build-essentials

2. Tweak : scroll bar 설정, launcher 의 icon size변경, work space 사용하기 등등...

  • make a shortcut of terminal to task bar
  • Repository and package manager (In System> software and update)
        enable the Canonical Partners’ Repository.
        sudo apt install synaptic
        sudo apt install gdebi

  • Additional Drivers (In System> software and update)
  • enable Workspace( System Settings >>> Appearance >>> Behavior)
  • Fix app menu problem(System Settings >>> Appearance >>> Behavior tab >> ‘Show the Menus for a Window’ . always displayed)




3. install Java: sudo apt-get install default-jre

4. Nautilus configuration:
  • open terminal command in nautilus: sudo apt-get install nautilus-open-terminal 
(From 16.04, it seems not need to install nautilus-open-terminal. Also, new terminal opens a new tab by 'control-shift-T' )
  • nautilus action configure tool to make customization of right click in nautilus :
  • sudo apt-get install nautilus-actions-configuration (From 16.04, I could not find the package)        
  • Bookmark the network server I use
  • install meld nautilus-compare
5. classic menu indicator

6. dropbox 설치
    sudo apt install nautilus-dropbox

7. secpanel

8. Texworks and latex
    : for tex, install texlive, texlive-extras, texlive-publishers (for revtex)

9. Numerical libraries:
  • gfortran 
  • LAPACK, SCALAPACK: liblapack, libscalapack 을 검색해서 install 
    (여러 패키지중에서 dev 가 붙어 있고 static 이라고 쓰여 있는 것. liblapack.a 파일이 있는지 확인할 것.)
  • MATHLIB: install libmathlib2-dev   or install cernlib
  • MPICH: 
      sudo apt install gfortran
      sudo apt install libmpich-dev
      sudo apt install liblapack-dev
      sudo apt install libscalapack-mpi-dev
      sudo apt install libmathlib2-dev cernlib 
  • FFTW3:  sudo apt-get install  fftw3-dev 

10. build-essential package

     sudo apt install build-essential
     sudo apt install gfortran

11. vim and change its color scheme : vimrc file 복사하기, encryption method change
     ( default vi editor is not good to use.) 

     sudo apt install vim vim-gtk

.vimrc  example
--------------------
" When searching try to be smart about cases
set smartcase
" Makes search act like search in modern browsers
set incsearch
" Show matching brackets when text indicator is over them
set showmatch
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:syntax enable
set background=dark
:colo desert

" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8

" Use Unix as the standard file type
set ffs=unix,dos,mac

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>

" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

" Set encryption method to blowfish
set cm=blowfish
     


---------------------

12. gftp or filezilla

13. variety : wallpaper changer

14. python and ipython, matplotlib, scitools, scipy , pip

     # add alias to .bashrc_aliases file
        alias python=python3  

      sudo apt-get install ipython
      sudo apt-get install python-pip python-tk
      python -m pip install --upgrade pip
pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
# Consider adding this at the end of your ~/.bashrc file
    export PATH="$PATH:/home/[your_user]/.local/bin"
15. Make /bin and /lib directory for personal usage.
    # add path in .basrc
    export PATH=$PATH:/home/yhsong/bin:/home/yhsong/lib

16. gnuplot
    FRESCO

    sudo apt install gnuplot-qt

and more ...


Ubuntu 18.04 : click-action setting.
                One can choose click-action for the dock :
                 'minimize', 'minimize-or-overview', 'previews','cycle-windows'

gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'


10-or-20-things-to-do-after-installing-ubuntu-14-04-trusty-tahr

http://scienceblogs.com/gregladen/2014/04/24/10-or-20-things-to-do-after-installing-ubuntu-14-04-trusty-tahr/

2014년 6월 10일 화요일

Remove/Uninstall Copy.com from Ubuntu

THESE are copied from other site and here for easy reference.



Follow these steps to completely remove Copy from your system:
  1. Disable autostart for each user, if necessary. (You don't need to use sudo if no other user accounts on your system are using Copy)...
    sudo rm -rf /home/<user>/.config/autostart/CopyAgent.desktop
    
  2. Log out and log back in. This will shut down the running copy process so it does not re-create the files you are about to delete in step 3. (You can also just kill the "CopyAgent" process using System Monitor if you don't want to log out.)
  3. Execute the following for each user, if necessary. (You don't need to use sudo if no other user accounts on your system are using Copy).
    sudo rm -rf /home/<user>/<path_to_users_copy_folder>/.copy.cache/
    sudo rm -rf /home/<user>/<path_to_users_copy_folder>/.user_info
    sudo rm -rf /home/<user>/.copy
    sudo rm -rf /home/<user>/.icons
    
  4. If you had manually installed the Nautilus overlay icons, uninstall them...
    sudo <installation_location>/<architecture>/CopyCmd Overlay remove
    
  5. Uninstall Copy software...
    sudo rm -rf /root/.copy
    
  6. If you had manually added a launcher shortcut, remove it. Assuming you called the launcher "copy.desktop" do the following.
    For all users...
    sudo rm  /usr/share/applications/copy.desktop
    
    Or, for each user...
    sudo rm  /home/<user>/.local/share/applications/copy.desktop
    
Note, in the above steps...
  • Replace <user> with the user on your system that is using Copy.
  • Replace <path_to_users_copy_folder> with the user's local "Copy" folder (for example, Documents/Copy).
  • Replace <installation_location> with the location where you installed Copy (for example /usr/share/copy).
  • Replace <architecture> with "x86" (if you have a 32bit computer) or with "x86_64" (if you have a 64bit computer).

스트레스 줄이기


2014년 5월 22일 목요일

그래프에서 데이터 읽기

우연히 검색해서 찾아낸 툴 : Curvesnap

논문에 숫자가 아닌 그래프로 데이터가 나와 있는 경우,
그것을 숫자 테이블로 바꾸어 주는 프로그램이다.
어느 정도의 에러를 감안할때 꽤 그럴 듯한 값을 끄집어 낼 수 있다.
사용법도 나름 편리. 자세한 것은 링크를 참조....(귀찮은가)

나중에 좀 자세히 쓰자.


http://xoofee.com/2012/12/curvesnap/

2014년 5월 19일 월요일

Linux tips

1. VI, VIM tips

(1)Case Insensitive search in vi

 If you want to ignore case for one specific pattern, you can do this by
prepending the "\c" string. Using "\C" will make the pattern to match case.

(2) Change characters into all lower or upper capitals.

 ":%s/[A-Z]/\L&/g" or  ":%s/[a-z]/\U&/g" 


(3)Copy/Paste to/from clipboard.

: Check 'vim --version' if it has '+clipboard' .  If it is not, one may install vim-gnome or vim+gtk.
  One can copy to clipboard after selecting in visual mode by "+y 
  (With shift key, press " and press + , then release shift key and press y ). 


 2. SED tips


(1) search strings with special character :  put \ in front of any special character
(2) wild character : use .* instead *
   Ex:    sed ‘s/\[.*\]/xxx/’    replaces string ‘[......]’ to ‘xxx’


 Removing ^M from file: 



 1. To remove the ^M character, in ViM, write the following in the command mode and press :w to save the changes:

 :set fileformat=unix

 2. Or, type this script in ViM, in the command mode and type :w to save the changes:
   ^V^M gives ^M character in the screen
:1,$s/^V^M//g

 3. With sed:

 $ sed 's/^M//g' filename > newfilename

 4. With Dos2Unix:

 $ dos2unix filename newfilename

 5. With col:

 $ cat filename | col -b > newfilename

 use Internet Explorer (IE) as an FTP client.
ftp://[id]@[ftpaddress]:{port} or ftp://[ftpaddress]:{port}


 change multiple file names


rename "s/ *//g" *.mp3


 column editing:


Notepad++, Visual Studio, and some others: Alt + drag.
vim: Ctrl + v 
Netbeans 7.1 can select columns (Rectangular Selection) with Ctrl + shift + R 
Since Eclipse 3.5, you just need to type Alt+Shift+A
In Kate toggle Ctrl + shift + B


 Delete many files except several:


        [wild cards][Control+shift+x, *]   (즉 ^X*) 
        shows all visible files match. Then remove those from the list to keep.


VIM editor encryption:

1. edit .vimrc file and add 'set cm=blowfish'. This gives better encryption.
2. Set encrption password by ':X'
3. make change and save file. Now the file is encrypted.
4. To remove ecncryption, set blank key by 'set key=' .


        

Python tips

1. change list of strings to list of arrays
   (1) use map(command, list) : apply ‘command’ to all elements of ‘list’
        -> in python 2: map returns list
        -> in python 3: map returns iterator


   (2) use list comprehension: [ ‘cmd’(x) for x in ‘list’]


2. search strings in lists
  (1) return index of matching list elements
   matching= [lines.index(s) for s in lines if "searching" in s]


3. join two arrays as columns
   np.column_stack(array1,array2)


4. multiple arguments as a tuple or unpack tuple
   *(tuple) unpacks the tuple
   **(dictionary) unpacks the dictionary
   it enables
   (1) defined function to receive arbitary number of arguments
         def f(*arguments)
    (2) passing arguments as tuple
         x=(1,2,3)
         f(*x) is equivalent f(1,2,3)

Fortran : string 관련 tips


1. Change between numbers and characters(string)
  (1) Use CHAR(48+num) trick: However this works only for 1 digit number
  (2) Use internal file method :

* To convert number into strings, write

          WRITE(string_name,format) number

          (be careful that we need to use I3.3 instead of I3 to
          put zeroes on the left of number )

        * To convert strings into number, read

         READ(string_name,format) number

   (3) If we need only part of  string, use slicing

         string(begin:end)

       *In case of one character, string(num) does not work.
        Have to use

         string(num:num)  

   예를 들어서 길이가 달라지는 변수에 대해 format string을 쓰고 싶은 경우. 
   길이가 n 인 실수 array v(1:n) 를 출력한다고 하자. 
 
    WRITE(fmt_str,'(a,i2.2,a)') '(1x,' , n , '(f15.7,1x))'     

    ( n=3인 경우) fmt_str 은 '(1x,03(f15.7,1x))' 가 되고 

    WRITE(* , trim(fmt_str)) v    
    로 v 를 출력할 수 있다. 
  

2. Deal with system commands in Fortran
(1) get_command_argument(i,arg): get command arguments  
                             return i-th command argument as string
                             0-th argument is command itself

(2) SYSTEM( strings  )  : use system command

(3) TRIM : Removes trailing blank characters of a string

(4) call getcwd(path): get current working directory
      call chdir(path)   :change current working directory
      포트란의 기본 인풋/아웃풋 들, 파일 핸들링은 current working directory를
      기준으로 한다. call SYSTEM(‘cd path’)
      does not actually change the environment for fortran

3. quotes in strings : ‘’ represent ‘ in string. thus ‘’’ x’’’ -> ‘x’

4. Fw.d : 전체 캐릭터 수가 w 이고,( 부호, . 포함), 소수점뒤로 d 캐릭터
   Ew.d:  전체 캐릭터 수가 w 이고,( 부호, ., E+00 포함) 소수점 뒤로 d 캐릭터