マックでスクリーンショットの保存先を変更する方法
macでスクリーンショットを取ると、どんどんデスクトップに溜まってしまう。
Desktopではなく、デスクトップにある screenshots フォルダに入れるように変更。
保存先を変更する方法:
- Terminalを起動
- 以下のコマンドを入力
- defaults write com.apple.screencapture location ~/Desktop/screenshots
- killall SystemUIServer
参照:
http://osxdaily.com/2011/01/26/change-the-screenshot-save-file-location-in-mac-os-x/
Googleカレンダー用のイベントを作る
ホームページで紹介しているイベントから、google calendarにイベントとして登録できる仕掛けを作りたいので調べて見た。
参考にしたのはこちら:
http://www.google.com/googlecalendar/event_publisher_guide.html
生成されたコードを解読してみると、
<?php date_default_timezone_set('Asia/Tokyo'); $start = '2011-12-21 00:15'; $mktime = strtotime($start) - date('Z'); $start_time = date('Ymd\THi00\Z', $mktime); $end = '2011-12-21 01:15'; $mktime = strtotime($end) - date('Z'); $end_time = date('Ymd\THi00\Z', $mktime); ?> <a href="http://www.google.com/calendar/event?action=TEMPLATE&text=<?=urlencode(名前)?>&dates=<?=$start_time?>/<?=$end_time?>&details=<?=urlencode(description部)?>&location=<?=urlencode(tvstation部)?>&trp=false&sprop=<?=urlencode(Website address部)?>&sprop=name:<?=urlencode(Website name部)?>" target="_blank"><img src="//www.google.com/calendar/images/ext/gc_button1.gif" alt="0" border="0"></a>
住所から簡単にジオコードを調べる方法
こんな方法もあるが、処理上でジオコードを取得したいときは
$address = '東京都目黒区中目黒2-10-15'; $geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false'); $output= json_decode($geocode); $lat = $output->results[0]->geometry->location->lat; $long = $output->results[0]->geometry->location->lng; echo $lat.','.$long;
出力:
35.6406465,139.7027264
phpでarrayをobjectにする方法
$person = array ( 'firstname' => 'Namae', 'lastname' => 'Myouji' ); $p = (object) $person; echo $p->firstname;
print_r()してみると、arrayから stdClass Object に変わっているのがわかる。
header()でリダイレクトができないとき
header('Location:http://hogehoge.com'); exit;
としてもリダイレクトされないときは、すでに何かしらheaderが飛んでいる可能性がある。そんなときは
if (headers_sent()) { print_r(headers_list()); die('cannot send location header (anymore)'); }
を怪しいところに入れて見る。