<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>PMG</title>
	
	<link>http://pmg.co</link>
	<description>Peformance Media Group</description>
	<lastBuildDate>Fri, 25 May 2012 19:14:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/performancemediagroup" /><feedburner:info uri="performancemediagroup" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>The Most Interesting File in WordPress</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/fpeJ85Ta-hk/interesting-file-wordpress</link>
		<comments>http://pmg.co/interesting-file-wordpress#comments</comments>
		<pubDate>Fri, 25 May 2012 19:14:13 +0000</pubDate>
		<dc:creator>Christopher Davis</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2174</guid>
		<description><![CDATA[The thing that makes WordPress an amazing flexible CMS (and, increasingly, a basic application framework) is its system of hooks. Hooks are places where a developer can fire a function that either performs specific actions or filters/changes the output that gets sent to the user. The WordPress core effectively eats it&#8217;s own dog food. Rather [...]]]></description>
			<content:encoded><![CDATA[<p>The thing that makes WordPress an amazing flexible CMS (and, increasingly, a basic application framework) is its system of <a href="http://codex.wordpress.org/Plugin_API" target="_blank">hooks</a>.</p>
<p>Hooks are places where a developer can fire a function that either performs specific <a href="http://codex.wordpress.org/Function_Reference/add_action" target="_blank">actions</a> or <a href="http://codex.wordpress.org/Function_Reference/add_filter" target="_blank">filters</a>/changes the output that gets sent to the user.</p>
<p>The WordPress core effectively eats it&#8217;s own dog food. Rather than specifically formatting the output of <code>the_content()</code> inside the function, for instance, the WordPress core adds filters to <code>the_content</code>.  This means, of course, that you, as a user/developer are free to unhook those formatting functions and do whatever you want.</p>
<h2>The Most Interesting File in WordPress</h2>
<p>To see all the actions and filters the WordPress core uses, you needn&#8217;t look any further than <a href="http://core.trac.wordpress.org/browser/trunk/wp-includes/default-filters.php" target="_blank">wp-includes/default-filters.php</a>.</p>
<p>As an example, let&#8217;s explore what exactly happens when one uses the <code>the_content();</code> function.  Here&#8217;s that function:</p>
<pre>
&lt;?php
function the_content($more_link_text = null, $stripteaser = false) {
    $content = get_the_content($more_link_text, $stripteaser);
    $content = apply_filters(&#039;the_content&#039;, $content);
    $content = str_replace(&#039;]]&gt;&#039;, &#039;]]&amp;gt;&#039;, $content);
    echo $content;
}
</pre>
<p>Most of the WordPress core follows this sort of design pattern: <code>the_something</code> is a wrapper around <code>get_the_something</code> that only echoes out the value (and usually runs it through a filter).</p>
<p>In this case, the line we&#8217;re interested in is the <code>apply_filters('the_content', $content);</code>.  This tells WordPress to fire the filter hook <code>the_content</code>.  Any functions hooked into <code>the_content</code> will fire, receiving the post content as an argument.  Now that we know which filter fires, we can go explore the default filters file to see what happens:</p>
<pre>
&lt;?php
add_filter( &#039;the_content&#039;, &#039;wptexturize&#039;        );
add_filter( &#039;the_content&#039;, &#039;convert_smilies&#039;    );
add_filter( &#039;the_content&#039;, &#039;convert_chars&#039;      );
add_filter( &#039;the_content&#039;, &#039;wpautop&#039;            );
add_filter( &#039;the_content&#039;, &#039;shortcode_unautop&#039;  );
add_filter( &#039;the_content&#039;, &#039;prepend_attachment&#039; );
</pre>
<p>There are six separate functions hooked into <code>the_content</code> here &#8212; there are actually a few more hooked into <code>the_content</code> in other parts of the default filters file.  Now that you know what functions are getting fired, you can go and figure out what exactly they do.  <a href="http://codex.wordpress.org/Function_Reference/wptexturize" target="_blank">wptexturize</a>, for instance, <a href="http://core.trac.wordpress.org/browser/trunk/wp-includes/formatting.php#L29" target="_blank">converts</a> certain characters into their html entity equivalents.</p>
<h2>Why This Matters</h2>
<p>Most of the time, how the core uses its own hook system doesn&#8217;t matter.  But when you want to change WordPress&#8217; default behavior, you are able to. It&#8217;s also possible that the filters the core uses may conflict or cause unexpected behavior in your theme or plugin.  At that point, it&#8217;s up to you to track things down.</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/fpeJ85Ta-hk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/interesting-file-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/interesting-file-wordpress</feedburner:origLink></item>
		<item>
		<title>Discover Who’s Linking to You with Google Analytics New Backlink URL Report</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/k2H4Q43LcrU/discover-whos-linking-google-analytics-new-backlink-url-report</link>
		<comments>http://pmg.co/discover-whos-linking-google-analytics-new-backlink-url-report#comments</comments>
		<pubDate>Thu, 24 May 2012 14:00:52 +0000</pubDate>
		<dc:creator>Michael McCully</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2178</guid>
		<description><![CDATA[Earlier this month Google announced a brand new way to monitor who’s linking to your site, allowing users to view all the backlink URL’s via Google Analytics, “Have you ever wondered which other pages on the web link to your own? Wouldn’t it be nice to know which sites are talking about your content, and [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><img class="aligncenter  wp-image-2187" src="http://pmg.co/wp-content/uploads/2012/05/Google-Analytics1.jpeg" alt="Google Analytics" width="306" height="221" /></p>
<p>Earlier this month Google announced a brand new way to monitor who’s linking to your site, allowing users to view all the backlink URL’s via Google Analytics,</p>
<p>“Have you ever wondered which other pages on the web link to your own? Wouldn’t it be nice to know which sites are talking about your content, and in which context? Well, a problem no more: now you can see all the backlink URL’s, post titles, and more right within the new Social reports.”</p>
<p>Google explains,</p>
<p>“These reports provide another layer of social insight showing which of your content attracts links, and enables you to keep track of conversations across other sites that link to your content. Most website and blog owners had no easy mechanism to do this in the past, but we see it as another important feature for holistic social media reports. When you know what your most linked content is, it is then also much easier to replicate the success and ensure that you are building relationships with those users who actively link to you the most.”</p>
<p><em></em>For most, this sounds like a breakthrough.  The ability to analyze your impact on Facebook, Twitter and other social platforms is a valuable tool for any company website or blog.  However, the backlink reports currently lack the right configurations to view aggregated data.  This setup works great for Social Media experts who aren’t too concerned with the ability to segment or filter data but for SEOs who want the truth, keep reading.</p>
<p>A few simple tricks can shift the focus of these reports towards SEO, allowing users to see where links are originating, who’s linking the most and etc.  First, navigate through Analytics in this order: Traffic Sources &gt; Social &gt; Pages.</p>
<ul>
<li>Once inside Pages, select a URL and then click on the Activity Stream tab near the top of the page to view the activity for a specific URL.  Click on the Events tab near the middle of the screen to see an event list for that same URL.</li>
<li>Backlink reports default to a view per page structure &#8211; to view all backlinks per site simply click “All” near the top of the screen.  This loads every backlink for the selected time period onto one page.</li>
<li>Click on the green Trackback arrow (see below) to see a list of all external sites that are linking to that page.  This will filter the Activity Stream to Trackbacks only – listing all of your pages Trackbacks by date.<a href="http://pmg.co/discover-whos-linking-google-analytics-new-backlink-url-report/trackback-icon" rel="attachment wp-att-2180"><img class="aligncenter size-full wp-image-2180" src="http://pmg.co/wp-content/uploads/2012/05/Trackback-Icon.png" alt="" width="288" height="49" /></a></li>
<li>To see how many new sites have linked to your website in the last day, go to the Date Range and change the date to Yesterday or choose a custom date.</li>
<li>Skip the navigation process of monitoring Backlinks by creating a widget on your Dashboard.  Simply follow the previously mentioned steps to arrive at your destination and select Add to Dashboard near the top of the page.</li>
</ul>
<p>Using these tips and tricks will better allow you to monitor which pages are getting the most links, and hopefully enhance your optimization process thereafter.  I expect we will be seeing more and more additions to this new Social Reports feature in the near distant future!</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/k2H4Q43LcrU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/discover-whos-linking-google-analytics-new-backlink-url-report/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/discover-whos-linking-google-analytics-new-backlink-url-report</feedburner:origLink></item>
		<item>
		<title>Will Apple’s Retina Display Macs Ruin Web Design</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/UeNq86dBPe0/will-apples-retina-display-macs-ruin-web-design</link>
		<comments>http://pmg.co/will-apples-retina-display-macs-ruin-web-design#comments</comments>
		<pubDate>Fri, 18 May 2012 19:12:25 +0000</pubDate>
		<dc:creator>Chris Alvares</dc:creator>
				<category><![CDATA[Apple Rumors]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Tech News]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2158</guid>
		<description><![CDATA[News broke out earlier this week about Apple&#8217;s Macbook pro, Macbook Air and iMacs gaining a retina display this summer, most likley with WWDC. At first I was excited about the news, it was about time that 3D was kicked out, and the true next real big advancement in Monitor and TV technology came about. [...]]]></description>
			<content:encoded><![CDATA[<p>News broke out earlier this week about Apple&#8217;s Macbook pro, Macbook Air and iMacs gaining a retina display this summer, most likley with WWDC. At first I was excited about the news, it was about time that 3D was kicked out, and the true next real big advancement in Monitor and TV technology came about. Then I thought back to when the iPhone 4 was announced, and I got chills. </p>
<p>When Apple released the iPhone 4 with a retina display, and a super high resolution, they converted the default measurement of iOS from Pixels to Points. This made it super easy for native app developers to keep using the old iPhone measurements, with the device scaling up to the new resolution automatically. It was however, created problems for web developers who were building mobile sites. Before, they would only have to put an image src with the image, but now, they have to check the user agent string or use custom CSS/JS, see if the current device is a retina display, and then display a high quality image.</p>
<p>That was ok at the time because mobile sites were still in a baby stage, and web developers could write that code as they developed the mobile site. However, now, with the new Retina Display Macs, a real big problem comes into play. How does Apple handle Pixels vs Points.</p>
<p>I think Apple will keep it inline with iOS, and change the default measurement for applications to points. This would require no change for developers, other than to update their images with a high resolution version for Mac OS X to use. However, with the web, this still creates blurry images. When I first viewed Google on my iPhone 4, the logo looked pixelated, and a bit blurry. With Apple&#8217;s Retina Display Macs, that blurriness becomes a problem for the entire web. </p>
<p><a href="http://pmg.co/wp-content/uploads/2012/05/retina.png" rel="lightbox[2158]"><img src="http://pmg.co/wp-content/uploads/2012/05/retina.png" alt="Retina Display Images Vs Standard Images" width="480" height="350" class="aligncenter size-full wp-image-2159" /></a><br />
<em>Difference Between Retina Images and Standard Images</em></p>
<p>Applications that were built long ago will now have to pay more development and artists dollars to upgrade their code and images on the website to be retina display ready. Display Media will have to create two versions of ads, one for retina displays, and one without, and when you are talking about creating hundreds of banners, advertising agencies will now have to double that. </p>
<p><em>Featured Image from Ars Technica</em></p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/UeNq86dBPe0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/will-apples-retina-display-macs-ruin-web-design/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/will-apples-retina-display-macs-ruin-web-design</feedburner:origLink></item>
		<item>
		<title>5 Useful Excel Tips for SEO Noobs</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/ilYrHYdDTsE/5-useful-excel-tips-for-seo-noobs</link>
		<comments>http://pmg.co/5-useful-excel-tips-for-seo-noobs#comments</comments>
		<pubDate>Fri, 11 May 2012 13:00:09 +0000</pubDate>
		<dc:creator>Michael McCully</dc:creator>
				<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2129</guid>
		<description><![CDATA[When it comes to using Excel for SEO, whether you’re modifying a large list of URLs or updating a few thousand Title Tags there are a few essential Excel shortcuts that can dramatically increase your workflow. Mr. Miyagi once said, “You trust the quality of what you know, not quantity.” I like to apply this [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to using Excel for SEO, whether you’re modifying a large list of URLs or updating a few thousand Title Tags there are a few essential Excel shortcuts that can dramatically increase your workflow.</p>
<p>Mr. Miyagi once said, “You trust the quality of what you know, not quantity.”</p>
<p>I like to apply this approach to SEO.  Starting out, you may share many of the same frustrations of Daniel-san as you begin to paint your Title Tags and polish your URLs but with persistence, it won’t be long until you’re kicking SEO butt!  Although learning Excel’s more advanced keyboard shortcuts and functions takes time, with that comes a wealth of knowledge that is sure to double your efficiency as you accumulate valuable functions along the way.</p>
<h2>1. Find And Replace</h2>
<p>This is a very practical tool that makes updating Title Tags a breeze.  For example, say you have a lengthy list of products where over 200 isolated instances of “Hat” needs to be renamed “Baseball Cap”.  Simply use the keyboard shortcut CTRL+F, or click Edit from the menu bar, and select Find to open the Find and Replace tool.  Where it says, “Find what:” type, “Hat” to select every instance of the word.  Now click Replace and where it says, “Replace with:” type, “Baseball Cap” and click Replace All.  Now you’ve updated over 200 products in only a few short clicks.</p>
<p>Now this,</p>
<div id="attachment_2131" class="wp-caption aligncenter" style="width: 510px"><img src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-10-at-3.19.52-PM-500x214.png" alt="Excel Find &amp; Replace for SEO" title="Excel Find &amp; Replace for SEO" width="500" height="214" class="size-medium wp-image-2131" /><p class="wp-caption-text">Excel Find &#038; Replace Step 1</p></div>
<p>Looks like</p>
<div id="attachment_2132" class="wp-caption aligncenter" style="width: 510px"><img src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-10-at-3.21.07-PM-500x114.png" alt="Excel Find &amp; Replace for SEO" title="Excel Find &amp; Replace for SEO 2" width="500" height="114" class="size-medium wp-image-2132" /><p class="wp-caption-text">Excel Find &#038; Replace Step 2</p></div>
<h2>2. Excel Filtering</h2>
<p>The Filter tool functions similarly to the Find and Replace tool; however filtering works better for more invasive editing.  If you have a workbook with thousands of products and you want to edit every product that contains the word “Portable”, simply click on the Product Column, and select the Filter tool.  If you’re using Excel 2011, you should see that your Product Column now has a drop down arrow.  Click on the drop down arrow and the Filter tool appears.  Locate the Filter Method box and select Contains.  Now type “Portable” in the toolbox and HiYa! Every portable product in your inventory is displayed.</p>
<p><img class="aligncenter size-medium wp-image-2133" src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-10-at-3.24.04-PM-500x143.png" alt="Excel Filtering for SEO" title="Excel Filtering for SEO" width="500" height="143" /></p>
<h2>3. The Excel Proper Function</h2>
<p>This simple little function capitalizes the first letter of each word in the desired cells, which is an important step in developing your Title Tags.  Type “=PROPER” in the desired cell, specifying what cells to affect: “=PROPER(C2)”.  So if Column C requires some capitalization, scoot over to D2 and type “=PROPER(C2)” and apply this function to the remainder of Column D.</p>
<p><img class="aligncenter size-full wp-image-2134" src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-10-at-3.25.33-PM.png" alt="The Excel Proper Function" title="The Excel Proper Function" width="385" height="127" /></p>
<h2>4.The Excel Len Function</h2>
<p>LEN is handy for a number of reasons, two of which being that LEN displays the number of characters in a cell, making data crunching much easier.  This is particularly useful when working on Title Tags and Meta Descriptions.  To display Column D’s character lengths in Column E, Key in “=LEN(D2)” in E2.  Now column E displays the character length of all your Title Tags.</p>
<p><img class="aligncenter size-full wp-image-2135" src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-10-at-3.26.42-PM.png" alt="The Excel Len Function" title="The Excel Len Function" width="468" height="96" /></p>
<p>You want to shoot for less than 70 characters on your Title Tags and less than 156 on Meta otherwise the Black Belts over at Google will surely truncate you.</p>
<h2>5. Total Concatenation</h2>
<p>The Concatenate Function is the mother of all timesavers.  Think of it as the Karate Kid’s “Crane Kick” that delivers the final blow to win the championship.  In place of tediously keying in our Meta and Title Tags, we will use “=CONCATENATE” to aggregate all of our product information into one cell. So, if Columns A and C are product descriptions and Column D is your Title Tag column, key in “=CONCATENATE(A2,&#8221; : &#8220;,C2,&#8221; | YourCompany.com&#8221;).  Depending on your preferences, you may want to modify this function to enhance your Title Tags’ visual aspect.</p>
<p><img class="aligncenter size-medium wp-image-2139" src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-10-at-3.34.49-PM-500x85.png" alt="Excel Concatenation for SEO" title="Excel Concatenation for SEO" width="500" height="85" /></p>
<p>For such a complicated task it’s a pretty simple function that will save you lots of time.</p>
<p>Congratulations Grasshopper, you’ve earned your White Belt in SEO!</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/ilYrHYdDTsE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/5-useful-excel-tips-for-seo-noobs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/5-useful-excel-tips-for-seo-noobs</feedburner:origLink></item>
		<item>
		<title>I’d Turn That! Configuring Your iPhone App To Accept Multiple UIInterfaceOrientations</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/VoYPFd5qkPQ/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations</link>
		<comments>http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations#comments</comments>
		<pubDate>Fri, 04 May 2012 22:44:08 +0000</pubDate>
		<dc:creator>Hector Matos</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2071</guid>
		<description><![CDATA[When developing an iPhone or iPad app, the developer has quite a lot to think about: How will this app benefit my audience? How can I make it pretty enough to keep them interested? How can I write this app with the least amount of code possible? Does it need to be able to show [...]]]></description>
			<content:encoded><![CDATA[<p>When developing an iPhone or iPad app, the developer has quite a lot to think about:</p>
<p>How will this app benefit my audience?</p>
<p>How can I make it pretty enough to keep them interested?</p>
<p>How can I write this app with the least amount of code possible?</p>
<p>Does it need to be able to show different orientations?</p>
<p>Well in this post I&#8217;m going to at least answer that last question. You see, employing different <em>UIInterfaceOrientations</em> within your app can have many advantages. One example is for people who prefer typing in Landscape over typing in portrait.</p>
<p>Let&#8217;s say you have ten <em>UITextFields</em> in a form that the user is going to have to type a lot of information into. I don&#8217;t know about you, but I&#8217;m a landscape typer on my iPhone and if it were me, the first thing I do when I see that many <em>UITextFields</em> is flip my phone to the side so I can bust out my information pretty fast. If your app doesn&#8217;t have that capability, then personally I don&#8217;t care about using it. If I wanted to be forced to type my information into a form in only one way, then I&#8217;ll just pull out my computer so I can do it on there. I mean, what&#8217;s the point of having a phone with orientation capabilities if I can&#8217;t use it?</p>
<p>Well I created an app Project in Xcode 4.3 to show you step by step how to throw multiple <em>UIInterfaceOrientations </em>in your app.</p>
<p>First, you want to open up your app target in Xcode. It should look something like this:</p>
<p><a href="http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/screen-shot-2012-05-04-at-12-42-18-pm-2" rel="attachment wp-att-2091"><img class="aligncenter size-medium wp-image-2091" src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-04-at-12.42.18-PM1-500x264.png" alt="" width="500" height="264" /></a></p>
<p>You see, Xcode has lately made this process easier. Before, you had to go into your info tab, find the &#8220;custom IOS Target Property&#8221; that says &#8220;supported interface orientations&#8221; and add them in there by yourself but now, we have these nifty buttons that you can press that automatically does that for you. So first, you&#8217;re going to want to press each button that you see above that indicates which interface orientations you want your app to support. As you can see, my app supports <em>UIInterfaceOrientationPortrait</em>, <em>UIInterfaceOrientationLandscapeLeft</em>, and <em>UIInterfaceOrientationLandscapeRight.</em></p>
<p>Next, go to your <em>UIViewController </em>that you want to support different orientations. For this post, I created a <em>BlogViewController</em> instance to show you how to do this with pictures.</p>
<p>In your <em>XIB </em>file, Xcode has an autosizing feature that autosizes any object that you have as the view itself changes. This is what you&#8217;re going to want to use for most of your controllers.</p>
<p style="text-align: center"><a href="http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/screen-shot-2012-05-04-at-12-58-02-pm" rel="attachment wp-att-2092"><img class="size-full wp-image-2092 aligncenter" src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-04-at-12.58.02-PM.png" alt="" width="260" height="469" /></a></p>
<p style="text-align: center"><a href="http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/screen-shot-2012-05-04-at-1-00-08-pm" rel="attachment wp-att-2093"><img class="size-medium wp-image-2093 aligncenter" src="http://pmg.co/wp-content/uploads/2012/05/Screen-Shot-2012-05-04-at-1.00.08-PM-500x421.png" alt="" width="500" height="421" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Inside of the autosizing box is everything you need to manipulate your objects as your view changes orientations. Each of the arrows when clicked makes your object expand with the screen in whichever direction you press the arrow. For example, clicking the red horizontal arrow causes your object (i.e. your <em>UITextField</em>) to expand as the width of your view expands.</p>
<p>But this is important so pay attention; you see the outside lines that look like H&#8217;s? <strong>Those are anchors. </strong>When you click those anchor lines, your object will anchor to the view on the side of the line you clicked. For example, if you clicked the anchor line on the left and you turn your device from Portrait to Landscape, that object will always retain the same distance from the left side of that view in Landscape as it does in Portrait. Turning off both left and right anchors keeps your object in the middle at all times.</p>
<p>Generally, there are about two methods out of quite a few that you&#8217;ll pretty much use all the time when manipulating your objects when you&#8217;re switching from <em>UIInterfaceOrientationPortrait </em>to <em>UIInterfaceOrientationLandscape </em>and vice versa. Below, I have a few examples of these methods and also a header file that I created that automatically generates the width and height self&#8217;s interface orientation :</p>
<p>First, create your header file that generates the width and height of self interfaceOrientation and import it into each controller&#8217;s header file that you want to use it in:</p>
<pre>

#import &lt;Foundation/Foundation.h&gt;

static float WidthForUIInterfaceOrientation(UIInterfaceOrientation orientation)

{

return (UIInterfaceOrientationIsPortrait(orientation)) ? 320.0 : 480.0;

}

static float HeightForUIInterfaceOrientation(UIInterfaceOrientation orientation)

{

return (UIInterfaceOrientationIsPortrait(orientation)) ? 416.0 : 268.0;

}
&lt;div&gt;&nbsp;</pre>
</div>
<div></div>
<div>Now here are the examples of the <em>rotateInterfaceOrientation </em>methods that you&#8217;ll use quite a bit:</div>
<pre>

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

// &nbsp; &nbsp; In here you&#039;re going to want to return YES for all supported orientations. As well, for each UIViewController&nbsp;in a UINavigationController&nbsp;you can limit that view&#039;s orientation to whatever you want. In this example, I&#039;m limiting the view to only accept UIInterfaceOrientationPortrait. If your app supports UIInterfaceOrientationUpsideDown,&nbsp;then this line causes your view to accept that as well. If you want it to only accept, for example, UIInterfaceOrientationLandscapeRight, then you&#039;d just replace this line with &quot;return interfaceOrientation == UIInterfaceOrientationLandscapeRight;&quot;.

return UIInterfaceOrientationIsPortrait([self interfaceOrientation]);

}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

{

// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;In this method, you&#039;re going to want to implement code that manipulates your objects &lt;strong&gt;BEFORE &lt;/strong&gt;the animation finishes to your new orientation. I have an example below that changes my scroll view&#039;s frame according to each orientation.

CGRect blogScrollViewFrame = [blogScrollView frame];

blogScrollViewFrame.size.height = (keyboardIsShowing &amp;amp;&amp;amp; UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) ? &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;HeightForUIInterfaceOrientation(toInterfaceOrientation) - keyboardPortraitHeight : (keyboardIsShowing &amp;amp;&amp;amp; UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) ? HeightForUIInterfaceOrientation(toInterfaceOrientation) - keyboardLandscapeHeight : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;HeightForUIInterfaceOrientation(toInterfaceOrientation);

blogScrollViewFrame.size.width = WidthForUIInterfaceOrientation(toInterfaceOrientation);

blogScrollViewFrame.origin.y = (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) ? 44.0 : 32.0;

[UIView animateWithDuration:duration

animations:^{

[blogScrollView setFrame:blogScrollViewFrame];

[blogScrollView setContentSize:scrollArea.frame.size];

} completion:^(BOOL finished) {

float textFieldY = (textFieldReference == addressLine2TextField) ? textFieldReference.frame.origin.y - 34.0 : (!keyboardIsShowing) ? 0.0 : textFieldReference.frame.origin.y - 3.0;

if ((textFieldY &amp;gt; scrollArea.frame.size.height - blogScrollViewFrame.size.height) &amp;amp;&amp;amp; (textFieldY != 0.0)) {

textFieldY = scrollArea.frame.size.height - blogScrollViewFrame.size.height;

}

[blogScrollView setContentOffset:CGPointMake(0.0, textFieldY) animated:TRUE];

}];

}
</pre>
<p>Basically this is what the result will be:<a href="http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/screenshot-2012-05-04-12-55-13" rel="attachment wp-att-2100"><img class="aligncenter size-medium wp-image-2100" src="http://pmg.co/wp-content/uploads/2012/05/Screenshot-2012.05.04-12.55.13-333x500.png" alt="" width="333" height="500" /></a></p>
<p><a href="http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/screenshot-2012-05-04-12-55-59-2" rel="attachment wp-att-2102"><img class="aligncenter size-medium wp-image-2102" src="http://pmg.co/wp-content/uploads/2012/05/Screenshot-2012.05.04-12.55.591-500x333.png" alt="" width="500" height="333" /></a><a href="http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/screenshot-2012-05-04-12-55-19" rel="attachment wp-att-2103"><img class="aligncenter size-medium wp-image-2103" src="http://pmg.co/wp-content/uploads/2012/05/Screenshot-2012.05.04-12.55.19-500x333.png" alt="" width="500" height="333" /></a><a href="http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/screenshot-2012-05-04-12-55-20" rel="attachment wp-att-2104"><img class="aligncenter size-medium wp-image-2104" src="http://pmg.co/wp-content/uploads/2012/05/Screenshot-2012.05.04-12.55.20-500x333.png" alt="" width="500" height="333" /></a></p>
<p>Now I&#8217;ve found a couple of problems with Apple&#8217;s rotation system&#8230;one thing to look out for is a little quirk with <em>UITabBarControllers</em>. Basically, I&#8217;ve noticed that no matter what I do&#8230;when you initialize each tab with a <em>UINavigationController </em>as each tab&#8217;s respective <em>RootViewController</em>, then when you try to disable only one of the tabs <em>RootViewController&#8217;s </em>shouldRotateToInterfaceOrientation methods by returning NO on any supported orientation, then what happens is that the other tabs get disabled as well. As far as I can see, the phone won&#8217;t autorotate the tabs as soon as you press any other tab but the one you&#8217;re disabling.</p>
<p>I can&#8217;t really think of any other problems but hopefully I&#8217;ve taught y&#8217;all a bit about UIInterfaceOrientations&#8230;so with that, I bid thee farewell reader. Until next time!</p>
<p>Happy Coding!</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/VoYPFd5qkPQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/id-turn-that-configuring-your-iphone-app-to-accept-multiple-uiinterfaceorientations</feedburner:origLink></item>
		<item>
		<title>How New Change to Google Adwords Keyword Match Type Effects Your PPC Campaigns</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/kt-FQiCPZvQ/how-new-change-to-google-adwords-keyword-match-type-effects-your-ppc-campaigns</link>
		<comments>http://pmg.co/how-new-change-to-google-adwords-keyword-match-type-effects-your-ppc-campaigns#comments</comments>
		<pubDate>Fri, 04 May 2012 15:05:00 +0000</pubDate>
		<dc:creator>Duy Vu</dc:creator>
				<category><![CDATA[PPC]]></category>
		<category><![CDATA[google adwords]]></category>
		<category><![CDATA[google ppc]]></category>
		<category><![CDATA[matchtype]]></category>
		<category><![CDATA[misspellings]]></category>
		<category><![CDATA[ppc]]></category>
		<category><![CDATA[variations]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2073</guid>
		<description><![CDATA[According to Google, 7% of the internet can’t spell. To cater to them, Google has decided to include an option in Adwords for advertisers to “Include plurals, misspellings, and other close variants” for exact and phrase match keywords.  The other option being “Do not include close variants.“ Here’s where the option is in your account [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://adwords.blogspot.com/2012/04/new-matching-behavior-for-phrase-and.html">According to Google</a>, 7% of the internet can’t spell. To cater to them, Google has decided to include an option in Adwords for advertisers to “Include plurals, misspellings, and other close variants” for exact and phrase match keywords.  The other option being “Do not include close variants.“</p>
<p>Here’s where the option is in your account campaign settings:</p>
<p><a href="http://pmg.co/how-new-change-to-google-adwords-keyword-match-type-effects-your-ppc-campaigns/googlemisspelling" rel="attachment wp-att-2074"><img class="size-medium wp-image-2074 aligncenter" src="http://pmg.co/wp-content/uploads/2012/05/googlemisspelling-500x248.jpg" alt="google misspelling option" width="500" height="248" /></a></p>
<p>With roughly 7% of impressions coming from misspelled keywords it also means 7% of searches result in undelivered ads. <em>It’s an untapped stream of revenue for Google!</em> So of course, the folks at Google immediately integrated this little feature and &#8216;secretly&#8217; turned it on for all existing campaigns <strong>by default</strong>. So if you notice a 7% spike in impressions or clicks, you’ll know why.</p>
<p>The problem is it could lead to budget problems or ROI problems for campaigns that have already been optimized.  You can always turn this new feature off in the campaign settings, but I figured Google would have this option turned off by default once they gave us the option &#8211; but that’s not the case.</p>
<p>Here are a few other challenges I see with this new option:</p>
<ol>
<li>Those misspelled keywords that you used to bid on, where no other competition existed before, will now be joined by other competitors.  This also applies to your trademark keywords!</li>
<li> Who gets more preference out of the two settings? Let’s say you’re using the first option to cover misspellings and variations of correctly spelled keywords in your list while a competitor chooses the second option to not include misspellings however they include misspellings in their list. What’s going to happen?  Sounds like it will come down to a bidding war for top spot.</li>
</ol>
<p>On the other hand, you could get more qualified traffic, you could get more conversions from that traffic, you could also find more exact keyword search queries to add and expand on for your campaign. So I can see why this new matchtype feature can turn out to benefit or be advantageous for some advertisers, I just didn’t like the fact that Google had it turned on by default without letting us do a little testing first.</p>
<p>If your wondering if this option is available in adwords editor (current version 9.7.1), unfortunately it doesn&#8217;t exist yet.  So at the moment if you want to change the option for this new misspelling matchtype feature to a few hundred campaigns at once it’s going to be through the web interface where you can enjoy the tedious task of clicking through to each campaign one at a time, changing the settings, and developing a minor case of carpel tunnel syndrome.</p>
<p>It would also be nice if Google gave us an option in their keyword tool to include misspellings.  Currently, the only way to gauge how often a misspelled keyword is being searched for is if you enter in the misspelling it self.</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/kt-FQiCPZvQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/how-new-change-to-google-adwords-keyword-match-type-effects-your-ppc-campaigns/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/how-new-change-to-google-adwords-keyword-match-type-effects-your-ppc-campaigns</feedburner:origLink></item>
		<item>
		<title>My Progress with Objective-C thus far</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/u-oLldlfp0U/my-progress-with-objective-c-thus-far</link>
		<comments>http://pmg.co/my-progress-with-objective-c-thus-far#comments</comments>
		<pubDate>Thu, 03 May 2012 20:53:25 +0000</pubDate>
		<dc:creator>Hector Matos</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=1554</guid>
		<description><![CDATA[So here&#8217;s the deal. I&#8217;ve published one blog post about things I&#8217;ve learned about Objective-C but in reality, I wrote that post about two to three weeks ago. I would go on pretending that this next week&#8217;s post is actually what I learned in one week after that last post, but let&#8217;s face it &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>So here&#8217;s the deal. I&#8217;ve published one blog post about things I&#8217;ve learned about Objective-C but in reality, I wrote that post about two to three weeks ago. I would go on pretending that this next week&#8217;s post is actually what I learned in one week after that last post, but let&#8217;s face it &#8211; I&#8217;m not actually going to do that. Instead, I&#8217;ll catch you up on what I&#8217;ve learned under my mentor, Andrew Strauss, and then tell you my progress thus far.</p>
<p>I&#8217;m sure we all can agree that a lot can happen in to to three weeks. In fact, in that time I&#8217;ve already had a baby, I finished trying to make the Bro Code app to move on to bigger and better things, and I&#8217;m already almost to the point where I can write 80% of an iPhone app on my own.</p>
<p>Let&#8217;s tackle each thing one by one shall we?</p>
<h2>1. I had a baby</h2>
<p>Yes, yours truly had his first baby and IT&#8217;S A GIRL!!! She is absolutely gorgeous and as of this posting, she is about 6-7 days old and already sleeps through the night. <img src='http://pmg.co/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Her name is Brooke Abigail Matos and sad to say, but I may have fallen in love with someone other than my wife.</p>
<div id="attachment_1562" class="wp-caption aligncenter" style="width: 510px"><img class="size-medium wp-image-1562" src="http://pmg.co/wp-content/uploads/2012/03/IMG_0269-500x375.jpg" alt="" width="500" height="375" /><p class="wp-caption-text">My Baby Girl</p></div>
<h2>2. I stopped working on the Bro Code app</h2>
<p>I know &#8211; for all you How I Met Your Mother fans out there, this would&#8217;ve been an amazing app to put out but unfortunately, the app was really only created to teach me the basics behind Objective-C and Cocoa. Challenge accepted! And job well done. We can actually put this little guy to rest until I decide to come back to him on my free time.</p>
<h2>3. Bigger and better things</h2>
<p>So what am I doing now that I laid The Bro Code to rest? Actual work. George reckoned that I should start on another  app for one of our clients that was created by someone else&#8230;who&#8217;s to argue with the boss?<br />
&nbsp;<br />
I can&#8217;t tell you how many bugs we&#8217;ve found so far, and the sheer amount of UI mistakes as well. To say the least, I believe we&#8217;re about a third of the way through the app and we have a 6th of the amount of source files he does. The original author repeats hundreds of lines of code even though with Objective-C, it&#8217;s pretty easy to condense all of those lines of code with a couple of simple lines of code. For instance, let&#8217;s say you wanted to bring up a loading view in certain methods throughout your app when you make a call to the server:<br />
&nbsp;<br />
Instead of writing this code over and over when you want it to pop up&#8230;</p>
<pre>

UIView *loadingView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height)];

UILabel *loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(110.0, (self.view.frame.size.height-46.0)/2.0, 100.0, 21.0)];

UIActivityIndicator *loadingIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150.0, ((self.view.frame.size.height-(loadingLabel.frame.size.height+25.0))/2.0) + loadingLabel.frame.size.height+5.0, 20.0, 20.0)];

[loadingLabel setBackgroundColor:[UIColor clearColor]];

[loadingLabel setTextAlignment:UITextAlignmentCenter];

[loadingLabel setLineBreakMode:UILineBreakModeWordWrap];

[loadingLabel setNumberOfLines:0];

[loadingView addSubview:loadingLabel];

[loadingView addSubview:loadingIndicator];

[loadingIndicator startAnimating];

[loadingView release];

[loadingLabel release];

[loadingIndicator release];
</pre>
<p>You can just take the above code, create a UILoadingViewController that is a subclass of UIViewController and implement a couple of methods that do exactly what I wrote above as you write your own code passing certain parameters to change the text, change the color of the loadingView background color, and throw in a couple of typedef enums to create different loadingView styles. Now, every time you have a ViewController that you want to have a loadingView in, you can just change the subclass on that ViewController to your LoadingViewController like this:</p>
<pre>

#import "yourHeader.h";

@interface YourViewController : LoadingViewController ;

{

}
</pre>
<p>And every time you want your loadingView to show up, just call whatever boolean method you wrote in your LoadingViewController to have it show up like this:</p>
<pre>
#import "LoadingViewController.h"

@implementation

- (void)setLoadingViewHidden:(BOOL)isHidden
{
    [loadingView setHidden:isHidden];
}
</pre>
<p>Call that method&#8230;</p>
<pre>
-(void)viewDidLoad
{
    [self setLoadingViewHidden:FALSE];
}
</pre>
<p>Now later on, all you have to do is call on line of code as opposed to about fifteen to twenty to call on you loadingView.</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/u-oLldlfp0U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/my-progress-with-objective-c-thus-far/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/my-progress-with-objective-c-thus-far</feedburner:origLink></item>
		<item>
		<title>Quick iPhone Tip: Flash for Text Messages</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/b5MfjqWuM6I/quick-iphone-tip-flash-for-text-messages</link>
		<comments>http://pmg.co/quick-iphone-tip-flash-for-text-messages#comments</comments>
		<pubDate>Wed, 02 May 2012 15:34:46 +0000</pubDate>
		<dc:creator>Chris Alvares</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2055</guid>
		<description><![CDATA[When I am at work, I usually lay my iPhone on the desk, on top of a stack of papers. Getting messages used to be problematic, because with my headphones in, and me jamming to the best tunes on the planet, I would not hear the phone vibrate. iOS 5 has a cool little feature [...]]]></description>
			<content:encoded><![CDATA[<p>When I am at work, I usually lay my iPhone on the desk, on top of a stack of papers. Getting messages used to be problematic, because with my headphones in, and me jamming to the best tunes on the planet, I would not hear the phone vibrate. iOS 5 has a cool little feature that will blink the flashlight whenever you get a new text message. Here is how to do it.</p>
<pre>
Open the Settings Application -&gt; General -&gt; Accessibility -&gt; LED Flash for Alerts -&gt; On
</pre>
<p><BR /><br />
<a href="http://pmg.co/wp-content/uploads/2012/05/photo-1.png" rel="lightbox[2055]"><img src="http://pmg.co/wp-content/uploads/2012/05/photo-1-500x375.png" alt="iPhone Turn on Flash for SMS How To" width="500" height="375" class="aligncenter size-medium wp-image-2057" /></a></p>
<p>That is it, your iPhone will now blink using the flash when you receive a text message, and receive a phone call. You can customize which applications turn on the blinker using Notification Center.</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/b5MfjqWuM6I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/quick-iphone-tip-flash-for-text-messages/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/quick-iphone-tip-flash-for-text-messages</feedburner:origLink></item>
		<item>
		<title>How to Set Up Directory Specific Bash (or other Shell) Environments</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/oX1nhSKdsO4/how-to-set-up-directory-specific-bash-or-other-shell-environments</link>
		<comments>http://pmg.co/how-to-set-up-directory-specific-bash-or-other-shell-environments#comments</comments>
		<pubDate>Mon, 30 Apr 2012 13:53:12 +0000</pubDate>
		<dc:creator>Christopher Davis</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[autoenv]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[sh]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=2041</guid>
		<description><![CDATA[As I am an avid *nix (mostly Ubuntu and OSX) user, I&#8217;m constantly trying to improve my workflow in the terminal (I use the Bash shell) and my dotfiles. One recent development has been the use of directory specific environments. Before getting into that, let&#8217;s talk about what happens when your terminal fires up. Loading [...]]]></description>
			<content:encoded><![CDATA[<p>As I am an avid *nix (mostly Ubuntu and OSX) user, I&#8217;m constantly trying to improve my workflow in the terminal (I use the <a href="http://en.wikipedia.org/wiki/Bash_(Unix_shell)" target="_blank">Bash shell</a>) and my <a href="https://github.com/chrisguitarguy/dotfiles">dotfiles</a>.  One recent development has been the use of <em>directory specific environments</em>.  Before getting into that, let&#8217;s talk about what happens when your terminal fires up.</p>
<h2>Loading the Environment</h2>
<p>When you fire up <a href="http://en.wikipedia.org/wiki/Xterm" target="_blank">xterm</a> or the Terminal.app, Bash looks for one of two files: <code>.bashrc</code> or <code>.bash_profile</code>. On most unix-like systems, including Ubuntu, xterm opens in a &#8220;non-login shell&#8221;, and non-login shells <code>source</code> (more on this later) <code>.bashrc</code>.  Login shells &#8212; any shell where you have to type your username and/or password &#8212; will load the <code>.bash_profile</code>.</p>
<p>Bash will look for both <code>.bashrc</code> and <code>.bash_profile</code> in your <code>$HOME</code> directory.  You can find out what that is like this:</p>
<pre>
shell$ cd ~
shell$ pwd
/Users/chris
</pre>
<p>On most linux distros it&#8217;s something like <code>/home/[your_user_name]</code>; in OSX it&#8217;s <code>/Users/[your_user_name]</code>.</p>
<p><strong>Use the Source</strong></p>
<p>Above, the word <code>source</code> was thrown around.  This just means read and execute the file.  It&#8217;s roughly the same as Python&#8217;s <code>import</code> or PHP&#8217;s <code>require</code> and <code>include</code>.  Any code statements in the main body of the file (eg. not inside a function definition) will be executed.</p>
<p>The essential idea of sourcing the <code>.bash_profile</code> or <code>.bashrc</code> file is to set up your environment.  You can change whatever you want here &#8212; like defining a custom prompt or setting up <a href="http://tldp.org/LDP/abs/html/aliases.html" target="_blank">aliases</a>.  </p>
<p>Unfortunately, the same &#8220;environment&#8221; might not be needed everywhere.  Here&#8217;s a few examples:</p>
<ul>
<li>The <a href="http://aws.amazon.com/developertools/351" target="_blank">EC2 command line tools</a> requires several <a href="http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html" target="_blank">environment variables</a>.  If you manage multiple clients on EC2, they&#8217;ll need separate certificate files active in the environment.  You&#8217;d have to set those up every time you needed to use the EC2 tools.</li>
<li>Using Python&#8217;s <a href="https://github.com/pypa/virtualenv/" target="_blank">virtualenv</a> effectively replaces your current set up with one that uses a specific set of libraries</li>
</ul>
<h2>Enter the `.env` File</h2>
<p>If you need to set up different environments, the solution is simple:  create a file name <code>.env</code> and put all the things you need to run in it.  Source the <code>.env</code> file after entering the directory to set up a directory specific environment.</p>
<pre>
shell$ cd /path/to/a/dir
shell$ source .env
</pre>
<p>Piece of cake!  But that&#8217;s not very fun.  Let&#8217;s see if we can make it happen automagically when we cd in.</p>
<p>Here&#8217;s a little function that checks to see if the file exists then sources it.</p>
<pre>
function make_env()
{
    if [ -f "$PWD/.env" ]; then
        source "$PWD/.env"
    fi
}
</pre>
<p>Now, let&#8217;s make that function run every time we cd into a directory.  We&#8217;ll create another function that tries to run the build in <code>cd</code> and, if successful, run the <code>maybe_env</code> function to source the <code>.env</code> file.</p>
<pre>
function replace_cd()
{
    if builtin cd "$@"; then
        maybe_env
    fi
}
</pre>
<p>Now we just need to alias <code>cd</code> to run <code>replace_cd</code></p>
<pre>
alias cd="replace_cd"
</pre>
<p>Every time you entire a directory, bash will look for the .env file and and source it if it&#8217;s there!</p>
<h2>Problems &#038; Improvements</h2>
<p>The above works, but it will source the .env file <em>every time</em> you enter the directory. Not a big deal, but not efficient.  It should only load the <code>.env</code> if it hasn&#8217;t already been loaded.  As a way around that, let&#8217;s improve the <code>maybe_env</code> function to&#8230;</p>
<ul>
<li>Check if <code>.env</code> exists</li>
<li>Check to see if the <code>CURRENT_ENV</code> environment variable is set or if it&#8217;s pointed to another <code>.env</code> file and source the current <code>.env</code> file if necessary</li>
</ul>
<pre>
function maybe_env()
{
    local env="$PWD/.env"
    if [ -f "$env" ]; then
        if [ -z "$CURRENT_ENV" ]; then
            # no current environment, source .env file
            builtin source "$env"
            export CURRENT_ENV="$env"
        elif [ ! "$CURRENT_ENV" = "$env" ]; then
            # we have a current environment setup
            # the environ we have setup is not this one
            # check to see if we have a deactivate function to run
            if [ "$(type -t deactivate)" = "function" ]; then
                deactivate
            fi
            builtin source "$env"
            export CURRENT_ENV="$env"
        fi
    fi
}
</pre>
<p>The above will store which <code>.env</code> file is in use and only try to source if <code>CURRENT_ENV</code> isn&#8217;t set or is pointed elsewhere.  It also attempts to deactivate the old <code>.env</code> file.</p>
<p>There are all sorts of cool things you can when CD&#8217;ing into a directory.  Like setting up <a href="https://github.com/chrisguitarguy/dotfiles/blob/master/bash/history.sh">directory specific history</a> or running <code>git status</code>.  Settings up a little directory specific environment is just one example.</p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/oX1nhSKdsO4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/how-to-set-up-directory-specific-bash-or-other-shell-environments/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/how-to-set-up-directory-specific-bash-or-other-shell-environments</feedburner:origLink></item>
		<item>
		<title>Leather and Lace</title>
		<link>http://feedproxy.google.com/~r/performancemediagroup/~3/k1YUe1R_vEQ/leather-and-lace</link>
		<comments>http://pmg.co/leather-and-lace#comments</comments>
		<pubDate>Fri, 27 Apr 2012 20:35:50 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://pmg.co/?p=1877</guid>
		<description><![CDATA[Sometimes when two, equally good things come together, the product sounds better in theory. Ketchup? Good. Ice cream? Good. Ice Ketchup Cream? Not so much. But other times, when two very different things come together, it&#8217;s beautiful. Granola and yogurt, for instance. Ozzy and Miss Piggy performing together on the Muppet Show, Sir Paul McCartney [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: Cambria">Sometimes when two, equally good things come together, the product sounds better in theory. Ketchup? Good. Ice cream? Good. Ice Ketchup Cream? Not so much. But other times, when two very different things come together, it&#8217;s beautiful. Granola and yogurt, for instance. Ozzy and Miss Piggy performing together on the Muppet Show, Sir Paul McCartney and MJ, Aerosmith and Run DMC.</span></p>
<p><span style="font-family: Cambria">Leather and lace, serif and script.</span></p>
<p><span style="font-family: Cambria">One of the most popular trends in design is combining contrasting typefaces. There are a few guidelines to keep in mind if you want to do this well, but showing severe contrast can go a long way in communicating multi-faceted personalities.</span></p>
<p><span style="font-family: Cambria">An important thing to remember is that you want to use a very legible script, not an overly elaborate one with three-inch curls and super-tight kerning. Use one that doesn’t require squinting or head-tilting. Using a heavy serif font, a slab serif, will provide a canvas for the whimsical script and the result, if you choose your fonts well, can be country-charm or upscale elegance.</span></p>
<p><a href="http://pmg.co/leather-and-lace/calligrapher-notes-wedding-invitations" rel="attachment wp-att-1878"><img class="alignnone size-full wp-image-1878" src="http://pmg.co/wp-content/uploads/2012/04/calligrapher-notes-wedding-invitations.jpg" alt="calligrapher notes wedding invitations" width="420" height="300" /></a></p>
<p><span style="font-family: Cambria">This wedding invitation, for example, combines an austere serif with an elegant script with elaborate, but sparingly-used swashes.</span></p>
<p><a href="http://pmg.co/leather-and-lace/bonnies-jams-2_6283" rel="attachment wp-att-1879"><img class="alignnone size-medium wp-image-1879" src="http://pmg.co/wp-content/uploads/2012/04/Bonnies-Jams-2_6283-500x376.jpg" alt="Bonnie's Jams" width="500" height="376" /></a></p>
<p><span style="font-family: Cambria">Bonnie’s Jams creates old-world charisma with its choice to showcase a simple schoolhouse cursive and using the serif font for the details.</span></p>
<p><a href="http://pmg.co/leather-and-lace/burciaga" rel="attachment wp-att-1880"><img class="alignnone size-medium wp-image-1880" src="http://pmg.co/wp-content/uploads/2012/04/Burciaga-500x311.jpg" alt="Burciaga" width="500" height="311" /></a></p>
<p><span style="font-family: Cambria">This woman’s design blog shows off her last name and mimics an ink-pen signature. She reserves this script, using it only in the main heading and for blog titles, thus maintaining the legibility and professionalism of her site.</span></p>
<img src="http://feeds.feedburner.com/~r/performancemediagroup/~4/k1YUe1R_vEQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pmg.co/leather-and-lace/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pmg.co/leather-and-lace</feedburner:origLink></item>
	</channel>
</rss>

