<?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>Julian Castaneda &#187; Solutions</title>
	<atom:link href="http://www.smooka.com/blog/category/solutions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.smooka.com/blog</link>
	<description>From programming to music!</description>
	<lastBuildDate>Mon, 29 Aug 2011 15:50:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>PHP: Change UTC time to local time</title>
		<link>http://www.smooka.com/blog/2011/06/03/utc-time-to-local-time/</link>
		<comments>http://www.smooka.com/blog/2011/06/03/utc-time-to-local-time/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 21:10:30 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[utc]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=439</guid>
		<description><![CDATA[Did you know that you can quickly change UTC time stamps to Local time by doing the following: It&#8217;s so obvious, but I only wished, I knew [...]]]></description>
			<content:encoded><![CDATA[<p>Did you know that you can quickly change UTC time stamps to Local time by doing the following:</p>
<pre class="brush: php; title: ; notranslate">
//make sure your time is set
date_default_timezone_set('America/New_York');

$datetime = '2004-02-12T15:19:21+00:00';

//convert the given datetime string to time
$newDatetime = strtotime($datetime);

//re-contruct to format
$newDatetime = date('Y-m-d H:i:s', newDatetime);
</pre>
<p>It&#8217;s so obvious, but I only wished, I knew this before trying all sort of crazy stuff. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2011/06/03/utc-time-to-local-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unit Testing your AJAX requests with Zend Framework and PHPunit</title>
		<link>http://www.smooka.com/blog/2011/01/15/unit-testing-ajax-requests-zend-framework-phpunit/</link>
		<comments>http://www.smooka.com/blog/2011/01/15/unit-testing-ajax-requests-zend-framework-phpunit/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 20:28:26 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[Frameworks and API's]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[PHPunit]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=421</guid>
		<description><![CDATA[I ran into a problem yesterday, when trying to create a couple of unit tests using PHPunit along side the Zend Framework. If you want to unit [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.smooka.com/blog/wp-content/uploads/phpunit.gif" alt="" title="phpunit" width="94" height="80" class="alignleft size-full wp-image-432" />I ran into a problem yesterday, when trying to create a couple of unit tests using <a href="https://github.com/sebastianbergmann/phpunit/" target="_blank">PHPunit</a> along side the <a href="http://zendframework.com/" target="_blank">Zend Framework</a>. </p>
<p>If you want to unit test an action in a controller that checks the request to see if is an XML HTTP Request using the <a href="http://www.smooka.com/blog/2009/04/17/5-things-working-with-zend-framework-and-ajax/">isXmlHttpRequest()</a> method provided by the Zend Framework, then you will definitely run into a problem.</p>
<p>isXmlHttpRequest() pretty much checks to see if the $_SERVER['HTTP_X_REQUESTED_WITH'] is set with &#8216;XMLHttpRequest&#8217;, if not, then returns FALSE. I thought that by setting the server variable with XMLHttpRequest directly will allow me to bypass the check.<br />
<span id="more-421"></span></p>
<pre class="brush: php; title: ; notranslate">
function myAjaxTestAction()
{
      $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';

      //then do your ajax tests here
}
</pre>
<p>This solution seemed like it was going to work, but it turns out that isXmlHttpRequest() makes a call to getHeader() like this:</p>
<pre class="brush: php; title: ; notranslate">
public function isXmlHttpRequest()
{
        return ($this-&gt;getHeader('X_REQUESTED_WITH') == 'XMLHttpRequest');
}
</pre>
<p>What I didn&#8217;t know is that when you are doing unit tests the framework extends the HTTP class and changes the getHeader() to only use headers set using the setHeader or setHeaders methods.<br />
After a couple of minutes tracing over the calls being made. I discovered that the fix was pretty simple, set our headers doing the following in your test case:</p>
<pre class="brush: php; title: ; notranslate">
function myAjaxTestAction()
{
      $this-&gt;request-&gt;setHeader('X_REQUESTED_WITH');

      //then do your ajax tests here
}
</pre>
<p>This will fake an AJAX request and return the expected result.</p>
<p>I hope this article helps many of you since I spent many hours trying to decipher why setting &#8216;XMLHttpRequest&#8217; to the $_SERVER did not work as I expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2011/01/15/unit-testing-ajax-requests-zend-framework-phpunit/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Fix GIT Lock after GIT Crash</title>
		<link>http://www.smooka.com/blog/2010/12/09/fix-git-lock-after-git-crash/</link>
		<comments>http://www.smooka.com/blog/2010/12/09/fix-git-lock-after-git-crash/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 16:04:12 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=412</guid>
		<description><![CDATA[If you ever see the following message when trying to commit your code to a GIT repository. If no other git process is currently running, this probably [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever see the following message when trying to commit your code to a GIT repository.</p>
<blockquote><p>If no other git process is currently running, this probably means a<br />
git process crashed in this repository earlier. Make sure no other git<br />
process is running and remove the file manually to continue.</p></blockquote>
<p><span id="more-412"></span><br />
The solution is very easy, just delete the .git/index.lock file<br />
<code>~ rm /yourhomedir/.git/index.lock</code></p>
<p>Then you need to do a git reset<br />
<code>~ git reset</code></p>
<p>That should do the trick. Let me know if this worked for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2010/12/09/fix-git-lock-after-git-crash/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installing Zend Studio on Ubuntu 64-bit</title>
		<link>http://www.smooka.com/blog/2009/11/02/installing-zend-studio-on-ubuntu-64-bit/</link>
		<comments>http://www.smooka.com/blog/2009/11/02/installing-zend-studio-on-ubuntu-64-bit/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 19:38:11 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Studio]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=224</guid>
		<description><![CDATA[Today I tried to install Zend Studio 7.0 on the latest 64-bit version of Ubuntu (9.10). Initially, it would just throw an error. (exec: 2481: /tmp/install.dir.2855/Linux/resource/jre/bin/java: not [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.smooka.com/blog/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/blog/wp-content/thumbnails/224.jpg&amp;w=70&amp;h=70&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Today I tried to install Zend Studio 7.0 on the latest  64-bit version of Ubuntu (9.10). Initially, it would just throw an error. (<em>exec: 2481: /tmp/install.dir.2855/Linux/resource/jre/bin/java: not found</em>). Since, the error was related to the installer not being able to find the java JRE that came bundled with the installer, I decided to install with the system&#8217;s JRE using:</p>
<p><code>./ZendStudio7_0_0.bin LAX_VM /usr/bin/java</code></p>
<p>That seemed to do the trick, but, once the installer had finished. Trying to open Zend Studio would give me an error <em>(Failed to execute child process &#8220;/usr/local/Zend/Zend Studio-7.0.0/ZendStudio&#8221; (No such file or directory)</em>). At this point I was about to give up, until I did a little bit of research and found that the problem was more simple that I imagined.<span id="more-224"></span></p>
<p>Just run the following command in your terminal window:</p>
<p><code>sudo aptitude install libc6-i386 ia32-libs</code></p>
<p>ia32 is a package that contains runtime libraries for the ia32/i386 architecture, configured for use on systems running a 64-bit kernel. This will allow to install and run Zend Studio, but It will enable compatibility with any other application designed for 32-bit processors.</p>
<p>After running the above command, and installing Zend Studio, I ran into my second problem. A bug in eclipse that would not allow me to click on next or finish in certain windows. In my case, was when I was trying to create a new remote connection. To fix this problem I had to do the following steps:</p>
<ul>
<li>1). Open terminal and go to Zend Studio Directory.</li>
<li>2). Create a new file called ZendStudio.sh and open it.<br />
<code>vi ZendStudio.sh</code></li>
<li>3). Paste the following code, save and then close it:<br />
<code>#!/bin/sh<br />
CURDIR=`dirname $0`<br />
export GDK_NATIVE_WINDOWS=1<br />
$CURDIR/ZendStudio</code></li>
<li>4). Change the permissions of the file for execution<br />
<code>chmod +w ZendStudio.sh</code></li>
<li>5). Go to your application launcher, and right click and select properties.<br />
Once in the properties dialog, modify the command field.</p>
<p>Change the path from:</p>
<p><code>"/home/{USER}/Zend/ZendStudio-7.0.0/ZendStudio"</code></p>
<p>to</p>
<p><code>"/home/{USER}/Zend/ZendStudio-7.0.0/ZendStudio.sh"</code></p>
<p>So basically you are adding the .sh extension.</li>
<li>6). Close the window and open Zend Studio, everything should be working fine now.</li>
</ul>
<p>I hope this information helps you if you happen to run with the same problem I did. Let me know if you have a different solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2009/11/02/installing-zend-studio-on-ubuntu-64-bit/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Maintaining PHP session when using CURL.</title>
		<link>http://www.smooka.com/blog/2009/07/24/maintaining-php-session-when-using-curl/</link>
		<comments>http://www.smooka.com/blog/2009/07/24/maintaining-php-session-when-using-curl/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 16:17:11 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=134</guid>
		<description><![CDATA[Working now on some iGoogle like dashboard for the system I&#8217;m developing. I was trying some stuff out with CURL and was having a hard time to [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.smooka.com/blog/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/blog/wp-content/thumbnails/134.jpg&amp;w=70&amp;h=70&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Working now on some iGoogle like dashboard for the system I&#8217;m developing.</p>
<p>I was trying some stuff out with CURL and was having a hard time to maintain my current session when making a curl request to another page. I needed to stay authenticated in order to retrieve my widget. </p>
<p>Here is my initial code:</p>
<pre class="brush: php; title: ; notranslate">
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
$ch = curl_init($rssFeedLink);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_COOKIE, $strCookie );
$response = curl_exec($ch);
curl_close($ch);
</pre>
<p>The problem with that piece of code is that it was generating a new session id instead of sending my current session.</p>
<p>The solution? <span id="more-134"></span> Put session_write_close() before you make the CURL request.</p>
<pre class="brush: php; title: ; notranslate">
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';

session_write_close();

$ch = curl_init($rssFeedLink);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_COOKIE, $strCookie );
$response = curl_exec($ch);
curl_close($ch);
</pre>
<p>What does session_write_close() do? It, ends the current session and store session data. Apparently, PHP does not like when multiple scripts play around with the session, so, it locks it. Putting session_write_close makes sure that your current session is stored so you can retrieve it and use it. </p>
<p>This little issue had my head spinning for a few hours, so, I hope this article helps you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2009/07/24/maintaining-php-session-when-using-curl/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

