狂ったお茶会のlog

後で起きる自分のためのメモ

cdコマンドとか

どうしても忘れるので未来の俺のために書いておく

  • ./ 今いるディレクトリ
  • ../ 一個上のディレクトリ
  • ~/ ホーム
  • ディレクトリを指定せず cd するとホームに行く
  • cd - すると移動前のディレクトリに戻る
  • pwd 今いる場所を表示する

随時追記

参考?

Linuxコマンド集 - 【 cd 】 ディレクトリを移動する:ITpro

PostgreSQLのソースをサーバにインストールする

インストールする

初っ端から蛇足だが、どっからDLしていいかしばらくわからなかったので書いておくと
http://www.postgresql.org/ のDLページ、左端のメニューのSourceを押すと出て来る
f:id:dormouse666:20151014015756p:plain

今回は9.4.4を入れます

※root状態でやる

cd /usr/local/src    //場所移動
curl -O https://ftp.postgresql.org/pub/source/v9.4.4/postgresql-9.4.4.tar.gz   //ソースを取得
tar xvzf postgresql-9.4.4.tar.gz   //展開
cd postgresql-9.4.4    //できたフォルダに移動

この後./configureをしたが以下のエラー出た

configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... no
configure: WARNING:
*** Without Perl you will not be able to build PostgreSQL from Git.
*** You can obtain Perl from any CPAN mirror site.
*** (If you are using the official distribution of PostgreSQL then you do not
*** need to worry about this, because the Perl output is pre-generated.)
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing shm_open... -lrt
checking for library containing shm_unlink... none required
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

bisonとflexperlreadlineがない?
WARNINGは放置してとりあえずreadlineを入れろとの天のお告げがあったので以下インストール

yum install readline readline-devel

上記した後、以下

./configure
make
make install

ビャーッと色々出た最後にPostgreSQL installation complete.となって、インストール完了

ここからインストール後

mkdir /usr/local/pgsql/data   //格納先?を作る
chown postgres:postgres /usr/local/pgsql/data   //格納先の権限移譲

postgresユーザ作成
※セキュリティ上、rootだとpostgresqlは起動できない

useradd postgres   //ユーザ作成
passwd postgres   //パスワード設定
su - postgres   //ユーザ切り替え

posgresユーザで以下をする

cd /usr/local/pgsql/bin   //場所移動
./initdb --encoding=UTF8 --no-locale -D /usr/local/pgsql/data   //initdbする。-Dでディレクトリ指定しないとエラーだった

ビャーッと出た後に

Success. You can now start the database server using:

    ./postgres -D /usr/local/pgsql/data
or
    ./pg_ctl -D /usr/local/pgsql/data -l logfile start

と出て完了

起動したい

上記のコマンドで起動できるようだが

./pg_ctl -D /usr/local/pgsql/data -l logfile start

↑をやってみたけど

$ sh: logfile: Permission denied

とか出てしまった、権限がない?

絶対パスを指定してみる
※以下を拝見した
MacPorts で PostgreSQL をインストールする - make world

./pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile start
$ ./pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile start
server starting

動いたっぽい?

確認(1)

$ ps awx | grep postgres
11502 pts/0    S      0:00 su - postgres
11558 pts/1    S      0:00 su - postgres
11620 pts/0    S      0:00 /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
11622 ?        Ss     0:00 postgres: checkpointer process                        
11623 ?        Ss     0:00 postgres: writer process                              
11624 ?        Ss     0:00 postgres: wal writer process                          
11625 ?        Ss     0:00 postgres: autovacuum launcher process                 
11626 ?        Ss     0:00 postgres: stats collector process                     
11628 pts/1    S+     0:00 grep postgres

確認(2)

$ ./psql -l
                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | UTF8     | C       | C     | 
 template0 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
(3 rows)

確認方法がこれで合ってるのかよくわかってないが

もう1つのコマンドの↓もやってみた

./postgres -D /usr/local/pgsql/data

以下になって止まる、上記と同じくpsした感じ動いてるっぽい気配

$ ./postgres -D /usr/local/pgsql/data
LOG:  database system was shut down at 2015-10-04 15:53:16 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

スキーマつくる

testというスキーマ作成してみた

$ ./createdb test
$ ./psql test
psql (9.4.4)
Type "help" for help.

