2015年7月19日日曜日

MacにhomebrewでAtomを入れた

ちょっと環境を作り変えることになったので、
エディタも変えてみようと思い、homebrewでAtom入れてみました。

Atomはbrew caskで入れられるようなので、
まずは検索してみる。
$ brew cask search atom
No cask found for "atom".

出てこなかったのでcaskをupgradeしてみる。
$ brew upgrade cask
Error: No such file or directory - /usr/local/Cellar/cask

どうやらcaskでは入ってないようなので、何で入っているのか調べてみる。
$ ls /usr/local/Cellar/
autoconf/           makedepend/         pkg-config/         rbenv-default-gems/ readline/           
brew-cask/          mysql/              python/             rbenv-gem-rehash/   ruby-build/         
gdbm/               openssl/            rbenv/              rbenv-gemset/       sqlite/  

brew-caskで入っているようなので、改めてupgradeしてみる。
$ brew upgrade brew-cask
==> Upgrading 1 outdated package, with result:
phinze/cask/brew-cask 0.54.1
==> Upgrading phinze/cask/brew-cask
==> Cloning https://github.com/caskroom/homebrew-cask.git
Cloning into '/Library/Caches/Homebrew/brew-cask--git'...
remote: Counting objects: 2999, done.
remote: Compressing objects: 100% (2902/2902), done.
remote: Total 2999 (delta 117), reused 834 (delta 81), pack-reused 0
Receiving objects: 100% (2999/2999), 5.74 MiB | 3.70 MiB/s, done.
Resolving deltas: 100% (117/117), done.
Checking connectivity... done.
Note: checking out '2fc9d2323950a45549e1d5c4b25481d98726b85c'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

==> Checking out tag v0.54.1
🍺  /usr/local/Cellar/brew-cask/0.54.1: 2731 files, 11M, built in 8 seconds

無事にupgradeができたので、Atomの情報が取れるかinfoで確かめてみる。
$ brew cask info atom
atom: 1.0.2
Atom
https://atom.io/
Not installed
https://github.com/phinze/homebrew-cask/blob/master/Casks/atom.rb
==> Contents
  Atom.app (app)
  Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm (binary)
  Atom.app/Contents/Resources/app/atom.sh (binary)

atomの情報が取れたので、installをしてみる。
$ brew cask install atom
==> Satisfying dependencies
complete
==> Downloading https://github.com/atom/atom/releases/download/v1.0.2/atom-mac.zip
######################################################################## 100.0%
==> Symlinking App 'Atom.app' to '/Users/xxxx/Applications/Atom.app'
==> Symlinking Binary 'apm' to '/usr/local/bin/apm'
==> Symlinking Binary 'atom.sh' to '/usr/local/bin/atom'
🍺  atom staged at '/opt/homebrew-cask/Caskroom/atom/1.0.2' (1574 files, 198M)

無事にインストールできた。
シンボリックリンクがユーザーのアプリケーションディレクトリに貼られていて、
/Applications配下には入ってないので、起動するときはLaunchpadとかから起動するのがよさそうです。


参考URL
http://qiita.com/hkusu/items/f41f5566e1040147f1fc

2015年7月13日月曜日

awsのec2インスタンス作成時にruby2.2.2をインストールするユーザーデータ

完全にメモですが、awsでec2インスタンス作るときに、
ruby2.2.2をrbenvで入れてある状態にするユーザーデータです。

#!/bin/bash
yum update -y
yum install -y git
yum install -y gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel mysql-devel
yum install -y patch
 
cd /usr/local
git clone https://github.com/sstephenson/rbenv.git
mkdir -p /usr/local/rbenv/plugins
cd /usr/local/rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git
 
cat << EOF >> /etc/profile.d/rbenv.sh
export RBENV_ROOT=/usr/local/rbenv
export PATH="\$RBENV_ROOT/bin:\$PATH"
eval "\$(rbenv init -)"
EOF
 
source /etc/profile.d/rbenv.sh
rbenv install -f 2.2.2
rbenv rehash
rbenv global 2.2.2
rbenv version
最後にrbenv versionを入れてないと、最初にログインした時のruby -vが2.2.2にならなかった

参考URL
http://hivecolor.com/id/129

2015年7月6日月曜日

AWSのS3で静的ウェブサイトホスティングするときのバケットポリシー

AWSのS3で静的ウェブサイトホスティングでjsやcssを配信したいと思い、
どこのサイトからでもアクセスされてかまわない形でアクセスを許可したときの
バケットポリシーについて調べました。
AWSのドキュメントにもあるように、以下の記述でうまくいきました。
{
 "Version": "2012-10-17",
 "Statement": [
  {
   "Sid": "PublicReadGetObject",
   "Effect": "Allow",
   "Principal": "*",
   "Action": "s3:GetObject",
   "Resource": "arn:aws:s3:::バケット名/*"
  }
 ]
}

参考URL
https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/WebsiteAccessPermissionsReqd.html