<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>iamtgc &#187; Google</title>
	<atom:link href="http://iamtgc.com/category/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamtgc.com</link>
	<description></description>
	<lastBuildDate>Thu, 01 Mar 2012 19:46:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Add Google +1 to your WordPress blog</title>
		<link>http://iamtgc.com/2011/07/13/add-google-plus-one-to-your-wordpress-blog/</link>
		<comments>http://iamtgc.com/2011/07/13/add-google-plus-one-to-your-wordpress-blog/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 13:42:16 +0000</pubDate>
		<dc:creator>tgc</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://iamtgc.com/?p=336</guid>
		<description><![CDATA[Google&#8217;s +1 buttons have been popping up left and right, and according to Google &#8230; +1’s from friends and contacts can be a useful signal to Google when determining the relevance of your page to a user’s query. This is &#8230; <a href="http://iamtgc.com/2011/07/13/add-google-plus-one-to-your-wordpress-blog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Google&#8217;s +1 buttons have been popping up left and right, and according to Google</p>
<blockquote><p>&#8230; +1’s from friends and contacts can be a useful signal to Google when determining the relevance of your page to a user’s query. This is just one of many signals Google may use to determine a page’s relevance and ranking &#8230;</p></blockquote>
<p>and if that isn&#8217;t enough, consider the <em>limited Field Trial</em> of <a href="https://plus.google.com/" title="Google+" target="_blank">Google+</a> already reaching an estimated user base between 10 and 20 million, adding a +1 button to your content becomes even more important.</p>
<p>While there are plugins that exist to add +1 buttons to your WordPress blog, I will explain how to modify your theme and add the +1 button without using plugins.<br />
<span id="more-336"></span></p>
<p><strong>Note:</strong> If you are modifying themes, you should do so using <a href="http://codex.wordpress.org/Child_Themes" title="Child Themes">child themes</a>.  Child themes help to preserve your modifications during upgrades, and make backing out your changes easier if you break something.</p>
<p>Begin by adding the script tag, just prior to your closing body tag in <strong>footer.php</strong>.</p>
<pre class="brush:html;">
&lt;script type="text/javascript" src="https://apis.google.com/js/plusone.js"&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Next, if you want to add the +1 button to your single posts, edit <strong>loop-single.php</strong>, you&#8217;ll want to decide where to place the button, in this example it will appear immediately to the right of the post title.  </p>
<pre class="brush:html;">
&lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
&lt;h1 class="entry-title"&gt;&lt;?php the_title(); ?&gt; &lt;g:plusone&gt;&lt;/g:plusone&gt;&lt;/h1&gt;

&lt;div class="entry-meta"&gt;
&lt;?php twentyten_posted_on(); ?&gt;
&lt;/div&gt;&lt;!-- .entry-meta --&gt;
</pre>
<p>Note the added plusone tag</p>
<pre class="brush:html;">
&lt;g:plusone&gt;&lt;/g:plusone&gt;
</pre>
<p>As WordPress (<a href="http://wordpress.org/news/2009/12/wordpress-2-9/" title="WordPress 2.9" target="_blank">since 2.9</a>) provides a <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=139394" title="canonical link element" target="_blank">canonical link element</a> it is not necessary to include the href attribute.  </p>
<p>However, if you want to include +1 outside of a single post/page, like in <strong>loop.php</strong>, where the canonical link is not helpful, you can use the following.</p>
<pre class="brush:html;">
&lt;?php /* How to display all other posts. */ ?&gt;

        &lt;?php else : ?&gt;
                &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
                        &lt;h2 class="entry-title"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt; &lt;g:plusone href="&lt;?php the_permalink(); ?&gt;" &gt;&lt;/g:plusone&gt;&lt;/h2&gt;

                        &lt;div class="entry-meta"&gt;
                                &lt;?php twentyten_posted_on(); ?&gt;
                        &lt;/div&gt;&lt;!-- .entry-meta --&gt;
</pre>
<p>Note the added plusone tag</p>
<pre class="brush:html;">
&lt;g:plusone href="&lt;?php the_permalink(); ?&gt;" &gt;&lt;/g:plusone&gt;
</pre>
<p>For further customization, such as button size and the exclusion of counts, please refer to the <a href="http://www.google.com/+1/button/" title="Google +1 documentation">Google +1 documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtgc.com/2011/07/13/add-google-plus-one-to-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Integrating a Google Custom Search Engine into your WordPress blog</title>
		<link>http://iamtgc.com/2011/07/10/integrating-a-google-custom-search-engine-into-your-wordpress-blog/</link>
		<comments>http://iamtgc.com/2011/07/10/integrating-a-google-custom-search-engine-into-your-wordpress-blog/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 23:54:45 +0000</pubDate>
		<dc:creator>tgc</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://iamtgc.com/?p=232</guid>
		<description><![CDATA[It has been a while since I last had a need to integrate a Google Custom Search Engine into a WordPress blog, but it seems a lot has changed. The layout options have changed, and the IFrame option I was &#8230; <a href="http://iamtgc.com/2011/07/10/integrating-a-google-custom-search-engine-into-your-wordpress-blog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It has been a while since I last had a need to integrate a Google Custom Search Engine into a WordPress blog, but it seems a lot has changed.  The <a href="http://code.google.com/intl/en/apis/customsearch/docs/ui.html#layout" title="Google Custom Search layout options" target="_blank">layout options</a> have changed, and the IFrame option I was used to using has been deprecated.</p>
<p>Fortunately, this has allowed me to discover one of the more useful options, the <em><strong>results only</strong></em> layout.  With this option and a few minor modifications, you will be able to leverage Google&#8217;s search with your existing WordPress search box.</p>
<p>So to begin, if haven&#8217;t done so already, <a href="http://google.com/cse" title="Google Custom Search Engine">create your own custom search engine</a>.  I&#8217;ll leave it to you to decide on the name, description, sites to index, etc. and focus on the settings that impact you integrating your custom search into WordPress.<br />
<span id="more-232"></span><br />
First, when you&#8217;re creating (or editing) the look and feel of your custom search, you will want to chose the <strong><em>results only</em></strong> layout.  Here you can also customize your style or chose from one on those Google provides.<br />
<a href="http://iamtgc.com/wp-content/uploads/2011/07/cse-look-and-feel.jpg" rel="colorbox" ><img src="http://iamtgc.com/wp-content/uploads/2011/07/cse-look-and-feel.jpg" alt="" title="cse-look-and-feel" width="1028" height="629" class="alignnone size-full wp-image-284" /></a></p>
<p>Next you&#8217;ll want to get the code necessary to display the search results in your blog.  While there is probably little reason to change the <strong>query parameter name</strong> from the default of <strong>q</strong>, if you do, make sure you don&#8217;t use <strong>s</strong> as it&#8217;s used for WordPress&#8217; built in search. Copy your generated code into the clipboard.<br />
<a href="http://iamtgc.com/wp-content/uploads/2011/07/cse-get-code.jpg" rel="colorbox" ><img src="http://iamtgc.com/wp-content/uploads/2011/07/cse-get-code.jpg" alt="" title="cse-get-code" width="900" height="695" class="alignnone size-full wp-image-319" /></a></p>
<p>Next, you will want to add a new page to your blog.  Here the title is less significant than the permalink, which for this example will be named <strong>google-cse</strong>.  Paste the generated code into this page, disable comments, and publish it.<br />
<a href="http://iamtgc.com/wp-content/uploads/2011/07/wordpress-cse-page.jpg" rel="colorbox" ><img src="http://iamtgc.com/wp-content/uploads/2011/07/wordpress-cse-page.jpg" alt="" title="wordpress-cse-page" width="780" height="548" class="alignnone size-full wp-image-323" /></a></p>
<p><strong>Note:</strong> You may want to <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates" title="Wordpress - Create You Own Page Template" target="_blank">create your own page template</a> for the search results page to remove the title, authorship, etc.<br />
<strong>Note 2:</strong> If you have auto-generated menus that include your pages, you will likely want to customize them to exclude your search results page.</p>
<p>Finally, you will want to edit your WordPress theme&#8217;s <strong>searchform.php</strong>.  If this does not exist, you can create it.  I removed theme specific function calls for this example, but you can adjust this as you see fit.  The most important parts are the <strong>action</strong>, which must point to the permalink of the search results page we just created, and the <strong>name</strong> and <strong>id</strong> which must match the query parameter name we previously chose, in this case Google&#8217;s default <strong>q</strong>.</p>
<pre class="brush:html;">
&lt;form method="get" id="searchform" action="/google-cse/"&gt;
&lt;label for="q" class="assistive-text"&gt;Search&lt;/label&gt;
&lt;input type="text" class="field" name="q" id="q"/&gt;
&lt;input type="submit" class="submit" id="searchsubmit"/&gt;
&lt;/form&gt;
</pre>
<p><strong>Note 3:</strong> Since we are now using the query parameter of <strong>q</strong>, if your theme decorates the search form with css (as <a href="http://theme.wordpress.com/themes/twentyeleven/" title="twentyeleven">twentyeleven</a> does) some modifications may be necessary.  CSS entries referencing #s will have to be changed to #q.  For exmaple</p>
<pre class="brush:css;">
input#s {
    background: url(images/search.png) no-repeat 5px 6px;
    -moz-border-radius: 2px;
    border-radius: 2px;
    font-size: 14px;
    height: 22px;
    line-height: 1.2em;
    padding: 4px 10px 4px 28px;
}
</pre>
<p>Will have to be modified to</p>
<pre class="brush:css;">
input#q {
    background: url(images/search.png) no-repeat 5px 6px;
    -moz-border-radius: 2px;
    border-radius: 2px;
    font-size: 14px;
    height: 22px;
    line-height: 1.2em;
    padding: 4px 10px 4px 28px;
}
</pre>
<p><strong>Note 4:</strong> If you are modifying themes, you should do so using <a href="http://codex.wordpress.org/Child_Themes" title="Child Themes">child themes</a>.  Child themes help to preserve your modifications during upgrades, and make backing out your changes easier if you break something.</p>
<p><strong>Update:</strong> as reader PamL points out, if you have only &#8220;Loading&#8221; showing in the search results, remove the blank lines in the Google CSE code for your search results page.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtgc.com/2011/07/10/integrating-a-google-custom-search-engine-into-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Geocoding with Python</title>
		<link>http://iamtgc.com/2007/07/25/geocoding-with-python/</link>
		<comments>http://iamtgc.com/2007/07/25/geocoding-with-python/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 20:57:37 +0000</pubDate>
		<dc:creator>tgc</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://iamtgc.com/2007/07/25/geocoding-with-python/</guid>
		<description><![CDATA[The following code snippet is intended to demonstrate how you can leverage Python and the Google Maps/Geocode API to query the coordinates of two zip codes and then determine the distance between them. Both functions have far reaching uses independently &#8230; <a href="http://iamtgc.com/2007/07/25/geocoding-with-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The following code snippet is intended to demonstrate how you can leverage Python and the Google Maps/Geocode API to query the coordinates of two zip codes and then determine the distance between them.  Both functions have far reaching uses independently which will be further demonstrated in future posts.</p>
<p>This example determines distance between the two points in miles, however it can be modified to return distance in kilometers by replacing 3959.0 (the average radius of the earth in miles) with 6371.0 (the radius in kilometers).</p>
<p>This code does no validation on the existence of the zip code, and will likely return valid coordinates of something (whatever Google thinks you really meant) when you pass it a non existent zip code.<br />
<span id="more-6"></span><br />
The original geocode code was found <a href="http://www.djangosnippets.org/snippets/293/">here.</a></p>
<p><b>Note:</b> You will have to provide your Google Maps API key in the key variable.</p>
<pre class="brush:py;">
import math
import urllib

def get_lat_long(location):
        key = ""
        output = "csv"
        location = urllib.quote_plus(location)
        request = "http://maps.google.com/maps/geo?q=%s&#038;output=%s&#038;key=%s" % (location, output, key)
        data = urllib.urlopen(request).read()
        dlist = data.split(',')
        if dlist[0] == '200':
                return dlist[2], dlist[3]
        else:
                return None, None

def calculate_distance(zip1, zip2):
        lat1, lon1 = get_lat_long(zip1)
        lat2, lon2 = get_lat_long(zip2)

        if (not lat1) or (not lon1) or (not lat2) or (not lon2):
                return -1

        lat1 = float(lat1) * math.pi/180
        lon1 = float(lon1) * math.pi/180
        lat2 = float(lat2) * math.pi/180
        lon2 = float(lon2) * math.pi/180

        return 3959.0 * math.acos(math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(lon2-lon1))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://iamtgc.com/2007/07/25/geocoding-with-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

