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

Qt에서 emacs key binding 사용하기

tips & tricks/Qt 2020. 8. 19. 15:04 by manywaypark
  1. Help > About Plugins... 에서 emacs plugin을 활성화 (이후 Qt Creator 재시작 필요함)
  2. Tools > Options... 에서 Environment > Keyboard 에서 아래 Emacs.kms 다운로드 후 import!
    Emacs.kms

ref: machinekoder.com/running-qt-creator-in-emacs-mode/

갑자기 코드 자동완성이 안되는 경우가 발생했는데, 해결법은 아래와 같다. 좀 이상하게도 플러그인을 disable해야한다.

Help > About Plugins... 에 들어가서 ClangCodeModel을 시작시 로드하지 않게 uncheck한 다음 Qt Creator를 재시작한다.

현재 환경 참고:

Qt Creator 4.11.0
Based on Qt 5.14.0 (MSVC 2017, 32 bit)
Built on Dec 10 2019 12:27:13
From revision 017ed74400

ref: https://forum.qt.io/topic/107498/code-completion-is-not-working-in-qtcreator/3

 

Code completion is not working in QtCreator?

Hi, Great. Works like a charm. :) But what is the problem with ClangCodeModel? Is this BUG?... Regardsi Mucip:)

forum.qt.io

 

happy hackin'

Function has no local return

함수형 언어/Elixir 2020. 2. 27. 20:22 by manywaypark

dialyzer(discrepancy analyzer)는 Erlang의 static analyzer(정적분석도구)이다. type safety가 확보되면 아주 많은 오류를 줄일 수 있다. 그런데 이 좋은 도구인 dialyzer를 사용하다보면 언듯 보기에 멀쩡한 부분에서 "function foo/2 has no local return" 이라는 경고를 만나게 된다.

일단 참고 아티클에서 발췌:

'Function Name/Arity has no local return' is the standard Dialyzer warning emitted whenever a function provably doesn't return anything (other than perhaps raising an exception) because one of the function it calls happens to trip Dialyzer's type error detector or raises an exception itself. When such a thing happens, the set of possible types of values the function could return is empty; it doesn't actually return. This error propagates to the function that called it, giving us the 'no local return' error.

대충 요약하자면 return이 없거나 영원이 return되지 않을 것(crash 등)으로 추측되는 경우 dialyzer에서 이 경고가 나온다는 말인데...

내 경험상 해결 방법은 다음 방법들 중에 하나를 쓰면 된다. 

  1. dialyer에게 type inference hint를 준다. 즉, @spec을 제대로 써주면 해결됨 (dialyer는 좁은 범위를 제시하면 훨씬 똑똑하게 동작함)
  2. error, exception, raise 등이 발생하는 경우(1차적으로 눈에 보이지 않더라도 call stack을 따라 전파됨) return type에 명시적으로 return이 없을 수 있다고 명시한다.
    - Erlang은 no_return()
    - Elixir는 RuntimeError를 try rescue/catch 등의 방법으로 처리

 

ref: https://learnyousomeerlang.com/dialyzer#typing-about-types-of-types

 

Type Specifications and Erlang | Learn You Some Erlang for Great Good!

Hey there, it appears your Javascript is disabled. That's fine, the site works without it. However, you might prefer reading it with syntax highlighting, which requires Javascript! Type Specifications and Erlang Back in Types (or lack thereof), I introduce

learnyousomeerlang.com

happy hackin'

module을 정의할 때 attribute, directive 등의 순서는 아래와 같이 정리하면 좋다.

@moduledoc
@behaviour
use
import
alias
require
@module_attribute
defstruct
@type
@callback
@macrocallback
@optional_callbacks

 

ref: https://github.com/christopheradams/elixir_style_guide#module-attribute-ordering

 

christopheradams/elixir_style_guide

A community driven style guide for Elixir. Contribute to christopheradams/elixir_style_guide development by creating an account on GitHub.

github.com

happy hackin'

명령행에서 diskpart를 이용하면 된다.

diskpart.exe 실행해서 한번에 해결하기:

diskpart.exe
DISKPART> list disk
......
DISKPART> select disk [disk-number-here]
DISKPART> clean
DISKPART> create partition primary
DISKPART> list partition
......
DISKPART> select partition 1
DISKPART> active
DISKPART> format fs=fat32 quick

 

NOTE: clean 단계 이후에는 그냥 GUI에서 format 해도 될 듯하다.

 

ref: https://miuna3.tistory.com/105

 

happy hackin'

현재 실행중인 docker container를 어떻게 실행했는지 잘 생각이 안나는 경우가 있다 (중요한 container는 run command를 파일로 남겨 놓는 것을 추천한다).

runlike라는 utility를 사용하면 되는데....
local에 깔기 귀찮으니깐 docker를 이용해서 이렇게 한다.

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
    assaflavie/runlike YOUR-CONTAINER


예:

