<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: head code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 23 Jul 2008 01:01:41 GMT</pubDate>
    <description>DZone Snippets: head code</description>
    <item>
      <title>Xorg.conf file for Acer C300 Notebook/Tablet (Dual head support with 1280x1024)</title>
      <link>http://snippets.dzone.com/posts/show/3245</link>
      <description>Supports 1280x1024 on a second screen as well as 1024x768 on main LCD. The following two lines are particularly important: &lt;br /&gt;       Option	  "DDC"		"0"&lt;br /&gt;       Option	  "VBERestore"  "0"&lt;br /&gt;Without them, the setup breaks unless you wait for X to start before plugging in the external monitor.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Section "Device"&lt;br /&gt;       Identifier  "Videocard0"&lt;br /&gt;       Driver      "i810"&lt;br /&gt;       VendorName  "Videocard vendor"&lt;br /&gt;       BoardName   "Intel Corporation 82852/855GM Integrated Graphics Device"&lt;br /&gt;       BusID       "PCI:0:2:0"&lt;br /&gt;       Screen      0&lt;br /&gt;      Option      "MonitorLayout" "CRT,LFP"&lt;br /&gt;       Option      "AGPMode"      "0"&lt;br /&gt;       VideoRam    32768&lt;br /&gt;       Option	  "DDC"		"0"&lt;br /&gt;       Option	  "VBERestore"  "0"&lt;br /&gt;EndSection&lt;br /&gt;Section "Device"&lt;br /&gt;       Identifier  "Videocard1"&lt;br /&gt;       Driver      "i810"&lt;br /&gt;       VendorName  "Videocard vendor"&lt;br /&gt;       BoardName   "Intel Corporation 82852/855GM Integrated Graphics Device"&lt;br /&gt;       BusID       "PCI:0:2:0"&lt;br /&gt;       Screen      1&lt;br /&gt;       Option      "MonitorLayout" "CRT,LFP"&lt;br /&gt;       Option      "AGPMode"      "0"&lt;br /&gt;       VideoRam    32768&lt;br /&gt;       Option	  "DDC"		"0"&lt;br /&gt;       Option	  "VBERestore"  "0"&lt;br /&gt;EndSection&lt;br /&gt;Section "Monitor"&lt;br /&gt;       Identifier  "Laptop LCD"&lt;br /&gt;       Option      "DPMS"&lt;br /&gt;       HorizSync   30-81	&lt;br /&gt;       VertRefresh 56-75&lt;br /&gt;EndSection&lt;br /&gt;Section "Monitor"&lt;br /&gt;       Identifier  "Desktop CRT"&lt;br /&gt;       Option      "DPMS"&lt;br /&gt;       HorizSync   30-81&lt;br /&gt;       VertRefresh 56-75&lt;br /&gt;EndSection&lt;br /&gt;Section "Screen"&lt;br /&gt;         Identifier      "Screen0"&lt;br /&gt;         Device           "Videocard0"&lt;br /&gt;         Monitor           "Laptop LCD"&lt;br /&gt;         DefaultDepth      24&lt;br /&gt;         SubSection "Display"&lt;br /&gt;               Depth           24&lt;br /&gt;               Modes           "1024x768"&lt;br /&gt;         EndSubSection&lt;br /&gt;EndSection&lt;br /&gt;Section "Screen"&lt;br /&gt;         Identifier          "Screen1"&lt;br /&gt;         Device                "Videocard1"&lt;br /&gt;         Monitor               "Desktop CRT"&lt;br /&gt;         DefaultDepth      24&lt;br /&gt;         SubSection "Display"&lt;br /&gt;               Depth           24&lt;br /&gt;               Modes           "1280x1024"&lt;br /&gt;         EndSubSection&lt;br /&gt;EndSection&lt;br /&gt;Section "ServerLayout"&lt;br /&gt;       Identifier      "DefaultLayout"&lt;br /&gt;       Screen          0 "Screen0" 0 0&lt;br /&gt;       Screen          1 "Screen1" LeftOf "Screen0"&lt;br /&gt;       InputDevice	"Generic Keyboard"&lt;br /&gt;       InputDevice	"Configured Mouse"&lt;br /&gt;       InputDevice	"Synaptics Touchpad"	&lt;br /&gt;       Option          "Xinerama"&lt;br /&gt;       Option          "Clone"    "Off"&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section "DRI"&lt;br /&gt;	Mode 0666&lt;br /&gt;EndSection&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 05 Jan 2007 11:37:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3245</guid>
      <author>eddiewould (Eddie)</author>
    </item>
    <item>
      <title>Get remote filesize (HTTP HEAD)</title>
      <link>http://snippets.dzone.com/posts/show/1207</link>
      <description>// because HTTP HEAD does not work properly in a lot of PHP versions&lt;br /&gt;// can be used to get remote size of a URL (MP3 file, movie, ...)&lt;br /&gt;// without actually downloading the whole thing (e.g. when it's more than 1MB)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function remote_file_size ($url){ &lt;br /&gt;	$head = ""; &lt;br /&gt;	$url_p = parse_url($url); &lt;br /&gt;	$host = $url_p["host"]; &lt;br /&gt;	if(!preg_match("/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/",$host)){&lt;br /&gt;		// a domain name was given, not an IP&lt;br /&gt;		$ip=gethostbyname($host);&lt;br /&gt;		if(!preg_match("/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/",$ip)){&lt;br /&gt;			//domain could not be resolved&lt;br /&gt;			return -1;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	$port = intval($url_p["port"]); &lt;br /&gt;	if(!$port) $port=80;&lt;br /&gt;	$path = $url_p["path"]; &lt;br /&gt;	//echo "Getting " . $host . ":" . $port . $path . " ...";&lt;br /&gt;&lt;br /&gt;	$fp = fsockopen($host, $port, $errno, $errstr, 20); &lt;br /&gt;	if(!$fp) { &lt;br /&gt;		return false; &lt;br /&gt;		} else { &lt;br /&gt;		fputs($fp, "HEAD "  . $url  . " HTTP/1.1\r\n"); &lt;br /&gt;		fputs($fp, "HOST: " . $host . "\r\n"); &lt;br /&gt;		fputs($fp, "User-Agent: http://www.example.com/my_application\r\n");&lt;br /&gt;		fputs($fp, "Connection: close\r\n\r\n"); &lt;br /&gt;		$headers = ""; &lt;br /&gt;		while (!feof($fp)) { &lt;br /&gt;			$headers .= fgets ($fp, 128); &lt;br /&gt;			} &lt;br /&gt;		} &lt;br /&gt;	fclose ($fp); &lt;br /&gt;	//echo $errno .": " . $errstr . "&lt;br /&gt;";&lt;br /&gt;	$return = -2; &lt;br /&gt;	$arr_headers = explode("\n", $headers); &lt;br /&gt;	// echo "HTTP headers for &lt;a href='" . $url . "'&gt;..." . substr($url,strlen($url)-20). "&lt;/a&gt;:";&lt;br /&gt;	// echo "&lt;div class='http_headers'&gt;";&lt;br /&gt;	foreach($arr_headers as $header) { &lt;br /&gt;		// if (trim($header)) echo trim($header) . "&lt;br /&gt;";&lt;br /&gt;		$s1 = "HTTP/1.1"; &lt;br /&gt;		$s2 = "Content-Length: "; &lt;br /&gt;		$s3 = "Location: "; &lt;br /&gt;		if(substr(strtolower ($header), 0, strlen($s1)) == strtolower($s1)) $status = substr($header, strlen($s1)); &lt;br /&gt;		if(substr(strtolower ($header), 0, strlen($s2)) == strtolower($s2)) $size   = substr($header, strlen($s2));  &lt;br /&gt;		if(substr(strtolower ($header), 0, strlen($s3)) == strtolower($s3)) $newurl = substr($header, strlen($s3));  &lt;br /&gt;		} &lt;br /&gt;	// echo "&lt;/div&gt;";&lt;br /&gt;	if(intval($size) &gt; 0) {&lt;br /&gt;		$return=intval($size);&lt;br /&gt;	} else {&lt;br /&gt;		$return=$status;&lt;br /&gt;	}&lt;br /&gt;	// echo intval($status) .": [" . $newurl . "]&lt;br /&gt;";&lt;br /&gt;	if (intval($status)==302 &amp;&amp; strlen($newurl) &gt; 0) {&lt;br /&gt;		// 302 redirect: get HTTP HEAD of new URL&lt;br /&gt;		$return=remote_file_size($newurl);&lt;br /&gt;	}&lt;br /&gt;	return $return; &lt;br /&gt;} &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 20 Jan 2006 02:48:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1207</guid>
      <author>pforret (Peter Forret)</author>
    </item>
  </channel>
</rss>
