Webエンジニアの備忘録

およそ自己の作業メモとして残しております。

debianにnodejs、npm、gruntをインストールする

必要なファイル

sudo apt-get update
sudo apt-get install build-essential curl git libssl-dev

バージョン管理ツールを使って入れるのが吉

どうもJS全般でバージョン差異による挙動変化が多く、開発環境下でもそれを変えながら作業する文化があるようだ。
nodejsについてもnvmとnaveと、全く同じ用途のライブラリがある。
ネットで検索しても言っていることはまちまちで、どちらを使ってもいいと思う。
環境によっても違うので、すんなり入りそうな方を自分で選ぶ。

~$ git clone git://github.com/creationix/nvm.git ~/.nvm
~$ source ~/.nvm/nvm.sh

これでnodeをバージョン管理するためのnvmがOK。

~$ nvm install latest
Warning: Failed to create the file 
Warning: /home/ttaniguchi/.nvm/bin/node-N/A-linux-x64/node-N/A-linux-x64.tar.gz
Warning: : No such file or directory
######################################################################## 100.0%
curl: (23) Failed writing body (0 != 162)
Binary download failed, trying source.
Additional options while compiling: 
nvm: install N/A failed!

latest(最新取ってきて)は若干挙動がおかしいときがある。

~$ nvm install 0.10
######################################################################## 100.0%
Now using node v0.10.24
~$ node -v
v0.10.24
~$ nvm list

  v0.10.24
current:    v0.10.24

~$ node -v
v0.10.24
~$ npm -v
1.3.21

やはりこちらが無難でした。
ここまでくれば、Macのときと同じ。

npm install -g grunt-cli

プロジェクト側は先日書いた記事のURL貼っておきます。
http://tak-taniguchi.hatenablog.com/entry/2013/12/21/162543

 

追記

~$ source ~/.nvm/nvm.sh

こちらのシェルはサーバープロセス毎に起動が必要なので、bashなどに記載しておく感じです。

vagrantの中からネットワークアクセスが一切できなくなる事案について

Macでvagrantを立ち上げていて、時々起こる事象がこのネットワーク不具合。

突然ヤフーにdigしてもヤフーにpingしてもヤフーに…(ごめん、ヤフー)

 

とにかく突然繋がらなくなるんです。

このときはネットワーク設定があってようが無線LANがバリ3(笑)であろうが関係ありません。

 

対処方法
[vagrant dir] $ vagrant reload

※あまりにもどうしようもない理由で腹が立ったから書いておく。

 

mac ports と brewは干渉すると訊いて。

$ brew install node
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.

どうも共存はよろしくないらしい。
職場でも複数のパッケージ管理が横行し、往々にしてそれらはお互いの領分を主張しあう。
frontendの開発のお話で、gruntの導入の際に表題の話になった。
おすすめはbrewだったので、わたしもmacportsはこれを機に卒業しようと思う。
記事を書いている人がいたので参照にさせてもらう。
http://qiita.com/paming/items/6e4acf78f0f934b764f5
http://d.hatena.ne.jp/yo_aibou/20121112/1352719113

vSSHについて

vSSHというアプリを購入。
iPhoneからSSHできるターミナルです。
この手のアプリはコンソールにがしがし打つのが現実的でないんだけど、vSSHはマクロを簡単に設定できたり、historyもスワイプで呼びたせたりと便利。
 
ロードやログ監視、緊急時の定型対応なんかいれておくと役に立ちそうだ。
350円でした。
 

vSSH for iPhone

Retinaがすごい件について

f:id:tak_taniguchi:20130217151955j:plain

RetinaディスプレイのMacBookProを買った。

今使っているMacBookAirと同じ13インチだ。

Proはでかいというイメージがあったが、なにげにそれほど変わらない。

それでいて、解像度が高いので、作業エリアはものすごく広くなった。

一度使うと元に戻れないと訊くが、初日で実感した。

 

iPhoneアプリ開発、ViewControllerあたりを写経する

かなり真面目にマニュアルに従って開発作法を学んできたが、Xcodeの作法のところはCSSのパラメータ暗記と通ずるところがあるなあ、という私見を抱いた。

なにが面倒というと、やっぱり覚えなきゃならない呪文が多い。これはXcodeフレームワークを提供しているから仕方ないんだけど、この手の勉強方法は覚えるしか無いんだな、と再確認。

 

ちょっと忘れそうになってきたので、中途だが備忘録を残しておく。

 

    // オブジェクト
    UIView *customView = [[UIView alloc] init];
    customView.frame = CGRectMake(0.0, 0.0, 200.0, 200.0);
    customView.center = CGPointMake(160.0, 160.0);
    customView.backgroundColor = [UIColor redColor];
    customView.hidden = NO;
    [self.view addSubview:customView];

 

    // 画像
    UIImageView *customImage = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
    customImage.hidden = NO;
    customImage.image = [UIImage imageNamed:@"sample.png"];
    [self.view addSubview:customImage];

 

    // ラベル
    UILabel * customLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 40)];
    customLabel.font = [UIFont fontWithName:@"HiraKakuProN-W6" size:18];
    customLabel.text = @"ラベルエリア";
    customLabel.shadowColor = [UIColor grayColor];
    customLabel.shadowOffset = CGSizeMake(2, 2);
    [self.view addSubview:customLabel];

 

    // ボタン
    UIButton *customButton1 = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
    customButton1.frame = CGRectMake(40, 80, 240, 40);
    [customButton1 setTitle:@"ここを押してください" forState:UIControlStateNormal];
    [customButton1 addTarget:selfaction:@selector(action) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:customButton1];

 

    // ボタン(画像)
    UIButton *customButton2 = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
    customButton2.frame = CGRectMake(120, 160, 80, 80);
    [customButton2 setImage:[UIImageimageNamed:@"button1.png"] forState:UIControlStateNormal];
    [customButton2 setImage:[UIImageimageNamed:@"button2.png"] forState:UIControlStateHighlighted];
    [customButton2 addTarget:selfaction:@selector(action) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:customButton2];

 

    // スイッチ
    UISwitch *customSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(120, 240, 0, 0)];
    customSwitch.on = NO;
    [customSwitch addTarget:selfaction:@selector(action2:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:customSwitch];

細かいオプションの選択肢もあったけど、ひとまず動くやつをメモっておく。