$ sudo docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike repo
......
docker run --name=repo --hostname=repo.teevr.io --env="PATH=/usr/local/erlang/17.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --env="LEOFS_VER=1.2.8" --expose=8080 --expose=10020 --expose=22 --expose=10021 --expose=10011 --expose=10010 --restart=always --detach=true firejun/leofs /usr/local/leofs/bin/start_leofs.sh


ref:
https://stackoverflow.com/questions/32758793/how-to-show-the-run-command-of-a-docker-container

 

How to show the run command of a docker container

I use a third party GUI (Synology Docker package) to setup a docker container. However, it's limitation makes me need to run the container from the command line. (I want to map another host ip to b...

stackoverflow.com

 

happy hackin'

vcpkg는 다 좋은데 특정 버전/이전 버전의 라이브러리를 쓰려면 명시적인 명령어가 없어서 좀 번거롭다.
다음의 과정을 거쳐서 특정버전의 라이브러리를 쓸 수 있다.

  1. 라이브러리의 특정 버전 commit id(sha)를 알아낸다.
  2. ports/ 디렉토리의 파일들을 sha를 사용해서 가져온다(checkout).
  3. 라이브러리를 (재)설치한다

현재 설치된 최신의 protobuf(3.9.1)를 3.8.0로 교체하는 예를 들어보겠다.

C:\libs\vcpkg>git log ports/protobuf
......
commit 1a63672f8fa796b044c839c777f7113ccea6e635
Author: myd7349 <myd7349@gmail.com>
Date:   Wed Jun 19 04:34:43 2019 +0800

    [protobuf] Update to 3.8.0 (#6739)

    * [protobuf] Update to 3.8.0

    * [nlopt] set options off

    * [shogun] should not use CMAKE_SYSTEM_PROCESSOR in port file

    * [protobuf] Add Homepage

    * [protobuf] turn warning flag off
......
C:\libs\vcpkg>git checkout 1a63672f8fa796b044c839c777f7113ccea6e635 -- ports/protobuf
C:\libs\vcpkg>vcpkg remove protobuf:x86-windows
The following packages will be removed:
    protobuf:x86-windows
Removing package protobuf:x86-windows...
Removing package protobuf:x86-windows... done
Purging package protobuf:x86-windows...
Purging package protobuf:x86-windows... done

C:\libs\vcpkg>vcpkg install protobuf:x86-windows
The following packages will be built and installed:
    protobuf[core]:x86-windows
Starting package 1/1: protobuf:x86-windows
Building package protobuf[core]:x86-windows...
-- Downloading https://github.com/google/protobuf/archive/v3.8.0.tar.gz...
-- Extracting source C:/libs/vcpkg/downloads/google-protobuf-v3.8.0.tar.gz
-- Applying patch fix-uwp.patch
-- Applying patch disable-lite.patch
-- Using source at C:/libs/vcpkg/buildtrees/protobuf/src/v3.8.0-f0fa939850
-- Configuring x86-windows
-- Building x86-windows-dbg
-- Building x86-windows-rel
-- Installing: C:/libs/vcpkg/packages/protobuf_x86-windows/tools/protobuf/protoc.exe
-- Installing: C:/libs/vcpkg/packages/protobuf_x86-windows/share/protobuf/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package protobuf[core]:x86-windows... done
Installing package protobuf[core]:x86-windows...
Installing package protobuf[core]:x86-windows... done
Elapsed time for package protobuf:x86-windows: 9.415 min

Total elapsed time: 9.415 min

The package protobuf:x86-windows provides CMake targets:

    find_package(protobuf CONFIG REQUIRED)
    target_link_libraries(main PRIVATE protobuf::libprotoc protobuf::libprotobuf)


C:\libs\vcpkg>cat ports/protobuf/CONTROL
Source: protobuf
Version: 3.8.0
Homepage: https://github.com/google/protobuf
Description: Protocol Buffers - Google's data interchange format

Feature: zlib
Description: ZLib based features like Gzip streams
Build-Depends: zlib
C:\libs\vcpkg>

현재 설치되어 있지 않은 라이브러리라면 remove를 할 필요는 없다.

ref: https://github.com/Microsoft/vcpkg/issues/1681

happy hackin'

윈도우즈에서는 뒤에 버전번호가 붙은 DLL은 좀 귀찮은 면이 많다. 아마도 자동으로 symlink를 생성할 수 없어서 기본으로 버전번호가 붙은 DLL만 생성되는 것으로 보인다.

따라서 그냥 없애는 것이 편하다.

간단하게 아래 두 방법 중 하나를 선택하면 되는데...

CONFIG += skip_target_version_ext

또는

VERSION = 0.0.1
win32:TARGET_EXT = .dll

win32에서만 버전번호 없는 dll을 하나 더 생성하게 하는 두번째 방법이 좀더 유용한듯하다.

(즉, 다시말해 완전히 없애는 첫번째 방법을 취한다면 unix 계열에서 우아하게 버전번호 붙이고 버전 번호 없는 대표명으로 링크 생성하는 것이 동작하지 않는다)

refs:

happy hackin'

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

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

03-19 11:02