<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: header code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 12 Oct 2008 14:46:04 GMT</pubDate>
    <description>DZone Snippets: header code</description>
    <item>
      <title>PHP headers to serve JSON</title>
      <link>http://snippets.dzone.com/posts/show/5882</link>
      <description>The first two headers prevent the browser from caching the response (a problem with IE and GET requests) and the third sets the correct MIME type for JSON.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;header('Cache-Control: no-cache, must-revalidate');&lt;br /&gt;header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');&lt;br /&gt;header('Content-type: application/json');&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 06 Aug 2008 21:22:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5882</guid>
      <author>jeffreybarke (Jeffrey Barke)</author>
    </item>
    <item>
      <title>301 redirect with PHP</title>
      <link>http://snippets.dzone.com/posts/show/5731</link>
      <description>For redirects on servers that have .htaccess locked down:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;header('HTTP/1.0 301 Moved Permanently');&lt;br /&gt;header('Location: http://new-page.com/');&lt;br /&gt;header('Connection: close');&lt;br /&gt;exit();&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 07 Jul 2008 21:07:31 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5731</guid>
      <author>jeffreybarke (Jeffrey Barke)</author>
    </item>
    <item>
      <title>PHP redirect code (with correct header)</title>
      <link>http://snippets.dzone.com/posts/show/5556</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;header ('HTTP/1.1 301 Moved Permanently');&lt;br /&gt;header('Location: http://domain.com/');&lt;br /&gt;exit;&lt;br /&gt;?&gt; &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 28 May 2008 21:35:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5556</guid>
      <author>yentsun (Max korinets)</author>
    </item>
    <item>
      <title>dynamic rails img headers</title>
      <link>http://snippets.dzone.com/posts/show/4737</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;find views -name [a-z]\*rhtml | xargs -n1 grep -H "@page_title" | grep -v "&lt;%" | sed "s/\@page_title = //" | sed "s/rhtml/png/" | sed "s:views/::" | sed "s:/:_:g" | sed "s:^:public/images/beta/headers/hdr_:" | sed "s/  //g"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 06 Nov 2007 00:52:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4737</guid>
      <author>jm3 (john manoogian III)</author>
    </item>
    <item>
      <title>Resolving a tinyURL to destination URL</title>
      <link>http://snippets.dzone.com/posts/show/4591</link>
      <description>Resolving a tinyURL to its original destination URL in a fastest way.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    &lt; ?php&lt;br /&gt;&lt;br /&gt;    // request like this http://&lt;domain&gt;/tinyurl.php?c=&lt;tinyurl&gt;&lt;br /&gt;&lt;br /&gt;    $num = $_GET['c'];&lt;br /&gt;&lt;br /&gt;    if($fp = fsockopen ("tinyurl.com", 80, $errno, $errstr, 30))&lt;br /&gt;    {&lt;br /&gt;    if ($fp) {&lt;br /&gt;    fputs ($fp, "HEAD /$num HTTP/1.0\r\nHost: tinyurl.com\r\n\r\n");&lt;br /&gt;    while (!feof($fp)) {$headers .= fgets ($fp,128);}&lt;br /&gt;    fclose ($fp);&lt;br /&gt;    }&lt;br /&gt;    $arr1=explode("Location:",$headers);&lt;br /&gt;    $arr=explode("\n",trim($arr1[1]));&lt;br /&gt;    echo trim($arr[0]);&lt;br /&gt;    }&lt;br /&gt;    ?&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;http://www.webforth.com/2007/07/resolving-tinyurls-to-the-desination-url</description>
      <pubDate>Sun, 30 Sep 2007 08:05:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4591</guid>
      <author>mixdev (Arun Vijayan)</author>
    </item>
    <item>
      <title>How to draw your own table header... (with borders)</title>
      <link>http://snippets.dzone.com/posts/show/3931</link>
      <description>// It's a bit  hacky at the beginning, but nstableheadercell wasn't exactly making things easy for me&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;- (void)_drawThemeContents:(NSRect)cellFrame highlighted:(BOOL)highlighted inView:(NSTableHeaderView *)view;&lt;br /&gt;{&lt;br /&gt;	int index = [view columnAtPoint:NSMakePoint(cellFrame.origin.x + 1,cellFrame.origin.y + 1)];&lt;br /&gt;	NSRect headerRect;&lt;br /&gt;	if(index != -1)&lt;br /&gt;		headerRect = [view headerRectOfColumn:index];&lt;br /&gt;	else&lt;br /&gt;		headerRect = NSZeroRect;&lt;br /&gt;	&lt;br /&gt;	[headerImage drawInRect:cellFrame&lt;br /&gt;				   fromRect:NSZeroRect&lt;br /&gt;				  operation:NSCompositeSourceOver&lt;br /&gt;				   fraction:1.0];&lt;br /&gt;	&lt;br /&gt;	[[NSColor colorWithCalibratedRed:207.0/255.0&lt;br /&gt;							   green:207.0/255.0&lt;br /&gt;								blue:207.0/255.0&lt;br /&gt;							   alpha:1.0] set];&lt;br /&gt;	NSRectFill(NSMakeRect(headerRect.origin.x, headerRect.origin.y + 1, headerRect.size.width, headerRect.size.height - 2));&lt;br /&gt;	[headerImage drawInRect:NSMakeRect(headerRect.origin.x, headerRect.origin.y, headerRect.size.width - 1, headerRect.size.height)&lt;br /&gt;				   fromRect:NSZeroRect&lt;br /&gt;				  operation:NSCompositeSourceOver&lt;br /&gt;				   fraction:1.0];&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 28 Apr 2007 19:48:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3931</guid>
      <author>aptiva (Fj&#195;&#182;lnir &#195;?sgeirsson)</author>
    </item>
    <item>
      <title>Turn CSV with headers into Array of Hashes (in 5 lines or less)</title>
      <link>http://snippets.dzone.com/posts/show/3899</link>
      <description>This assumes you have a CSV file whose first line are headings/labels for the individual columns.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'csv'&lt;br /&gt;&lt;br /&gt;csv_data = CSV.read 'data.csv'&lt;br /&gt;headers = csv_data.shift.map {|i| i.to_s }&lt;br /&gt;string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }&lt;br /&gt;array_of_hashes = string_data.map {|row| Hash[*headers.zip(row).flatten] }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 25 Apr 2007 15:10:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3899</guid>
      <author>seancribbs (Sean Cribbs)</author>
    </item>
    <item>
      <title>Cannot modify header information - headers already sent by FIX</title>
      <link>http://snippets.dzone.com/posts/show/2575</link>
      <description>Buffers output and eliminates problem with spaces/line breaks at the beginning/end of files. Make sure to place ob_start(); before header(); is called.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;ob_start();&lt;br /&gt;&lt;br /&gt;header("Location: somepage.php"); //Redirect&lt;br /&gt;&lt;br /&gt;ob_end_flush();&lt;br /&gt;exit;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 10 Sep 2006 03:54:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2575</guid>
      <author>dezmarie (Desirae Beberniss)</author>
    </item>
  </channel>
</rss>
