<?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>CodeSanity &#187; server</title>
	<atom:link href="http://codesanity.net/tag/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://codesanity.net</link>
	<description>PHP, Javascript &#38; Technology Ramblings</description>
	<lastBuildDate>Wed, 07 Jul 2010 00:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Avoiding Database Overload with Memcached</title>
		<link>http://codesanity.net/2010/03/avoiding-database-overload-with-memcached/</link>
		<comments>http://codesanity.net/2010/03/avoiding-database-overload-with-memcached/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 06:23:30 +0000</pubDate>
		<dc:creator>Tom Schlick</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[key pair]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://codesanity.net/?p=194</guid>
		<description><![CDATA[As you build out your application, scalability will start become an issue. You will find yourself making queries to the database every page load cost you precious cpu and load time. The trick is to cache frequently used data so that a database query is not necessary, reducing the overhead on your server.]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>Probably the biggest challenge for a newly popular site these days is scalability. The most common point of failure in applications seems to always be the database. These days our applications are totally reliant on some sort of relational database to store the information for our website&#8217;s content. Each and every page load brings many queries that read or insert information into this database all while rendering the web page in a timely manner. This isn&#8217;t so much a problem for your Mom &amp; Pop business, but when your website starts to get some real traffic pointed towards it,  your underlying architecture that you thought was impervious to anything will crumble before your eyes. The solution? Stop making so many queries to your database.</p>
<h2>Caching</h2>
<p>Caching is nothing new. Servers have been caching content for many years quite successfully. There are many different ways you can cache data in your application but right now we will just be talking about using <a href="http://memcached.org/" target="_blank">Memcached</a>. Memcached is a high-performance, distributed memory object caching system. So what does this mean? Basically it can store any kind of value that you would normally store in your database and retrieve it much much faster than your database can.</p>
<h2>Memcached Flow</h2>
<p>When you implement memcached you use it along side of your database. Neither takes the place of each other, memcached just takes some of the load off of your database server after your database server has previously done the grunt work. It works on a key pair system. Meaning it has no tables, rows, columns etc. You give memcached a name and pass it data and it stores that data just as you passed to it. You can pass it an object, array, binary, etc and it will output the same way when you go to retrieve it.</p>
<p>So how does this all work with the database? First, you add code that checks to see if the memcached object (blogpost-45 for our example) exists before it checks the database for the data. If it does you return that data and never touch the DB.  If the memcached object does not exist  you retrieve data from your database, take the array that is passed back and store it in  memcached with the key of &#8220;blogpost-45&#8243;. So the next time you try to get the data for blogpost-45 it will return from memcached and not your database. This is where the load savings occurs.</p>
<p>So what happens when I want to change the data? When you change the data in your database you should delete the key in memcached. You shouldn&#8217;t re-add the data after you delete it, let the select query do that to avoid complications.</p>
<h2>CodeIgniter + Memcached</h2>
<p>I have created a CodeIgniter Library that can help you get a jump start on your integration with memcached, its available on my github page and will be updated when I get time.</p>
<p><a href="http://github.com/trs21219/memcached-library" target="_blank">http://github.com/trs21219/memcached-library</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codesanity.net/2010/03/avoiding-database-overload-with-memcached/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Making the Switch: SVN to Git</title>
		<link>http://codesanity.net/2010/03/making-switch-svn-git/</link>
		<comments>http://codesanity.net/2010/03/making-switch-svn-git/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 02:25:49 +0000</pubDate>
		<dc:creator>Tom Schlick</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[environments]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[svn-git]]></category>

		<guid isPermaLink="false">http://codesanity.net/?p=175</guid>
		<description><![CDATA[Choosing the right revision control system can make or break your development flow. I found this out the hard way after SVN brought our source migration process to a crawl. We will walk through the problems that most have with SVN and the migration process from SVN to Git.]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>Recently at work, we realized that our SVN setup just wasn&#8217;t working anymore for us. Merges were difficult and time consuming, we had weekly release meetings to go file by file through a list of changes to make sure what we were pushing to production was actually quality. This process was severely inefficient and everyone hated it.  So we did what any company that absolutely hates svn does, we moved to <a href="http://git-scm.com/" target="_blank">Git</a> &amp; <a href="http://github.com/" target="_blank">Github</a>. We chose Github for the stability, function, and social coding features. We use freelancers fairly often to contribute to small modules we work on and having a rich GUI is absolutely essential.</p>
<h2>Git-SVN</h2>
<p>Now we had a years worth of commits that we wanted to migrate over to the new git system. I tried using the import tool that Github provides for repositories but due to our unconventional setup it couldn&#8217;t be done. After some searching  I found a command line tool that actually resides inside of the core git install called <a href="http://www.kernel.org/pub/software/scm/git-core/docs/git-svn.html" target="_blank">git-svn</a>. With a few simple commands and about 45 minutes in the case of our repository it had converted every commit to the sha-1 equivalent that git uses.  Git-svn was actually designed so that you have the ability to work with both systems at the same time. So you could use git while your co-worker uses svn and both commit to the same repository. Below is the actual command we used to convert our SVN repo to a git repository. You can find the original tutorial on doing so <a href="http://pauldowman.com/2008/07/26/how-to-convert-from-subversion-to-git/" target="_blank">here</a>.</p>
<p><code>git svn clone  --no-metadata -A authors.txt -t tags -b branches -T trunk </code></p>
<p>This took around 35 &#8211; 45 minutes with our repository which had almost 6,000 commits in it so give yourself some time.</p>
<h2>Git GUI &amp; Bash</h2>
<p>Unfortunately, not everyone in the office is running on a mac. Now this wouldn&#8217;t be so bad if windows had native support for ssh but it doesn&#8217;t so we had to find a third party solution to using git. Good thing for us is that the git gui &amp; bash application is pretty feature rich and has a low learning curve. After you <a href="http://git-scm.com/download" target="_blank">install git via msysGit</a>, head over to the <a href="http://learn.github.com" target="_blank">github learing </a>page or the <a href="http://progit.org/book/" target="_blank">progit book</a> site to get your self acclimated with how git works.</p>
<p>Screencast on using git gui via Vimeo<br />
[vimeo 2111264 400 285]</p>
<h2>Line Endings</h2>
<p>Let me just say this. Line Endings are a nasty bitch.  If you use multiple operating systems with your repository (especially windows) line endings can be a very big problem if you don&#8217;t set them up right from the start. What happens is that when Windows modifies a file and commits it it uses  a different style of line ending than mac or linux. When your mac or  linux machine pulls that down from the central repository, it changes  the line ending thus changing the sha1 which makes git think you edited  the entire file.  This bit us in the ass a week after converting our repo, which just so happened to be over the holidays so troubleshooting the problems it presented turned out to be especially hard. I highly recommend setting your line endings to the spec that <a href="http://help.github.com/dealing-with-lineendings/" target="_blank">this tutorial outlines</a>. Since we did this we have not had line ending problems.</p>
<h2>Workflow</h2>
<p>We experimented with several workflows to see which would work best with Git. We landed on the &#8220;branch per task&#8221; solution. Basically whenever someone is going to complete a task ( a bug fix, feature enhancement, etc) they create a branch with the ticket name and number. They do their work in that branch, committing and pushing often. When their code is ready to be merged back into the master branch its a fairly easy task. We just run git merge origin/branchname and their changes are ported into the current codebase. We have found this best because it keeps developers from stepping on each others toes and its easy to delay a branch from making it into the master codebase if needed.</p>
<h2>Server Deployment</h2>
<p>We use several staging &amp; production environments for alpha/beta testing  as well as our live environment. Pushing the code changes to these servers is actually quite easy. We just SSH right into the server, cd to the directory and run &#8221; git pull &#8220;. Its as simple as that.</p>
<h4>Overall we all like the new system. It took some getting used to and like everyone else we had our own WTF did I just do moments but in the end it works.</h4>
]]></content:encoded>
			<wfw:commentRss>http://codesanity.net/2010/03/making-switch-svn-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conditional .Htpasswd for Multi-Environment Setups</title>
		<link>http://codesanity.net/2009/11/conditional-htpasswd-multienvironment-setups/</link>
		<comments>http://codesanity.net/2009/11/conditional-htpasswd-multienvironment-setups/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 08:58:47 +0000</pubDate>
		<dc:creator>Tom Schlick</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[conditional]]></category>
		<category><![CDATA[environments]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[htpasswd]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://codesanity.net/?p=125</guid>
		<description><![CDATA[When using a Multi-Environment setup for your development process it is essential to have adequate protection from outside prying eyes, but also allow people to access your public/testing sites. This .htaccess code allows you to do that.]]></description>
			<content:encoded><![CDATA[<p>So a while back i set Chris over at <a href="http://css-tricks.com" target="_blank">CSS-Tricks</a> some code for his ongoing <a href="http://css-tricks.com/snippets/" target="_blank">snippet library</a> project. This is a quick explanation of that code.</p>
<p>You see when you are working with a multi-environment setup that is synced via a version control system such as Git or Subversion, you need a way to keep your development environments locked down while allowing access to your public environment.</p>
<p>Below is some text that you will input into a .htaccess file placed in your webroot</p>
<p>[sourcecode language='php']<br />
#allows a single uri through the .htaccess password protection<br />
SetEnvIf Request_URI &#8220;/testing_uri$&#8221; test_uri</p>
<p>#allows everything if its on a certain host<br />
SetEnvIf HOST &#8220;^testing.yoursite.com&#8221; testing_url<br />
SetEnvIf HOST &#8220;^yoursite.com&#8221; live_url<br />
Order Deny,Allow</p>
<p>AuthName &#8220;Restricted Area&#8221;<br />
AuthType Basic<br />
AuthUserFile /path/to/your/.htpasswd<br />
AuthGroupFile /<br />
Require valid-user</p>
<p>#Allow valid-user<br />
Deny from all<br />
Allow from env=test_uri<br />
Allow from env=testing_url<br />
Allow from env=live_url<br />
Satisfy any<br />
[/sourcecode]</p>
<p>so in the above code the &#8220;testing_uri&#8221; part could be if i only wanted to allow this url through my htaccess protections (useful for paypal pings) ex &#8220;http://mysite.com/paypal/ipn&#8221;</p>
<p>the host part is to allow anyone through if they are requesting the code from a specific domain such as &#8220;testing.yoursite.com&#8221;. if it is &#8220;development.yoursite.com&#8221; it will not allow the user through.</p>
<p><a href="http://css-tricks.com/snippets/htaccess/allow-single-url/" target="_blank">here is the code on css-tricks</a> and <a href="http://gist.github.com/229178" target="_blank">here is the code as a github gist</a></p>
<p>Thanks for reading and as always comments &amp; questions are heavily encouraged!</p>
]]></content:encoded>
			<wfw:commentRss>http://codesanity.net/2009/11/conditional-htpasswd-multienvironment-setups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Content Delivery Network via Amazon Web Services: S3: assets.codesanity.net.s3.amazonaws.com

Served from: codesanity.net @ 2010-09-06 07:44:31 -->