マックでスクリーンショットの保存先を変更する方法

macスクリーンショットを取ると、どんどんデスクトップに溜まってしまう。
Desktopではなく、デスクトップにある screenshots フォルダに入れるように変更。

保存先を変更する方法:

  1. Terminalを起動
  2. 以下のコマンドを入力
  3. defaults write com.apple.screencapture location ~/Desktop/screenshots
  4. 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

確認して見ると、
http://maps.google.com/maps?q=35.6406465,139.7027264&hl=en&ll=35.640662,139.702706&spn=0.027413,0.042272&sll=37.0625,-95.677068&sspn=54.093296,86.572266&vpsrc=6&t=m&z=15

header()でリダイレクトができないとき

header('Location:http://hogehoge.com');
exit;

としてもリダイレクトされないときは、すでに何かしらheaderが飛んでいる可能性がある。そんなときは

if (headers_sent()) {
    print_r(headers_list());
    die('cannot send location header (anymore)');
}

を怪しいところに入れて見る。

Facebookのiframeアプリ/タブでスクロールバーを無くす方法

タグの直前に

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'YOUR-APP-ID-HERE',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>

と記述し、ちゃんとjavascriptがloadされていることを確認する。

されていれば、次にタグの直前に

<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Canvas.setAutoGrow();
}
// Do things that will sometimes call sizeChangeCallback()
function sizeChangeCallback() {
FB.Canvas.setSize({ width: 520, height: 1400 });
}
</script>

を記述する。

それでもFirefoxでスクロールバーが表示される場合は、bodyのスタイルを

body { overflow:hidden; }

と定義する。

facebook apiを使って友達一覧を取得する

その1

    $friends_info = $facebook->api('/me/friends');
    print_r($friends_info);

こっちが推奨。どういう結果が帰ってくるかは
https://developers.facebook.com/tools/explorer
から試せる。さらに、取得したいfieldも指定できる:

    $friends_info = $facebook->api('/me/friends&fields=id,name');
    print_r($friends_info);

とすれば、idとnameのみ取得。


その2 こちらはobsoleteなのでいつサポートされなくなるかわからない。

    $temp = $facebook->api(array('method' => 'friends.get'));    
    foreach($temp as $friend_id)
    {
        echo 'https://graph.facebook.com/'.$friend_id;
        echo '    <img src="https://graph.facebook.com/'.$friend_id.'/picture"  />';
    }