01 Aug 2018
|
Android
BroadcastReceiver 코딩 템플릿
다음은 BroadcastReceiver 프로그래밍 템플릿입니다. register/unregister를 BroadcastReceiver 외부에서 하는 방법도 있는데, 개인적으로는 해당 클래스 내부에 하는 것이 결합도는 낮아지고 응집력도 더 높아지며 코드도 깔끔해지는 것 같습니다.
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
public class EventBroadcastReceiver extends BroadcastReceiver {
static final String ACTION_EVENT_DEBUG_ON = "ACTION_EVENT_DEBUG_ON";
static final String ACTION_EVENT_DEBUG_OFF = "ACTION_EVENT_DEBUG_OFF";
final Context context;
public EventBroadcastReceiver(Context ctx) {
this.context = ctx;
}
public void init() {
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_EVENT_DEBUG_ON);
filter.addAction(ACTION_EVENT_DEBUG_OFF);
context.registerReceiver(this, filter);
}
public void fin() {
context.unregisterReceiver(this);
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (ACTION_EVENT_DEBUG_ON.equals(action)) {
// TODO
} else if (ACTION_EVENT_DEBUG_OFF.equals(action)) {
// TODO
}
}
}
21 Jul 2018
|
리눅스
Ubuntu
리눅스에서 mp3 파일을 ogg 파일로 변경하는 방법
리눅스(Ubuntu)에서 mp3 파일을 ogg 파일로 변경하는 방법은 다음과 같습니다.
sudo apt-get install dir2ogg
dir2ogg -r /path/to/mp3s/
15 Jul 2018
|
리눅스
Ubuntu
apt 명령어 실행시 apt-get -f install 오류 발생하는 경우
apt 명령어를 실행할 때마다 아래와 같은 오류 메시지가 계속 발생하는 경우가 있을 수 있습니다.
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
pcl : Depends: libvtk6.2 but it is not installed
Depends: libvtk6.2-qt but it is not installed
E: Unmet dependencies. Try using -f.
이 경우는 다음 명령어로 해결할 수 있습니다.
<pre class=”prettyprint”
sudo apt –fix-broken install
sudo apt-get update
sudo apt-get upgrade
</pre>
15 Jul 2018
|
git
Git Submodule 사용 방법
Submodule을 추가하려는 부모를 parent라고 하고, Submodule로써 추가되려는 자식을 child라고 가정할 때, 다음과 같이 사용할 수 있습니다.
git submodule 추가 방법
아직 parent에 submodule이 추가되지 않은 상태에서 다음 명령어를 입력하여 submodule 추가를 해줄 수 있습니다.
git clone git@github.com:snowdeer/parent.git
cd parent
git submodule add git@github.com:snowdeer/child.git child
git commit -m "submodule is added."
git push
이 때, 별도로 git add 절차 없이 바로 commit 할 수 있습니다.
git clone으로 parent를 가져왔을 때
git clone으로 parent를 가져왔을 때, 내부의 child는 디렉토리만 만들어져 있고 내부가 없습니다. 이 때 submodule 초기화 및 업데이틀 해 주어야 합니다. 루트에서 다음 명령어를 실행하면 됩니다.
git submodule init
git submodule update
다만, 이 때 submodule의 소스 버전은 최신 버전을 가리키는 것이 아니라, submodule add를 수행했을 때의 버전을 가리키고 있습니다. submodule은 리파지토리가 실제로는 분리되어 있기 때문에 각 모듈의 버전이 따로 관리되는데, parent 프로젝트에서는 현재 submodule의 버전이 최신인지 아닌지 신경쓸필요없이 안정적인 특정 버전만 가리키면 되기 때문에 프로젝트 배포 등에서는 관리가 수월한 장점이 있습니다. 물론, 개발중인 프로젝트에서는 각 submodule들을 최신 버전으로 유지해야 할 경우 각 submodule들의 업데이트를 수동으로 한 번씩 더 해줘야 하는 단점이 있기도 합니다.
submoudle 최신 버전으로 교체
submodule을 최신 버전으로 교체하는 방법은 다음 같습니다.
child 디렉토리에 들어가서 각각의 submodule들을 개별 업데이트 해주는 방식. 각 submodule 디렉토리에서 git pull 명령어나 git checkout 명령어 등을 이용해서 업데이트 가능.
parent내에서 git submodule foreach git pull origin master 명령어를 실행하여 하위 submodule들을 전부 업데이트 해주는 방법
12 Jul 2018
|
리눅스 설정
Ubuntu
우분투 18.04 설치 이후 할 일들입니다.
업데이트
Software & Updates를 실행해서 필요한 항목들을 업데이트 합니다.
터미널에서
sudo apt update
sudo apt upgrade
명령어를 통해 업데이트를 해줍니다.
한글 키보드 설치
한글 키보드 설치 방법은 여기에서 확인할 수 있습니다.
키보드 단축키 변경
Setting으로 들어가서 Devices > Keyboard에서 키보드 단축키를 변경할 수 있습니다.
Home folder는 Windows + E
Copy a screenshot of a window to clipboard는 Shift + Ctrl + 1
Copy a screenshot of an area to clipboard는 Shift + Ctrl + 2
Save a screenshot of a window to Pictures는 Shift + Ctrl + 3
Save a screenshot of an area to Pictures는 Shift + Ctrl + 4
sudo apt install gnome-tweak-tool
Dock 설정
Setting에서 Dock 선택. 아이콘 크기는 32 정도로, Dock 위치는 Bottom으로 설정
.bashrc 수정
vscode ~/.bashrc
실행해서 아래라인의 숫자값 늘립니다. 파일 실행 이력 히스토리 크기를 늘리는 방법입니다.
HISTSIZE=99999
HISTFILESIZE=99999
전방 검색(Ctrl + S)을 위한 설정도 해줍니다.
# for (i-search)
stty stop undef
를 추가해줍니다.
Sublime Text 3 설치
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text
D2Coding Font 설치
http://snowdeer.github.io/linux/2017/12/02/ubuntu-install-font-d2coding/
Terminator 설치
sudo apt install terminator