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

Ubuntu에서 Nvidia driver 깔기

장치가 인식되어있는지 확인:

$ ubuntu-drivers devices

driver 자동 설치:

$ sudo ubuntu-drivers autoinstall


참조 링크에 더 다양한 방법이 있다.


ref: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux


 happy hackin'

Visual Studio 2017에는 google test가 통합되었구나. 세상이 좋아지고 있다.

https://docs.microsoft.com/ko-kr/visualstudio/test/how-to-use-google-test-for-cpp


happy hackin'

ssh reverse tunneling

tips & tricks/Linux/Unix 2018. 3. 12. 16:01 by manywaypark

기본적으로 ssh, autossh 등을 사용하면 됨. 

systemd 내에서 autossh를 쓸 경우는 좀 tricky한 상황이 생기는 듯 (portforwarding 환경에서는 port forwading에 실패했을 경우 재시작할 때 제대로되지 않는다.

autossh는 자동재시작 등의 기능이 있는데 이것은 systemd에서 제공하는(아주 잘 하는) 기능이다. 두개를 섞으면 좀 이상해지는 것으로 보인다.

좀 검색을 해보니 ssh + systemd가 제대로 잘 동작하는 것으로 보인다. 

좀더 시간을 두고 해결하는 것도 고려해보자.


/etc/systemd/system/secure-tunnel@.service 파일:


[Unit]

Description=Setup a secure tunnel to %I

After=network.target


[Service]

Environment="LOCAL_ADDR=localhost"

EnvironmentFile=/etc/default/secure-tunnel@%i

ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -NR ${LOCAL_PORT}:localhost:${REMOTE_PORT} ${TARGET} -p ${TARGET_PORT}


# Restart every >2 seconds to avoid StartLimitInterval failure

RestartSec=5

Restart=always


[Install]

WantedBy=multi-user.target


/etc/default/secure-tunnel@jupiter 파일:


TARGET=jupiter

TARGET_PORT=2222

LOCAL_PORT=20022

REMOTE_PORT=22


부팅시 실행되게 활성화 및 시작:

systemctl enable secure-tunnel@jupiter.service

systemctl start secure-tunnel@jupiter.service

현재 상태보기:

systemctl status secure-tunnel@jupiter.service

상태 연속으로 보기:

journalctl -f -u secure-tunnel@jupiter.service


refs:

http://system-monitoring.readthedocs.io/en/latest/ssh.html

https://gist.github.com/thomasfr/9707568 -> autossh + systemd

https://gist.github.com/drmalex07/c0f9304deea566842490 -> 최종적으로 (약간 수정해서) 내가 사용한 방법 (ssh + systemd)

https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units -> systemd 관련 상세 설명


2018-03-23 추가:
가끔 network configuration을 변경하면 재접속이 안되는 경우가 발생하는데...
아래와 같은 로그가 찍히면서 재접속 시도가 계속 실패한다.

~$ sudo journalctl -f -u secure-tunnel@tmp01.service
[sudo] password for xxxxxx: 
-- Logs begin at Fri 2018-03-23 16:45:46 KST. --
Mar 23 16:55:37 teevr-lt2 systemd[1]: secure-tunnel@tmp01.service: Failed with result 'exit-code'.
Mar 23 16:55:42 teevr-lt2 systemd[1]: secure-tunnel@tmp01.service: Service hold-off time over, scheduling restart.
Mar 23 16:55:42 teevr-lt2 systemd[1]: Stopped Setup a secure tunnel to tmp01.
Mar 23 16:55:42 teevr-lt2 systemd[1]: Started Setup a secure tunnel to tmp01.
Mar 23 16:55:42 teevr-lt2 ssh[2679]: Error: remote port forwarding failed for listen port 1907
Mar 23 16:55:42 teevr-lt2 systemd[1]: secure-tunnel@tmp01.service: Main process exited, code=exited, status=255/n/a
Mar 23 16:55:42 teevr-lt2 systemd[1]: secure-tunnel@tmp01.service: Unit entered failed state.
Mar 23 16:55:42 teevr-lt2 systemd[1]: secure-tunnel@tmp01.service: Failed with result 'exit-code'.

~$ sudo netstat -plant | grep 1907
tcp        0      0 127.0.0.1:1907          0.0.0.0:*               LISTEN      9949/sshd: xxxxxx
tcp6       0      0 ::1:1907                :::*                    LISTEN      9949/sshd: xxxxxx
tcp6      42      0 ::1:1907                ::1:40842               CLOSE_WAIT  9949/sshd: xxxxxx
tcp6       0      0 ::1:1907                ::1:40838               CLOSE_WAIT  9949/sshd: xxxxxx
tcp6      42      0 ::1:1907                ::1:40848               CLOSE_WAIT  9949/sshd: xxxxxx
tcp6      42      0 ::1:1907                ::1:40844               CLOSE_WAIT  9949/sshd: xxxxxx
tcp6      42      0 ::1:1907                ::1:40840               CLOSE_WAIT  9949/sshd: xxxxxx

접속을 이미 물고 있는 상태(LISTEN)에서 계속 재접속(port bind)을 시도하는 것이었다.
문제는 설정의 ServerAliveInterval이 60초로 설정되어 있고, 재접속시도는 5초만에 하게한 것(RestartSec) 이었다. Orz.
RestartSec을 최소한 ServerAliveInterval 보다는 길게 설정해야한다.

아래 처럼 변경후에 다른 subnet으로 옮기거나해도 잘 동작했다.
ServerAliveInterval=7
RestartSec=10

라고 쓸려고 했으나...
ClientAliveCountMax(default가 3)도 고려해야하므로, ServerAliveInterval * 3 보다 큰 값으로 RestartSec을 설정하면 잘 될거같은데...
실패하는 경우가 생긴다.

그냥 접속안되면 netstat 때려보고 port 물고 있는 pid를 죽이자!

happy hackin'

problem:

Windows, MSVC 환경에서 min이나 max가 포함된 qt 파일(eg, qrandom.h 등)에서 다음과 같은 경고가 나온 후에, 괴상한 에러가 나면서 컴파일에 실패하는 경우가 발생했다.

warning C4003: not enough actual parameters for macro 'max'


solution:

windows.h가 include 되기 전에 다음과 같은 선언을 넣어준다.

#ifndef NOMINMAX

# define NOMINMAX

#endif


ref: https://stackoverflow.com/questions/6884093/warning-c4003-not-enough-actual-parameters-for-macro-max-visual-studio-2010


happy hackin'

choco install erlang --forcex86=true

이렇게 하면 설치는 제대로 되지만 shim이 잘못된 위치(64bit용 위치 즉, \Program Files\ 아래)를 가리키게 되어있어서 오류가 난다.


PS C:\ProgramData\chocolatey> erl

Cannot find file at 'c:\program files/erl9.0/erts-9.0/bin/erl.exe' (c:\program files\erl9.0\erts-9.0\bin\erl.exe). This usually indicates a missing or moved file.


tools/shimgen.exe를 사용해서 다시 생성하면 해결된다.


PS C:\ProgramData\chocolatey\bin> ren erl.exe erl.exe.ERROR

PS C:\ProgramData\chocolatey\bin> ..\tools\shimgen.exe -o C:\ProgramData\chocolatey\bin\erl.exe -p 'C:\Program Files (x8

6)\erl9.0\bin\erl.exe'

