This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
aptitude update | |
aptitude install -f php5-cgi php5-cli nginx | |
cat << 'EOF' > /etc/default/php-fastcgi | |
# | |
# Settings for php-cgi in external FASTCGI Mode | |
# | |
# Should php-fastcgi run automatically on startup? (default: no) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//For PHP 5.3.x or later | |
public function emailExtended($data, $deep = false) { | |
$pattern = '/.+@(docomo|ezweb)\.ne\.jp$/i'; | |
$check = preg_replace_callback($pattern, function($matches) { | |
$patterns = array('/\.{2,}/', '/\.@/'); | |
$replacements = array('.', '@'); | |
return preg_replace($patterns, $replacements, $matches[0]); | |
}, array_shift($data)); | |
return Validation::email($check, $deep); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php -a | |
Interactive shell | |
php > echo preg_match('/.+@(docomo.ne.jp|ezweb.ne.jp)$/i', 'example@ docomo-ne.jp'); | |
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/path/to/php | |
<?php | |
$week = array( | |
'Mon' => 0, | |
'Tue' => 0, | |
'Wed' => 0, | |
'Thu' => 0, | |
'Fri' => 0, | |
'Sat' => 0, | |
'Sun' => 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/path/to/php | |
<?php | |
$week = array( | |
'Mon' => 0, | |
'Tue' => 0, | |
'Wed' => 0, | |
'Thu' => 0, | |
'Fri' => 0, | |
'Sat' => 0, | |
'Sun' => 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$period = new DatePeriod( | |
new Datetime('2012-01-13'), | |
new DateInterval('P1M'), | |
new Datetime('2012-12-13') | |
); | |
foreach ($period as $day) { | |
echo $day->format('Y-m-d') . PHP_EOL; | |
} | |
// 2012-01-13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export LC_ALL=en | |
date "+%Y.%m.%d %a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export LC_ALL=en | |
date "+%Y.%m.%d %a" | |
date "+%H:%M:%S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
df -h | grep disk0s2 | awk '{print "SSD: " $3 " used " $4 " free"}' | |
top -l 2 | awk '/CPU usage/ && NR > 5 {print "CPU: " $3 " user " $5 " sys"}' | |
top -l 1 | awk '/PhysMem/ {print "RAM: " $10 " free " $8 " inactive " $6 " active " $2 " wired"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mongo = new Mongo('127.0.0.1:27017'); // local の場合。ポート 27017 | |
// example が存在しない場合、 CREATE DATABASE 相当の操作は自動でやってくれる | |
$db = $mongo->selectDB('example'); | |
// RDB でいうところの table | |
// test が存在しない場合(以下略) | |
$collection = $db->selectCollection('test'); |
OlderNewer