Thursday, July 16, 2015

Raphael Bousso: The Black Hole Mystery: Firewall Paradox

Raphael Bousso

Siphon: In a Vacuum

Distillation Danger

Radioactive Alcohol

Ethanol (エタノール): Alcohol

Aspirin

Chemical Garden

PHP: Snippet: 任意のURLパラメータの値を取得


// Urlのパラメータの値を見つけて取得。?page_id%3D100&param2%3D200となっている場合、$pageIDは100になる。
   if (preg_match('/page_id%3D([0-9]+)/', $line, $match))
   {
      $pageID = $match[1];
   }

PHP: Snippet: 1行内の任意の標識文字に対する値の取得

// Label: の後に書いてある文字列を取得する
if (mb_strpos($line, “Label:”) !== false)
{
   $str = mb_substr($line, mb_strpos($line, “Label:”) + strlen(“Label:“));
}

PHP: Snippet: XML Parsing Example

// XMLを取得
$myXMLData = file_get_contents($xmlURL . $xmlURLParameter);

// XMLをパース
$xml = simplexml_load_string($myXMLData) or die (“Error: Cannot create object”);

// タイトルを取得
$title = $xml->entry->title;

// 概要を取得
$summary = $xml->entry->summary;

// 概要を行で分解
$lines = explode(PHP_EOL, $summary);

Google Calendar: XML

https://www.google.com/calendar/feeds/xxxxxxxx%40gmail.com/public/basic?futureevents=true&orderby=starttime&sortorder=ascending&max-results=1&singleevents=true&hl=en

PHP: function: isToday_new

// 今日か?
function isToday_new($y, $m, $d)
{  
   if (date('Y-m-d') == date ('Y-m-d', strtotime($y . "-" . $m . "-" . $d)))
   {
      $retval = true;
   }
   
   return $retval;
}

PHP: function: monthENtoJP

// 月を英語から数値へ
function monthENtoJP($en)
{
   $monthENtoNum = array(
      "Jan" => 1 , 
      "Feb" => 2 , 
      "Mar" => 3, 
      "Apr" => 4, 
      "May" => 5, 
      "Jun" => 6, 
      "Jul" => 7, 
      "Aug" => 8, 
      "Sep" => 9, 
      "Oct"=> 10, 
      "Nov" => 11, 
      "Dec" => 12);

   return $monthENtoNum[$en];
}

PHP: function: weekdayENtoJP

// 曜日を英語から日本語へ
function weekdayENtoJP($en)
{
   $weekdayENtoJP = array(
      "Sun" => "日",
      "Mon" => "月",
      "Tue" => "火",
      "Wed" => "水",
      "Thu" => "木",
      "Fri" => "金",
      "Sat" => "土");

   return $weekdayENtoJP[$en];
}