PS C:\ProgramData\chocolatey\bin> ren .\werl.exe werl.exe.ERROR

PS C:\ProgramData\chocolatey\bin> ..\tools\shimgen.exe -o C:\ProgramData\chocolatey\bin\werl.exe -p 'C:\Program Files (x

86)\erl9.0\bin\werl.exe'


제목을 'chocolatey에서 shim이 잘못되었을 때 새로 생성하는 방법'으로 할걸 그랬나?


happy hackin'


2018-10-23 추가:

오늘 새로 생긴 박스에 설정하면서 새로 깔아보니 아래와 같은 메시지가 보였다. 이것이 의미하는 바는... 저 5개의 실행파일 모두에 대해서 shimgen을 해 주어야한다는 것이다.

......

Installing erlang...

erlang has been installed.

Added C:\ProgramData\chocolatey\bin\erl.exe shim pointed to 'c:\program files/erl10.0.1/erts-10.0.1/bin/erl.exe'.

Added C:\ProgramData\chocolatey\bin\werl.exe shim pointed to 'c:\program files/erl10.0.1/erts-10.0.1/bin/werl.exe'.

Added C:\ProgramData\chocolatey\bin\erlc.exe shim pointed to 'c:\program files/erl10.0.1/erts-10.0.1/bin/erlc.exe'.