test=# \l
                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | UTF8     | C       | C     | 
 template0 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 test      | postgres | UTF8     | C       | C     | 
(4 rows)

ここまで、何もPATHを通してないので後で通す
一旦以上

追記

PATH通した
PATHを通す - 狂ったお茶会のlog

参考

ここらへんを見ました

http://www.postgresql.jp/document/9.4/html/installation.html

CentOS6.x - postgresインストール(ソースから) - Qiita

PostGISを使ってみる - shohu33's diary

desknet's NEO (Linux+PostgreSQL 9.2) インストールガイド|desknet's NEO

使えば分かるPostgreSQL運用&チューニング(1):PostgreSQL導入から接続まで (1/3) - @IT

nginxのソースをサーバにインストールする

nginxをソースコードからのビルドしたので雑なメモ

CentOS

サーバに入ったらrootになる

sudo su -

移動

cd /usr/local/src

http://nginx.org/en/download.html
の、Stable versionをDL
今回は1.8.0

curl -O http://nginx.org/download/nginx-1.8.0.tar.gz

以下でもできるようだがwgetが入ってなかったぽいのでcurlでやった、一応メモ

wget http://nginx.org/download/nginx-1.8.0.tar.gz

DLしたのを展開

tar xvzf nginx-1.8.0.tar.gz

展開するとディレクトリができるので移動

cd nginx-1.8.0/

そしてconfigureしたい

./configure

けどエラー

checking for OS
 + Linux 2.6.32-431.29.2.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

コンパイラが無いらしいのでinstall

yum install gcc

installしたので再度configure

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

また何か無い
以下install

yum -y install pcre-devel

※メモ:オプション -y は 問い合わせにすべて「y」と返答するオプション

再度configure

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

まだ何か無い のでinstall

yum -y install zlib-devel

で今度こそconfigure
ビャーっと出力されて最後こう出た
makefile出来たっぽい

creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

ここのパスを覚えとくといいのかな

そいでmakeしてmake installする

make
make install

ビャーッとコンパイル&インストールされる

起動ファイルとか作ると便利っぽいけど、一旦とりあえず起動

 /usr/local/nginx/sbin/nginx

特になんか表示してくれたりはしないので以下で確認してみる

ps aux | grep nginx

そうすると以下みたいにプロセスが表示されてれば動いてるっぽい

root     27808  0.0  0.0  20328   624 ?        Ss   10:31   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody   27809  0.0  0.1  20756  1216 ?        S    10:31   0:00 nginx: worker process      
root     27816  0.0  0.0 103248   872 pts/0    S+   10:31   0:00 grep nginx

停止してみる

/usr/local/nginx/sbin/nginx -s quit

ps aux | grep nginxで確認すると以下みたいにnginxのプロセスは消えてるので停止してるっぽい

root     27831  0.0  0.0 103248   876 pts/0    S+   10:31   0:00 grep nginx

nginx動いてる状態でブラウザでIPにアクセスするとこういうのが出る f:id:dormouse666:20150923232108p:plain

/usr/local/nginx/logs/access.logを見るとアクセスが来てるのがわかる

参考

ここらへんを見ました

Linux入門 - nginxの設定と使い方 - Webkaru

Nginxインストールメモ - Qiita

これから始める人のためのNginx(2):Nginxのインストールと基本設定 (1/4) - @IT

linux/nginx - おどうぐ箱

簡単!5分でnginx1.05をCentOS5.6にインストールする方法(ソースコードをコンパイル) · DQNEO起業日記

Curlコマンドの使い方例。curlコマンドの情報は意外と少ない・・・ - それマグで!

PC買った時に最初にやることまとめ

いい加減、おうち用にMacBook ProYosemite)を買ったので、
最初に入れるものとか、俺はこれが好きとかそういう話。技術的な話ではない。

chrome

ブクマを共有で使えるので今の所必須。
関連してグーグルカレンダーも良く使う。

dropbox

面倒臭がりなのであまり多くのオンラインストレージ使いこなせない。
だいたいここに突っ込む。
数日前にカッとなって有料版にした。

slack、Skype

ここらへんのチャットツールはとりあえず入れる。
Skype使いづらいんだけど会社で使ってるので。
LINEは乗っ取り云々がよろしくないっぽいので入れないでおいてる。

mailの設定

