CSS メモ
css いじるのに参考にさせてもらったのでメモ。webdesignrecipes.com
floatの概念は以下のサイト(特に図)が分かりやすかった。taneppa.net
【書評】リーダブルコード
リーダブルコード ―より良いコードを書くためのシンプルで実践的なテクニック (Theory in practice)
- 作者: Dustin Boswell,Trevor Foucher,須藤功平,角征典
- 出版社/メーカー: オライリージャパン
- 発売日: 2012/06/23
- メディア: 単行本(ソフトカバー)
- 購入: 68人 クリック: 1,802回
- この商品を含むブログ (129件) を見る
長らく積ん読にしてたけど、読み切った。
プログラマな方は一度は読んでおいたほうがいいとは感じました。以前、「読み物としてはおもしろい」と評価してる人がいたけど、まぁ才能ある人なら言われなくても実践してるんじゃなかろうか。
関数名などで動詞の選び方などはイングリッシュネイティブでないとちょっと難しいだろう。プログラマなら英語ぐらいできないとっていう意見はごもっともですが、レベルも人それぞれですから、プロジェクトで品質を安定させるにはある程度パターンを示したいところ。
余談だけど、javaみたく日本語で変数名等を書ける場合は、いっそ全部日本語にしてもいいのでは。DDDだとネーミングが重要視されてるわけで、英語にこだわる必要もないという話もある。
MacからNFSが不安定
先日、NFSサーバを立ててmacからマウントして利用していたが、どうにも不安定。よく固まるうえに、umount -fでもアンマウントできない。極めつけに、ファイルコピー中に突然OSXが落ちるというwww
dmesg見るとエラー出まくってるし、、、 ふーむ、さてはて。
nfs_mount_state_in_use_end: error 10025, initiating recovery for 192.168.20.1:/, 0x1 nfs recovery started for 192.168.20.1:/, 0x2 nfs_recover: 10033, need reopen for 502 0xffffff801c188340 0x0 ._test.dat nfs recovery completed for 192.168.20.1:/, 0x2 nfs_mount_state_in_use_end: error 10025, initiating recovery for 192.168.20.1:/, 0x2 nfs recovery started for 192.168.20.1:/, 0x3 nfs_recover: 10033, need reopen for 502 0xffffff801c188340 0x0 ._test.dat nfs recovery completed for 192.168.20.1:/, 0x3 nfs_mount_state_in_use_end: error 10025, initiating recovery for 192.168.20.1:/, 0x3 nfs recovery throttled for 192.168.20.1:/, 0x3 nfs recovery started for 192.168.20.1:/, 0x4 nfs_recover: 10033, need reopen for 0 0xffffff801c188340 0x0 ._test.dat nfs recovery completed for 192.168.20.1:/, 0x4 nfs_mount_state_in_use_end: error 10025, initiating recovery for 192.168.20.1:/, 0x4 nfs recovery started for 192.168.20.1:/, 0x5 nfs_recover: 10033, need reopen for 502 0xffffff801c188340 0x0 ._test.dat nfs recovery completed for 192.168.20.1:/, 0x5 nfs_mount_state_in_use_end: error 10025, initiating recovery for 192.168.20.1:/, 0x5 nfs recovery throttled for 192.168.20.1:/, 0x5 nfs recovery started for 192.168.20.1:/, 0x6 nfs_recover: 10033, need reopen for 502 0xffffff801c188340 0x0 ._test.dat nfs recovery completed for 192.168.20.1:/, 0x6 nfs_mount_state_in_use_end: error 10025, initiating recovery for 192.168.20.1:/, 0x6 nfs recovery started for 192.168.20.1:/, 0x7 nfs_recover: 10033, need reopen for 502 0xffffff801c188340 0x0 ._test.dat nfs_recover: 10033, need reopen for 502 0xffffff801c188630 0x0 test.dat nfs recovery completed for 192.168.20.1:/, 0x7 nfs server 192.168.20.1:/: resource temporarily unavailable (jukebox) nfs server 192.168.20.1:/: dead nfs4_renew_timer: error 6 nfs4_renew_timer: error 6, initiating recovery nfs delegated state claim error 6, state lost, 502 ._test.dat nfs: state lost for 0xffffff801c188340 0x2 ._test.dat fs_vnop_close: error 6, 502 ._test.dat nfs4_delegation_return, error 6 ._test.dat nfs server 192.168.20.1:/: resource temporarily unavailable (jukebox) nfs_vnop_open: error 6, 502 ._test.dat
CentOS 7 - NFS設定 & Macからマウント
以前のサーバではSambaでファイル共有していたのですが、転送速度があまり速くないし(チューニングが必要なのかも)、そもそもWindows使わないので、NFSに切り替えることにしました。
環境
今回は、CentOS7 にNFSサーバを稼働させてMacからマウントして使えるようにします。またNFSv4のみで運用します。クライアントはすべてnfsnobadyとして読み書き。
サーバ:CentOS Linux release 7.1.1503
クライアント:OSX Yosemite 10.10.3
NFSインストール
$ yum -y install nfs-utils
サーバ設定
/etc/sysconfig/nfs に以下を設定
RPCNFSDARGS="-N 2 -N 3"
/etc/exports に以下を設定
/exports/public 192.168.20.0/24(rw,sync,no_subtree_check,insecure,all_squash,anonuid=65534,anongid=65534,fsid=0)
これは、/exports/publicをネットワークアドレス192.168.20.0/24のクライアントに開放すると言う意味。
サービス起動
$ systemctl start rpcbind nfs-server $ systemctl enable rpcbind nfs-server
Haskell道 その3
リスト内包表記
リストに対してフィルタリング・変換・組み合わせの処理を行える。
奇数を得るならこんな感じ。
let odds = [x | x <- [1..100], odd x]
カンマ区切りで条件(すなわちフィルタリング)を追加できる。
let oddsNotMulti5 = [x | x <- [1..100], odd x, x `mod` 5 /= 0]
リストのリストを処理するのに内包表記を入れ子にする。
let numLists = [[1,2,3], [5,6,7], [8,9,0]] [ [x | x <- list, even x] | list <- numLists] -> [[2],[6],[8,0]]
リストを二乗する関数を作りたいなら、
let squares xs = [x * x | x <- xs] squares [1,2,3,4,5] -> [1,4,9,16,25]
2つのリストの数値を文字列として結合。
[ show x ++ show y | x <- [1..4], y <- [9,8,7,6,5] ] -> ["19","18","17","16","15","29","28","27","26","25","39","38","37","36","35","49","48","47","46","45"]
次は、3つの値がa + b = cとなる整数の組み合わせを探すとするとこう書ける。
[ (a, b, c) | c <- [1..5], a <- [1..c], b <- [1..a], a + b == c] -> [(1,1,2),(2,1,3),(2,2,4),(3,1,4),(3,2,5),(4,1,5)]
ここでaの範囲は[1..c]、bの範囲は[1..a]となっている。そう、cの値が決まればa、bの探索範囲も制限できるのである。
CentOS 7 不要サービスの停止
さてさて、サーバにCentOS 7入れたので、まずは不要なサービスを止めましょう。CentOS 7からはsystemdがデフォルトなので、CentOS 6とはいろいろ操作が異なりますね。
サービス一覧
$ systemctl list-units --type=service UNIT LOAD ACTIVE SUB DESCRIPTION auditd.service loaded active running Security Auditing Service avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack chronyd.service loaded active running NTP client/server crond.service loaded active running Command Scheduler dbus.service loaded active running D-Bus System Message Bus getty@tty1.service loaded active running Getty on tty1 irqbalance.service loaded active running irqbalance daemon iscsi-shutdown.service loaded active exited Logout off all iSCSI sessions on shutdown kdump.service loaded active exited Crash recovery kernel arming kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel lvm2-lvmetad.service loaded active running LVM2 metadata daemon lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2 network.service loaded active exited LSB: Bring up/down networking NetworkManager.service loaded active running Network Manager polkit.service loaded active running Authorization Manager postfix.service loaded active running Postfix Mail Transport Agent rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg rhel-import-state.service loaded active exited Import network configuration from initramfs rhel-readonly.service loaded active exited Configure read-only root support rsyslog.service loaded active running System Logging Service sshd.service loaded active running OpenSSH server daemon systemd-backlight@acpi_video0.service loaded active exited Load/Save Screen Backlight Brightness of acpi_video0 systemd-journald.service loaded active running Journal Service systemd-logind.service loaded active running Login Service systemd-random-seed.service loaded active exited Load/Save Random Seed systemd-readahead-collect.service loaded active exited Collect Read-Ahead Data systemd-readahead-replay.service loaded active exited Replay Read-Ahead Data systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems systemd-sysctl.service loaded active exited Apply Kernel Variables systemd-tmpfiles-setup-dev.service loaded active exited Create static device nodes in /dev systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories systemd-udev-trigger.service loaded active exited udev Coldplug all Devices systemd-udevd.service loaded active running udev Kernel Device Manager systemd-update-utmp.service loaded active exited Update UTMP about System Reboot/Shutdown systemd-user-sessions.service loaded active exited Permit User Sessions systemd-vconsole-setup.service loaded active exited Setup Virtual Console tuned.service loaded active running Dynamic System Tuning Daemon LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 38 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
サービスの内容と残すか無効化するか。
Service | Description | To be disable? |
---|---|---|
auditd | Linux Security Modulesによるシステムコール許可・不許可のログを出力させるサービス | 残しておく |
avahi-daemon | mDNS/DNS-SDによるローカルネットワーク内の名前解決サービス | MacのBonjourもあるし残す(環境によっては不要) |
chronyd | NTPによる時刻同期 | 必要 |
crond | いつものcron | 必要 |
dbus | publish/subscribe型のシステム内プロセス間メッセージ配信サービス | 必要 |
irqbalance | ハードウェア割込み処理をCPUの各コアに分散させるサービス | 2 coreなので必要 |
iscsi-shutdown | shutdown時にiscsiセッションをログオフしてくれるサービス | iscsi使わないけどoneshotなので放置 |
kdump | カーネルクラッシュ時にカーネルの状態をダンプするサービス | 使う日が来ないことを祈りつつ残す |
kmod-static-nodes | 起動時に/dev配下のデバイスファイルの設定をしている? | 必要 |
lvm2-lvmetad | LVM用(3.6. メタデータデーモン (lvmetad)) | LVMを利用しているので残す |
lvm2-monitor | LVMボリュームの監視 | 残す |
network | ネットワークインターフェース起動用 | 必要 |
NetworkManager | ネットワーク設定の自動管理 | 今回は有線しか使わないけど使い方は覚えたいので残しておく。勝手にネットワーク設定が切り替わったりするケースもあるので手動管理したい人は停止しておいたほうが無難。 |
polkit | セキュリティ・権限ポリシー管理 | 細かい権限管理は不要なので停止したいが、systemdなどとも連携してるため残す |
postfix | メールサーバ | 不要なので無効化 |
rhel-dmesg | dmesgを/var/log/dmesgに吐く | 残す |
rhel-import-state | initramfsの設定ファイルを起動時にコピーするみたいだがよくわからん | 残す |
rhel-readonly | /etc/sysconfig/readonly-rootの設定に基づいて起動時に/ をreadonlyにする | たぶん使わないけど残す |
rsyslog | ログ管理サービス | 必要 |
sshd | sshサービス | 必要 |
tuned | Linux Performance Tuning サービス(2.5. Tuned および ktune) | 残す |
あれ、停止するのpostfixぐらいかw。
あと、SELinuxも無効にしてために/etc/sysconfig/selinuxを開いて、
SELINUX=disabled
と設定しておく。
Haskell道 その2
- 作者: Miran Lipovača,田中英行,村主崇行
- 出版社/メーカー: オーム社
- 発売日: 2012/05/23
- メディア: 単行本(ソフトカバー)
- 購入: 25人 クリック: 580回
- この商品を含むブログ (68件) を見る
リスト操作
結合
[1, 2, 3] ++ [4, 5, 6] -> [1, 2, 3, 4, 5, 6]
リスト結合時は左側のリストの末端まで走査することになるため、左側に大きなリストを置かない方がいいと書いてるけど、実際は遅延評価なので気にならないっぽい。
*Main> let n = [1..99999999] ++ [1] -- 一瞬 *Main> let t = tail n -- 一瞬 *Main> length t -- 時間がかかる 99999999
先頭に要素を追加する。
let str = "ello, world" 'h':str -> "hello, world" "h":str -> error -- "h"は要素ではないため
アクセス
!! のあとに添え字を置く。
[1, 2, 3, 4, 5, 6] !! 2 -> 3
操作
head [1, 2, 3, 4, 5, 6] -> 1 tail [1, 2, 3, 4, 5, 6] -> [2, 3, 4, 5, 6] last [1, 2, 3, 4, 5, 6] -> 6 init [1, 2, 3, 4, 5, 6] -> [1, 2, 3, 4, 5]
take 3 [1, 2, 3, 4, 5, 6] -> [1, 2, 3]
drop 3 [1, 2, 3, 4, 5, 6] -> [4, 5, 6]
長さ
lenght [1, 2, 3, 4, 5, 6] -> 6
空リストチェック
null [1, 2, 3, 4, 5, 6] -> False null [] -> True
逆リスト
reverse [1, 2, 3] -> [3, 2, 1]