Added C:\ProgramData\chocolatey\bin\escript.exe shim pointed to 'c:\program files/erl10.0.1/erts-10.0.1/bin/escript.exe'.

Added C:\ProgramData\chocolatey\bin\dialyzer.exe shim pointed to 'c:\program files/erl10.0.1/erts-10.0.1/bin/dialyzer.exe'.

......

d3를 예제로 설명한다. 대부분의 npm package는 동일한 방법으로 사용가능하다.


npm을 이용해 d3 설치


cd /path/to/my_web_app

cd ./assets/

npm install --save d3



brunch-config.js 파일에 다음 내용 추가


  npm: {

    ......

    globals: {

      ......

      "d3": 'd3'

    }

  }


이젠 app.js 파일에 등록됨.

다시 말해 app.js를 include하는 모든 페이지의 javascript에서 d3를 사용할 수 있다.


happy hackin'

build emacs for windows 64

emacs 2017. 12. 5. 12:06 by manywaypark

window에서 emacs 직접 build 하는 방법:

(chocolatey에 포함된 emacs64 package 만드는 사람이 작성한 것)

https://github.com/zklhp/emacs-w64/wiki/Guideline-for-building-Emacs-in-MSYS2-MinGW-w64-system


happy hackin'

byobu 내에서 text-mode(=nox) emacs를 실행하면 기본 테마(특히 색상)가 적용되지 않는 것처럼 보이는데, 사실은 byobu의 기본 terminal 설정이 그냥 날(raw) screen이라서 컬러를 표시하지 못하는 것이다.


내 경우는 기본 login terminal에서 컬러표시가 잘되었으므로 아래와 같이 해서 컬러가 표시되게 했다.

$ echo $TERM

xterm-256color

$ echo 'set -g default-terminal "xterm-256color"' >> ~/.byobu/profile.tmux


refs:

https://unix.stackexchange.com/questions/240532/getting-256-colors-to-work-with-byobu

http://osmanov-dev-notes.blogspot.kr/2011/03/how-to-enable-color-prompt-in-byobu.html


happy hackin'




named argument 사용

함수형 언어/Elixir 2017. 9. 11. 12:38 by manywaypark

대충 map을 이용하면 되는데... 좀더 깔끔한 방법이 있다.

자세한 것은 참조 링크 참조.

결론은 아래처럼 NamedArgs를 mix.exs 의존성에 추가하고 필요한 모듈에서 use NamedArgs만 추가하면 끝.

  def deps do

    [

      {:named_args, "~> 0.1.0"}

    ]

  end

사용은 이렇게...

defmodule Talk do

  use NamedArgs

  def introduction(opts \\ [name: "Sarah", birthday: "1985-12-30"]) do

    IO.puts "Hi my name is #{opts[:name]} and I was born on #{opts[:birthday]}"

  end

end


refs:

https://blog.praveenperera.com/named-arugments-with-default-values-in-elixir/

https://github.com/mgwidmann/named_args


happy hackin'

emacs

emacs -mm


emacsclient

아래 방법들 중 하나로 한다.

emacsclient -c -F "'(fullscreen . fullboth)"

emacsclient -c -F "'(fullscreen . maximized)"

alias ecx="emacsclient -c -F \"'(fullscreen . maximized)\""

emacsclient -c -F "((width . 100) (height . 100) (left . 400))"


ref: https://stackoverflow.com/questions/20285965/how-can-i-launch-emacsclient-maximized-from-the-commandline


happy hackin'

1 2 3 4 5 6 ··· 31 
분류 전체보기 (306)
잡담 (20)
함수형 언어 (65)
emacs (16)
java (18)
tips & tricks (154)
사랑 (1)
가사 (0)
독서 (4)
mobile (6)
비함수형 언어 (2)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

04-19 07:18