<?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>Botched Code</title>
	<atom:link href="http://botchedcode.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://botchedcode.com</link>
	<description>just a "botched code" showcase</description>
	<lastBuildDate>Mon, 05 Dec 2011 18:35:08 +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>Reset a phpStorm project</title>
		<link>http://botchedcode.com/2011/12/05/reset-a-phpstorm-project/</link>
		<comments>http://botchedcode.com/2011/12/05/reset-a-phpstorm-project/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 18:35:08 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=213</guid>
		<description><![CDATA[I had a problem upgrading to phpStorm 3.0. Needed to kill the project data, for phpStorm to reset. $&#62; rm -rf .idea to clear the project data.]]></description>
			<content:encoded><![CDATA[<p>I had a problem upgrading to phpStorm 3.0.  Needed to kill the project data, for phpStorm to reset.  </p>
<pre class="brush: php">$&gt; rm -rf .idea</pre>
<p>to clear the project data.</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2011/12/05/reset-a-phpstorm-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting with Apache and SVN</title>
		<link>http://botchedcode.com/2011/11/18/hosting-with-apache-and-svn/</link>
		<comments>http://botchedcode.com/2011/11/18/hosting-with-apache-and-svn/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 15:10:44 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=211</guid>
		<description><![CDATA[Need to not serve SVN metadata/folders on apache? Solution here.]]></description>
			<content:encoded><![CDATA[<p>I have a requirement to not serve SVN meta data with the project, once deployed on a server.</p>
<p>So what can I do?<br />
Prevent Apache from serving the content:</p>
<p>Put an apache directive:</p>
<pre class="brush: php">&amp;amp;amp;lt;DirectoryMatch .*\.svn/.*&amp;amp;amp;gt;
Deny From All
&amp;amp;amp;lt;/DirectoryMatch&amp;amp;amp;gt;</pre>
<p>&nbsp;</p>
<p>or:</p>
<p>Remove all the SVN metadata altogether</p>
<p>While in the *nix prompt:</p>
<pre class="brush: php">find . -name &quot;.svn&quot; -type d -exec rm -rf {} \;</pre>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2011/11/18/hosting-with-apache-and-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac MAMP setup</title>
		<link>http://botchedcode.com/2011/06/17/mac-mamp-setup/</link>
		<comments>http://botchedcode.com/2011/06/17/mac-mamp-setup/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 14:17:12 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=196</guid>
		<description><![CDATA[install: mysql: http://www.mysql.com/downloads/mysql/ macports: http://www.macports.org/install.php run the following: $&#62; sudo port selfupdate $&#62; sudo port install apache2 tidy curl curl-ca-bundle php5-apc php5-curl php5-eaccelerator php5-gd php5-iconv php5-imagick php5-mbstring php5-mcrypt php5-mysql php5-soap php5-tidy php5-unit php5-uuid php5-xdebug php5-xmlrpc php5-xsl php5-zip wgetpro Go for a coffee/beer now&#8230; this will take a little time. edit the following files: edit /opt/local/apache/conf/http.conf enable mod_rewrite [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>install:
<ol>
<li>mysql: <a href="http://www.mysql.com/downloads/mysql/" target="_blank">http://www.mysql.com/downloads/mysql/</a></li>
<li>macports: <a title="mac ports" href="http://www.macports.org/install.php" target="_blank">http://www.macports.org/install.php</a></li>
</ol>
</li>
<li>run the following:
<ol>
<li>$&gt; sudo port selfupdate</li>
<li>$&gt; sudo port install apache2 tidy curl curl-ca-bundle php5-apc php5-curl <del>php5-eaccelerator</del> php5-gd php5-iconv php5-imagick php5-mbstring php5-mcrypt php5-mysql php5-soap php5-tidy php5-unit php5-uuid php5-xdebug php5-xmlrpc php5-xsl php5-zip wgetpro</li>
</ol>
<ul>
<li>Go for a coffee/beer now&#8230; this will take a little time.</li>
</ul>
</li>
<li>edit the following files:
<ol>
<li>edit /opt/local/apache/conf/http.conf
<ol>
<li>enable mod_rewrite</li>
<li>enable http-vhosts.conf</li>
<li>enable php5</li>
</ol>
</li>
<li>edit /opt/local/apache/conf/extra/httpd-vhosts.conf
<ol>
<li>ensure that target folder is group with &#8220;staff&#8221;, and readable.</li>
<li>note the following vhost entry, and the &lt;directory&gt;</li>
</ol>
<ul>
<li>&lt;VirtualHost *:80&gt;</li>
<li>ServerAdmin webmaster@dummy-host2.example.com</li>
<li>DocumentRoot &#8220;/Users/llleung/Projects/sample&#8221;</li>
<li>ServerName sample.localhost.com</li>
<li>ErrorLog &#8220;logs/sample.localhost.com-error_log&#8221;</li>
<li>CustomLog &#8220;logs/sample.localhost.com-access_log&#8221; common</li>
<li>&lt;Directory /Users/llleung/Projects/sample&gt;</li>
<li>Options FollowSymLinks</li>
<li>AllowOverride All</li>
<li>&lt;/Directory&gt;</li>
<li>&lt;/VirtualHost&gt;
<ul>
<li>Assumptions:</li>
<li>llleung is the user home folder</li>
<li>Projects, is where you house all the websites you want to deal with.</li>
</ul>
</li>
</ul>
</li>
<li>edit /etc/hosts
<ol>
<li>add custom urls referenced inside vhosts</li>
</ol>
<ul>
<li>127.0.0.1 sample.localhost.com</li>
</ul>
</li>
<li>edit your ~/.profile file, to run your instances of mysql, and apachectl</li>
</ol>
</li>
<ul>
<ul>
<li>alias mysql=&#8221;/usr/local/mysql/bin/mysql&#8221;</li>
<li>alias apachectl=&#8221;sudo /opt/local/apache2/bin/apachectl&#8221;</li>
</ul>
</ul>
</ol>
<div>edit:</div>
<div>Had to remove eacellerator, as it was conflicting with the latest APC.</div>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2011/06/17/mac-mamp-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento DB transaction commit rollback sniplet</title>
		<link>http://botchedcode.com/2011/01/18/magento-db-transaction-commit-rollback-sniplet/</link>
		<comments>http://botchedcode.com/2011/01/18/magento-db-transaction-commit-rollback-sniplet/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 22:27:06 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=186</guid>
		<description><![CDATA[Took me a while to find out how to do this&#8230; as there was no good examples on the web. So, here it is&#8230; so I can find it again. keywords: db database transaction rollback commit magento zend. try { $write = Mage::getSingleton(&#039;core/resource&#039;)-&#62;getConnection(&#039;core_write&#039;); $write-&#62;beginTransaction(); // do stuff here $write-&#62;commit(); } catch (Exception $e) { mage::log(__METHOD__ [...]]]></description>
			<content:encoded><![CDATA[<p>Took me a while to find out how to do this&#8230; as there was no good examples on the web.<br />
So, here it is&#8230; so I can find it again.</p>
<p>keywords:<br />
db database transaction rollback commit magento zend.</p>
<pre class="brush: php">try {
    $write = Mage::getSingleton(&#039;core/resource&#039;)-&gt;getConnection(&#039;core_write&#039;);
    $write-&gt;beginTransaction();

// do stuff here

    $write-&gt;commit();
} catch (Exception $e) {
    mage::log(__METHOD__ . &#039;:&#039; . __LINE__ . &#039;: Rollback happened.&#039;);
    $write-&gt;rollback();
}
</pre>
<p>Please drop a line if you found this useful.  Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2011/01/18/magento-db-transaction-commit-rollback-sniplet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>linux find the last modified file in directory</title>
		<link>http://botchedcode.com/2010/10/22/linux-find-the-last-modified-file-in-directory/</link>
		<comments>http://botchedcode.com/2010/10/22/linux-find-the-last-modified-file-in-directory/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 13:31:56 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=176</guid>
		<description><![CDATA[ls -tr &#124; tail -n 1]]></description>
			<content:encoded><![CDATA[<p>ls -tr | tail -n 1</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2010/10/22/linux-find-the-last-modified-file-in-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony 1.4 quick commands</title>
		<link>http://botchedcode.com/2010/10/08/symfony-1-4-quick-commands/</link>
		<comments>http://botchedcode.com/2010/10/08/symfony-1-4-quick-commands/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 13:35:53 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=161</guid>
		<description><![CDATA[I always forget these commands&#8230; so I&#8217;m posting it here, so I can find them again easily. Getting a value out of a loaded yaml config file. [project root]/app/frontend/config/app.yml all: .general: api_key: ASDFASDFASDFASDF sfConfig::get(&#8216;app_api_key&#8217;); will return &#8220;ASDFASDFASDFASDF&#8221;;]]></description>
			<content:encoded><![CDATA[<p>I always forget these commands&#8230; so I&#8217;m posting it here, so I can find them again easily.</p>
<p>Getting a value out of a loaded yaml config file.</p>
<p>[project root]/app/frontend/config/app.yml<br />
<code language="php"><br />
all:<br />
  .general:<br />
    api_key:        ASDFASDFASDFASDF<br />
</code></p>
<p>sfConfig::get(&#8216;app_api_key&#8217;);<br />
will return &#8220;ASDFASDFASDFASDF&#8221;;</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2010/10/08/symfony-1-4-quick-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build PHP 5.3.3, on centos 5.5</title>
		<link>http://botchedcode.com/2010/10/01/build-php-5-3-3-on-centos-5-5/</link>
		<comments>http://botchedcode.com/2010/10/01/build-php-5-3-3-on-centos-5-5/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 18:52:11 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=170</guid>
		<description><![CDATA[I&#8217;m assuming you have a fresh install of centos 5.5. $> yum groupinstall "Development Tools" $> wget http://us.php.net/get/php-5.3.3.tar.bz2/from/www.php.net/mirror $> tar xvf php-5.3.3.tar.bz2 $> yum install mysql-server httpd-devel-* libxml2-devel-* openssl-devel* xmlsec1-openssl-devel-* libpng* libjpeg* curl-devel libmcrypt* mysql-devel* mysql.* $> cd php-5.3.3 $> ./configure --with-mysql=shared --with-openssl --enable-pdo --with-pdo-mysql=shared --with-mhash=shared --enable-soap=shared --with-config-file-path=/etc/ --with-apxs2 --with-mysqli --enable-zip --enable-shared --with-curl --enable-mbstring=all --enable-maintainer-zts [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m assuming you have a fresh install of centos 5.5.</p>
<p><code><br />
$> yum groupinstall "Development Tools"</p>
<p>$> wget http://us.php.net/get/php-5.3.3.tar.bz2/from/www.php.net/mirror</p>
<p>$> tar xvf php-5.3.3.tar.bz2<br />
$> yum install mysql-server httpd-devel-* libxml2-devel-* openssl-devel* xmlsec1-openssl-devel-* libpng* libjpeg* curl-devel libmcrypt*  mysql-devel* mysql.*</p>
<p>$> cd php-5.3.3<br />
$> ./configure --with-mysql=shared --with-openssl --enable-pdo --with-pdo-mysql=shared  --with-mhash=shared --enable-soap=shared --with-config-file-path=/etc/ --with-apxs2 --with-mysqli --enable-zip --enable-shared --with-curl --enable-mbstring=all --enable-maintainer-zts --with-jpeg-dir=/usr/lib/ --with-libdir=lib64 --enable-soap --with-pdo-mysql --with-gd --with-mcrypt</p>
<p>$> make; make install;</p>
<p>$> service httpd restart</p>
<p></code></p>
<p>and there you go&#8230; php 5.3.3 on the box&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2010/10/01/build-php-5-3-3-on-centos-5-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Check list</title>
		<link>http://botchedcode.com/2010/04/29/check-list/</link>
		<comments>http://botchedcode.com/2010/04/29/check-list/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 14:54:03 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[General Programming]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=166</guid>
		<description><![CDATA[[are/did] you: 1.) backed up the file 2.) backed up the RIGHT file 3.) editing the right file 4.) editing the right file on the right server/environment 5.) are you viewing cached data, or live? 6.) does the input/output validate? 7.) did you remove all exit/die statements? If someone else looked at it, how many [...]]]></description>
			<content:encoded><![CDATA[<p>[are/did] you:<br />
1.) backed up the file<br />
2.) backed up the RIGHT file<br />
3.) editing the right file<br />
4.) editing the right file on the right server/environment<br />
5.) are you viewing cached data, or live?<br />
6.) does the input/output validate?<br />
7.) did you remove all exit/die statements?</p>
<p>If someone else looked at it, how many WTF per minute will there be?</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2010/04/29/check-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reusing a edit/create form</title>
		<link>http://botchedcode.com/2010/03/05/reusing-a-editcreate-form/</link>
		<comments>http://botchedcode.com/2010/03/05/reusing-a-editcreate-form/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 20:19:28 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[General Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony 1.3 & 1.4]]></category>
		<category><![CDATA[design pattern]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=159</guid>
		<description><![CDATA[As a web developer, you have to deal with web forms. Why would you make a new form, and an edit form, which is basically the same. How to handle this would be to use this design pattern: 1.) load the get item to load, if it exists. Lets call it $dataObject 2.) if $dataObject [...]]]></description>
			<content:encoded><![CDATA[<p>As a web developer, you have to deal with web forms. Why would you make a new form, and an edit form, which is basically the same.</p>
<p>How to handle this would be to use this design pattern:</p>
<p>1.) load the get item to load, if it exists. Lets call it $dataObject<br />
2.) if $dataObject is empty/does not exist, start a new dataObject. Lets call it $dataObject<br />
3.) dataObject is now instantiated.<br />
4.) Do what needs to be done &#8212; for example &#8220;title&#8221; of the page, being &#8220;editing XXX&#8221;, or &#8220;new dataObject&#8221;. Whatever frontend reflections need to happen, based on if it&#8217;s new object or editing an old object.<br />
5.) populate the form, accordingly. If the object is blank, it&#8217;ll just be populated with the default values.</p>
<p>6.) onSubmit()&#8230; check to see if an ID value was submitted, and the appropriate security checks, and deal accordingly. If there was no ID value, start a new dataObject, to be populated with the data submitted.</p>
<p>7.) $dataObject-&gt;save();</p>
<p>The above described is how symfony admin generator handles form reuse. While the admin generator is useful for most cases, sometimes you need to just do &#8220;more&#8221; customizations, than using the generator.</p>
<p>For example, you need to handle a collection of both NEW and Prior saved objects&#8230; to do batch edits, it&#8217;s easier to do it manually, instead of using the symfony-admin-generator.</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2010/03/05/reusing-a-editcreate-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony restful interface setup</title>
		<link>http://botchedcode.com/2010/03/05/symfony-restful-interface-setup/</link>
		<comments>http://botchedcode.com/2010/03/05/symfony-restful-interface-setup/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 20:08:09 +0000</pubDate>
		<dc:creator>Lloyd Leung</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony 1.3 & 1.4]]></category>
		<category><![CDATA[http_method]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[restful]]></category>
		<category><![CDATA[sf_method]]></category>
		<category><![CDATA[symfony 1.4]]></category>

		<guid isPermaLink="false">http://botchedcode.com/?p=150</guid>
		<description><![CDATA[How to make a restful interface easily with symfony: # &#8220;project_root&#8221;/app/&#8221;app_name&#8221;/config/routing.yml # default rules homepage: url: / param: { module: test, action: index } test_get: url: /v2/tester class: sfRequestRoute param: { module: test, action: get } requirements: sf_method: [get] test_put: url: /v2/tester class: sfRequestRoute param: { module: test, action: put } requirements: sf_method: [put] test_post: [...]]]></description>
			<content:encoded><![CDATA[<p>How to make a restful interface easily with symfony:</p>
<p># &#8220;project_root&#8221;/app/&#8221;app_name&#8221;/config/routing.yml</p>
<pre class="brush: php">
# default rules
homepage:
  url:   /
  param: { module: test, action: index }

test_get:
  url: /v2/tester
  class: sfRequestRoute
  param: { module: test, action: get }
  requirements:
    sf_method: [get]

test_put:
  url: /v2/tester
  class: sfRequestRoute
  param: { module: test, action: put }
  requirements:
    sf_method: [put]

test_post:
  url: /v2/tester
  class: sfRequestRoute
  param: { module: test, action: post }
  requirements:
    sf_method: [post]

test_head:
  url: /v2/tester
  class: sfRequestRoute
  param: { module: test, action: head }
  requirements:
    sf_method: [head]

# generic rules
# please, remove them by adding more specific rules
default_index:
  url:   /:module
  param: { action: index }

default:
  url:   /:module/:action/*
</pre>
<p>Remember, order DOES matter&#8230; if you have the default one at the top, the more specific matches to be overlooked.  So move more specific items to the top, and your routing will be fine.</p>
<p>Summary:<br />
post to http://localhost/sf_project/frontend_dev.php/test, will call frontend->test->post</p>
<p>delete to http://localhost/sf_project/frontend_dev.php/test, will call frontend->test->delete</p>
<p>put to http://localhost/sf_project/frontend_dev.php/test, will call frontend->test->put</p>
<p>head to http://localhost/sf_project/frontend_dev.php/test, will call frontend->test->head</p>
<p>you get the point&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://botchedcode.com/2010/03/05/symfony-restful-interface-setup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

