synblog

the round pegs in the square holes

Mac OS X Mountain Lion で apache を動かす手順

apache の設定手順

$ sudo vim /etc/apache2/users/USERNAME.conf

USERNAME.conf
--------------
<Directory "/Users/USERNAME/Sites">
Options Indexes Multiviews
AllowOverride AuthConfig Limit
Order allow,deny
Allow from all
</Directory>

$ sudo apachectl restart

以上で apache の設定終わり。 http://localhost/~USERNAME/ で ~/Sites 以下に置いたファイルがブラウザから見れる

php を有効にする

上の apache の設定だけだと php が動かないので php を有効にする

# apache の設定ファイル諸々は以下にある
/etc/apache2

# php を有効にする
$ sudo vim /etc/apache2/httpd.conf

httpd.conf
---------
# 以下のコメントアウトを解除
LoadModule php5_module libexec/apache2/libphp5.so

$ sudo apachectl restart

以上で php もブラウザから見れるようになる

続き

~/Sites が嫌なのでこれをシンボリックリンクにして Dropbox 内に向けたかったのだけど、Forbidden て怒られる

 [error] [client 127.0.0.1] Symbolic link not allowed or link target not accessible: /Users/mee/Sites

し、Options FollowSymLinks 追加したりディレクトリの権限かえても駄目だった。apache エラーログとかこの conf の設定の仕方がいつも分かりづらくて直感的でないので嫌い。apache+php は出来る限りさわりたくない

参考

Redis tutorial memo

Redis tutorial

I did following redis tutorial (TRY REDIS) and noted it this blog as memo.

http://try.redis.io/

SET, GET, DEL

SET server:name "fido"
GET server:name => "fido"
DEL server:name

INCR

SET connections 10
INCR connections => 11
DEL connections
INCR connections => 1

EXPIRE, TTL

SET resource:lock "Redis Demo"
# The key resource:lock to be deleted in 120 seconds.
EXPIRE resource:lock 120
TTL resource:lock => 113

list, RPUSH, LPUSH, LLEN, LRANGE, LPOP, RPOP

RPUSH friends "Tom"
RPUSH friends "Bob"
LPUSH friends "Sam"
LLEN friends => 3
# A value of -1 for the second parameter means to retrieve all elements in the list.
LRANGE friends 0 -1 => ["Sam", "Tom", "Bob"]
LRANGE friends 0 1 => ["Sam", "Tom"]
LPOP friends => "Sam"
RPOP friends => "Bob"
LRANGE friends 0 -1 => ["Tom"]

set, SADD, SREM, SISMEMBER, SMEMBERS, SUNION

# SADD: set add
SADD superpowers "flight"
SADD superpowers "x-ray vision"
SADD superpowers "reflexes"
# SREM: set remove
SREM superpowers "reflexes"
# SISMEMBER: set is member
SISMEMBER superpowers "flight" => true
SISMEMBER superpowers "reflexes" => false
# SMEMBERS: set members
SMEMBERS superpowers superpowers => ["flight", "x-ray vision"]
# SUNION: set union
SADD birdpowers "pecking"
SADD birdpowers "flight"
SUNION superpowers birdpowers => ["flight", "x-ray vision", "pecking"]

sorted set, ZADD, ZRANGE

ZADD hackers 1940 "Alan Kay"
ZADD hackers 1953 "Richard Stallman"
ZADD hackers 1965 "Yukihiro Matsumoto"
ZADD hackers 1916 "Claude Shannon"
ZADD hackers 1969 "Linus Torvalds"
ZADD hackers 1912 "Alan Turing"
ZRANGE hackers 0 -1 => ["Alan Turing", "Claude Shannon", "Alan Kay", "Richard Stallman", "Yukihiro Matsumoto", "Linus Torvalds"]

further documentation

MBP や MBA を外部モニタにつなげて使用している人に Forget-Me-Not というアプリが便利すぎる件

というよくある釣りタイトルを書いてみましたが、Forget-Me-Not というアプリ便利です。普段は、MacBook ProMacBook Air を外部モニタにつなげて使用していて、たまにモニタから外してラップトップを持ち運ぶという人にうってつけです。モニタをつけたり外したりする際に、毎回立ち上げているアプリのウィンドウのサイズや位置がかわってしまって、つなげなおす度にサイズを直して、、なんていうことをしていませんか。このアプリをいれておくとこのサイズと位置を覚えてくれていて、モニタを外してまた繋げ直した際にサイズと位置を復元してくれます。これでもう毎回サイズを直す必要はありませんね。これは便利。ぜひいれてみてください。

アプリの URL