아메리카노가 그렇게 맛있답니다 여러분

apt를 통해 다운받는 node.js는 버전이 낮다. (모듈 추가하는데 오류가 떠서 알게 되었다. v4.8.2로 설치되던데, 이렇게 낮을 줄 몰랐다)

당시에는 적절한 검색어를 통해 의외로 빠르게 해결하였지만 다른 우분투에서 작업하면서 오늘 다시 이 문제에 봉착했다.

상상했던 과거보다 오래 걸렸기 때문에 이번에는 글로 보관해야겠다.


아래의 설명을 보면 되지만 만약에 원문을 보고 싶다면 아래 링크로 이동하면 된다.

https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version



+ 라즈베리는 ARM이라 안되는 것이었다.


To undo:

sudo apt-get install --reinstall nodejs-legacy     # fix /usr/bin/node
sudo n rm 6.0.0     # replace number with version of Node that was installed
sudo npm uninstall -g n


Node.js v9.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs

Node.js v8.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs

Node.js v7.x:

NOTE: Debian Wheezy and Ubuntu Precise packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs

Node.js v6.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs

Node.js v5.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs

Node.js v4.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs

Node.js v0.12:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs

Node.js v0.10:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs

io.js v3.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs

io.js v2.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs

io.js v1.x:

Note: this branch of io.js is not actively maintained and is not recommended for production use.

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs


최근 크롤링을 위해 멀티 쓰레드 환경에서 SImpleDateFormat을 사용하다가 오류가 뜨는 것을 보았다.

나에게 발생한 문제는 NumberFormat이었던가? 여튼 포맷이 틀려서 발생하는 문제였는데 다른 사람의 문제를 찾아보니 ArrayIndexOutOfBound 등 다양한 문제를 야기시켰다.


만약 다중 쓰레드를 쓰는데 SimpleDateFormat 부분에서 오류가 났다면 한 번쯤 내가 SimpleDateFormat을 static으로 써서 그런 것은 아닌지 생각해야 할 것 같다. 의외로 쓰레드 문제 때문에 발생하는 예외의 종류가 획일적이지 않고 다양하다.


남들은 FastDateFormat인가? 하는 라이브러리로 해결할 수 있다고 하는데 이 문제는 점유 문제였기 때문에 clone() 메서드를 써서 static으로 만들어뒀던 SimpleDateFormat을 필요한 곳에 얕은 복사해서 쓰는 방법으로 해결했다. (그냥 쓰레드마다 new SimpleDateFormat()해줬단 뜻)

ionic start ActionSheetExample blank


아무 것도 없는 공백 아이오닉 프로젝트를 만듭니다.



import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

@NgModule({
declarations: [
MyApp,
HomePage,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}


app.module.ts를 들어가보면 HomePage가 보입니다. /src/pages/home/home.ts로 이동해야 Action Sheet를 쓸 수 있을 것 같습니다.



import { Component } from '@angular/core';

import { NavController } from 'ionic-angular';

@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {

constructor(public navCtrl: NavController) {

}

}


지금은 어떤 메서드도 없는 공백 컴포넌트입니다. 여기에 Action Sheet를 사용할 수 있도록 만들면 root-page에서 우리가 원하는 결과를 볼 수 있습니다.



import { NavController, ActionSheetController } from 'ionic-angular';


NavController 옆에 이런식으로 ActionSheetController를 추가해줍니다. import ~ from으로 새로 넣어도 되지만 같은 곳에서 참조하기 때문에 컴마로 구분해서 넣어주는 것이 대부분의 경우 보기 좋습니다.



constructor(public navCtrl: NavController, public actionSheetCtrl: ActionSheetController) {

}


생성자 부분도 새로 추가해주어야 Action Sheet를 사용할 수 있으니 추가해줍시다.

이제 메서드를 만들어야 클릭할 때 원하는 문구들을 뜨게 할 수 있으니 메서드를 추가해봅시다.



presentActionSheet() {
let actionSheet = this.actionSheetCtrl.create(
{
title: "Modify your album",
buttons: [
{
text: "Destuctive",
role: "ROLE:: Destructive",
handler: ()=> {
console.log('Destructive clicked')
}
},
{
text: "Archive",
handler: ()=> {
console.log("Archive clicked")
}
},
{
text: "Cancel",
role: "ROLE:: Cancel",
handler: ()=> {
console.log("Cancel clicked")
}
}
]
}
);
actionSheet.present();
}


참고로 타입스크립트에서는 var말고도 let변수가 있는데 var보다 엄격한 타입이라고 생각하시면 됩니다. (변수명 중복 불가 / 호출 시점 구분/블록 스코프 구분)

this.actionSheetCtrl.create()에서 어떤 값들이 Action Sheet에 뜨게 할 것인지 설정하고, 설정 끝에 actionSheet.present()를 통해 해당 메서드를 동작하면 Action Sheet가 뜨도록 합니다.


모두 추가했다면 home.html로 이동해서 버튼과 버튼에 해당하는 이벤틀르 추가해줍시다.



<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>

<ion-content padding>
<button ion-button (click) = "presentActionSheet()">
SHOW ACTION SHEET
</button>
</ion-content>


blank옵션을 줬을 때 기본으로 생성되는 페이지에 버튼만 추가했습니다.

button 태그는 이름만 보고도 알 수 있듯이 버튼을 만들어주는 역할을 하고, ion-button은 아이오닉에서 지원하는 버튼 모양입니다. ion-button을 넣지 않으면 <input type=file>의 '찾아보기' 같은 모습의 버튼이 보입니다. (click)="메서드()"를 통해 우리가 버튼을 누를 경우 이벤트에 의해 어떤 메서드가 발생하게 할지 정합시다. 저장하면 새 페이지가 로딩되면서 버튼이 추가된 것을 보실 수 있습니다.


[버튼 누르기 전]



[버튼 누른 후]



'프레임워크 > Ionic2(아이오닉2)' 카테고리의 다른 글

ionic2 페이지 이동  (0) 2017.10.16
ionic2 페이지 생성  (0) 2017.10.16
ionic2 프로젝트 구조  (0) 2017.10.15
Ionic2 프로젝트 생성과 실행  (0) 2017.10.15
Ionic2(아이오닉2) 개발환경 설정  (0) 2017.10.15