apple×3、Gmail、会社のアドレスそれぞれ。

iTunesの設定

プライベート用のPCならする。

顔文字辞書

これが今回難関だった。yosemiteなんだが、txtファイルが入らなかった。
通常、
システム環境設定->キーボード->入力ソース->追加辞書
にドラッグ&ドロップでいけるらしいのだが、

f:id:dormouse666:20150215170142p:plain

と言われる。

なんかyosemiteから品詞の扱いが変わったとかいう話もあったので、品詞変えてみたりもしたがダメだった。

しょうがないので会社のMacBook(mavericks)から元ファイル引っこ抜いてきて、入力ソース->追加辞書に突っ込んだらいけた。
※元ファイル場所: ライブラリ/Dictionaries

ただこれPC買い替えとかしてたら詰んでたんじゃないかと思う。

トラックパッドの設定

初期設定のナチュラル(スワイプした方に画面が動く)だと個人的に違和感あるので逆にする。
システム環境設定->トラックパッド

キーボード設定

fnキーの設定とか変える。f8押したら半角カナ変換してほしいので。
システム環境設定->キーボード->キーボードタブ

ディスプレイの明るさ設定

ちょっと暗めが好き。
あと、明るさ自動設定はだいたい切る。
システム環境設定->ディスプレイ

拡張子表示

Finder->環境設定->詳細->すべてのファイル名拡張子を表示
で設定したけど合ってるのかなこれ。

隠しフォルダ表示

winだと環境設定的なとこから出来たけど、Macだとターミナルから行う。

ここ見た。

以上。

インタフェースデザインの心理学読んだ

インタフェースデザインの心理学 ―ウェブやアプリに新たな視点をもたらす100の指針

インタフェースデザインの心理学 ―ウェブやアプリに新たな視点をもたらす100の指針

読んだ、というよりはパラパラ眺めた。

何でかと言うと割と知ってる話が多かったからだ。
インターフェースというよりは心理学寄りだったので。
(心理学は大学とかで結構やってた。人文学部だったし)

はじめに書いてあったけど、UIに役立つ心理学ネタをたくさん集めました、という体の本。

ただまあ、知ってることを如何にUIに活かしていくか?ということなんだとは思う。
たまに思い出すために眺めると良さそう。

リーダブルコード読んだ

リーダブルコード ―より良いコードを書くためのシンプルで実践的なテクニック (Theory in practice)

リーダブルコード ―より良いコードを書くためのシンプルで実践的なテクニック (Theory in practice)

先日、会社の後輩(プログラマ歴で言うと大層先輩)が「ドーマウスさんもそろそろこの域には達して欲しいんですよ」とか言いながら投げてきたので読んだ。

実際のコード部分は見てもわからないところもあり、ざっくり流して読んだので、たぶんまだ理解できてないと思うけど、本なんてそんなものなので、思い出した時にまた読む。

「機能は関数作って外に出せ」とか
「コメント書いてから処理書くとやりやすいですよ」とか
三項演算子はわかりづらいからあんまり使わない方がいいよね」とか
「関数名わかりやすく」とかとか、
今まで言われてきたことが結構書いてあって、あ、なるほどという感。

ちゃんと意識的に実践していきたい。まだ関数名とかたぶん変なの付けてる。

あとテストコード周りがまるっとわかってないことがわかった。
テストコード…?知らない子ですね…?レベル。がんばる。

はじめに

なぜはじめたか

  • やったことや考えたことのログを、いつでも見れる場所に置いておけると楽そう
  • 昔より忘れっぽくなったし、検索してすぐ出てくると便利かも
  • 未来の自分のための備忘録(どうせ同じこと忘れる)

なにを書くか

  • プログラムのこと
  • 仕事(ソーシャルゲーム制作)のこと
  • ただの日記
  • めんどくさい感じになってきたら分ける

履歴

  • 2010/4、社会人になる。ソシャゲの運用をやる。
  • 2012/11~2013/11までの約1年間、1~2週間に1回6時間くらいのペースで、知人にPHPを教えてもらう。
  • 2013/11くらいから、社内転職をしてエンジニアになる(PHP, MySQL)。
  • 2014/4、仕事でC++(というかcocos2d-x)をやりはじめた。
  • 2015/8、なんかjavaとかも少しやりはじめた。
  • 2017/8、まだcocos2d-xやってる。