728x90

test.ph

with open('read.txt', 'r') as fr:
    with open('write.txt', 'w') as fw:
        pre_line = ""
        line = "test"
        filelines = []
        while line != '':
            line = fr.readline()
            if line != pre_line:
                filelines.append(line)
            pre_line = line
        fw.writelines(filelines)
        fw.close()
        fr.close()

filelines에 모두 밀어 넣고 한번에 writelines로 처리했는데 이는 하나씩 writeline으로 처리해도 될 듯 하다.

필요에 의해서 만든 코드인데 read.txt내에 연속으로 중복되는 문자열을 제거하여 write.txt에 저장하는 코드다.

 

>> python3 tset.ph

728x90
728x90

원문 : http://www.openssh.com/legacy.html


If the client and server are unable to agree on a mutual set of parameters then the connection will fail. OpenSSH (7.0 and greater) will produce an error message like this:


Unable to negotiate with legacyhost: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1 



For the case of the above error message, OpenSSH can be configured to enable the diffie-hellman-group1-sha1 key exchange algorithm (or any other that is disabled by default) using the KexAlgorithms option - either on the command-line:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@legacyhost 



or in the ~/.ssh/config file:


Host somehost.example.org 

KexAlgorithms +diffie-hellman-group1-sha1 


OpenSSH 7.0 이상에서는 해당 옵션이 기본으로 enable 되어 있지 않기 때문에

옵션을 넣어줘야 한다.

항상 넣기 귀찮으니 config를 만들어서 넣고 쓰도록 하자.

config파일이 없으면 그냥 생성하면 적용 됨.

728x90
728x90

Original link : https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_MRG/1.2/html/Realtime_Reference_Guide/sect-Realtime_Reference_Guide-Using_library_calls_to_set_priority-sched_get_priority_min_and_sched_get_priority_max.html


#include <stdio.h>
#include <unistd.h>
#include <sched.h>

main()
{


  printf("Valid priority range for SCHED_OTHER: %d - %d\n",
  sched_get_priority_min(SCHED_OTHER),
  sched_get_priority_max(SCHED_OTHER));

  printf("Valid priority range for SCHED_FIFO: %d - %d\n",
  sched_get_priority_min(SCHED_FIFO),
  sched_get_priority_max(SCHED_FIFO));

  printf("Valid priority range for SCHED_RR: %d - %d\n",
  sched_get_priority_min(SCHED_RR),
  sched_get_priority_max(SCHED_RR));
}


Output

Valid priority range for SCHED_OTHER: 0 - 0

Valid priority range for SCHED_FIFO: 1 - 99

Valid priority range for SCHED_RR: 1 - 99



728x90
728x90

vim에서 backspace 되지 않을

~/.bashrc 또는 ~/.bash_profile 추가

stty erase '^?'

 

vim에서 .vimrc 가져오지 못을

~/.bashrc 또는 ~/.bash_profile 추가

alias vim="vim -S ~/.vimrc"

 

 

vim source insight처럼 사용하기(taglist, SrcExpl, nerdTree)

* SrcExpl: http://www.vim.org/scripts/script.php?script_id=2179
* taglist: http://www.vim.org/scripts/script.php?script_id=273
*nerdTree: http://www.vim.org/scripts/script.php?script_id=1658

~/.vim/ 하위에 설치


~/.vimrc 수정

set tabstop=2

set shiftwidth=2

set softtabstop=2

set cindent

set autoindent

set smartindent

set incsearch

syntax on

filetype on

set background=dark

colorscheme evening

set backspace=eol,start,indent

set history=1000

set hlsearch

set showmatch

set nu

"============= Like a Source Insight =============”

"=== Taglist ===

" // The switch of the Taglist

nmap <F7> :TlistToggle<CR>

let Tlist_Ctags_Cmnd = "/usr/bin/ctags"

let Tlist_Inc_Winwidth = 0

let Tlist_Exit_OnlyWindow = 0

let Tlist_Auto_Open = 0

let Tlist_Use_Left_Window = 1

"=== NERDTree ===

" // The switch of the NERDTree

nmap <F9> :NERDTreeToggle<CR>

let NERDTreeWinPos = "right"

"=== Source explorer ===

" // The switch of the Source Explorer

nmap <F8> :SrcExplToggle<CR>

"// Map the keys below to jump from one window to another:

nmap <C-H> <C-W>h

nmap <C-J> <C-W>j

nmap <C-K> <C-W>k

nmap <C-L> <C-W>l

let g:SrcExpl_winHeight = 8

let g:SrcExpl_refreshTime = 100

let g:SrcExpl_isUpdateTags = 0

" // Set “Enter” key to jump into the exact definition context

let g:SrcExpl_jumpKey = "<ENTER>"

" // Set “Space” key for back from the definition context

let g:SrcExpl_gobackKey = "<SPACE>"

map <F3> :tnext^M

map <F2> :tprevious^M

 

경우 F7, F8, F9 이용하여 켜고 있음.


Tag 생성

mktrace.sh

#!/bin/sh

rm -rf cscope.files cscope.files

rm -rf tags


find . \( -name  *.c  -o -name  *.cpp  -o -name  *.cc  -o -name  *.h  -o -name  *.s  -o -name  *.S  -o -name  *.asm  \) -print > cscope.files

ctags -R


cscope -i cscope.files 


728x90

+ Recent posts