<?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; Downloads</title>
	<atom:link href="http://codesanity.net/downloads/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>Mozenda Data Scraping with CodeIgniter</title>
		<link>http://codesanity.net/2009/04/mozenda-data-scraping-codeigniter/</link>
		<comments>http://codesanity.net/2009/04/mozenda-data-scraping-codeigniter/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 07:23:23 +0000</pubDate>
		<dc:creator>Tom Schlick</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[mozenda]]></category>

		<guid isPermaLink="false">http://codesanity.net/?p=51</guid>
		<description><![CDATA[Mozenda is a very powerful data scraping service. If you have ever found yourself writing scripts or manually copying and pasting data from one website to another then mozenda is for you. They have a very nice, full featured REST API which will be the focus of this article.]]></description>
			<content:encoded><![CDATA[<h1>Overview</h1>
<p>I use Mozenda all the time. When scraping crappy static html pages it is very difficult to find consistency with markup. So thats where Mozenda comes in. I create an agent to scrape a collection of data in a specific order. It can select data between html tags, select data thats supposed to be in one featured place on the page, or it can skip over it if the data you are looking for is not there. It is truely a lifesaving service for anyone that updates mass amounts of data on a regular basis. You cant beat the price of $49/month either (just think how much you would have to pay someone to scrape all of that data for you). I have created a CodeIgniter Library (regular php class compatible) to interact with this api in a easy way. Now lets get to it!</p>
<h1>Download</h1>
<address><a href="http://github.com/trs21219/mozenda-api" target="_blank">http://github.com/trs21219/mozenda-api</a></address>
<h1>Documentation</h1>
<p>First off you need to set your api key and set what format you would like the results to be returned to you in. If you don&#8217;t have an api key then</p>
<p>1. Login to your account at http://Login.Mozenda.com</p>
<p>2. Click the &#8216;Account&#8217; link located in the top right corner of the web page.</p>
<p>3. Look for the &#8216;API Web Service Key&#8217; section under the &#8216;Account Details&#8217; tab, then click &#8216;Generate a New Key&#8217;. You will be required to provide this key in all requests to the API.</p>
<p>If you already have your API key then all you need to worry about is setting your output format. The two options are array (php array) and json.</p>
<h3 style="padding-left: 30px;">Configuring Your Library</h3>
<p style="padding-left: 30px;">[code language='php']<br />
$config_array = array('output_format' =&gt; 'json', 'api_key' =&gt; 'MY-SUPER-SECRET-KEY');<br />
$this-&gt;mozenda_api-&gt;config($config_array);<br />
[/code]</p>
<h3 style="padding-left: 30px;">Collection.GetList</h3>
<p style="padding-left: 30px;">Returns a list of collections for an account</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_get_list();</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Collection.GetViews</h3>
<p style="padding-left: 30px;">Gets a list of views for a particular collection</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_get_views($collection_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Collection.GetFields</h3>
<p style="padding-left: 30px;">Returns a list of fields that are in that collection with their details</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_get_fields($collection_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Collection.AddItem</h3>
<p style="padding-left: 30px;">Adds an item to a collection with the values specified.</p>
<p>[code language='php']</p>
<p>$items = array('Username' =&gt; 'John', 'Phone_Number' =&gt; '555-0123');</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_add_item($collection_id, $items);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Collection.UpdateItem</h3>
<p style="padding-left: 30px;">Updates an item in the collection.</p>
<p>[code language='php']</p>
<p>$items = array('Username' =&gt; 'Peter', 'Phone_Number' =&gt; '555-9876');</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_update_item($collection_id, $item_id, $items);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Collection.DeleteItem</h3>
<p style="padding-left: 30px;">Deletes an item from a collection.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_delete_item($collection_id, $item_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Collection.Clear</h3>
<p style="padding-left: 30px;">Clears the contents of a collection but leaves the collection intact.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_clear($collection_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Collection.Delete</h3>
<p style="padding-left: 30px;">Deletes the collection and all data within it.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;collection_delete($collection_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">View.GetItems</h3>
<p style="padding-left: 30px;">Returns items from a view.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;view_get_items($view_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Agent.GetList</h3>
<p style="padding-left: 30px;">Returns a list of your agents with their ID, Name, Settings, Description, and other important information.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;agent_get_list();</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Agent.GetJobs</h3>
<p style="padding-left: 30px;">Returns a list of your agent&#8217;s jobs with detailed information.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;agent_get_jobs($agent_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Agent.Run</h3>
<p style="padding-left: 30px;">Starts or resumes the Agent.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;agent_run($agent_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Agent.Delete</h3>
<p style="padding-left: 30px;">Deletes an agent and all associated schedules for that agent.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;agent_delete($agent_id)</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Job.Get</h3>
<p style="padding-left: 30px;">Gets the details of a job by the Job ID.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;job_get($job_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Job.Cancel</h3>
<p style="padding-left: 30px;">Cancels a Job in the system. Note, a job must be in a Paused or Error State to cancel a job.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;job_cancel($job_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Job.Pause</h3>
<p style="padding-left: 30px;">Issues the &#8216;Pause&#8217; command for a job currently running in the system.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;job_pause($job_id);</p>
<p>[/code]</p>
<h3 style="padding-left: 30px;">Job.Resume</h3>
<p style="padding-left: 30px;">Resumes a job that is in a Paused or Error state.</p>
<p>[code language='php']</p>
<p>$data = $this-&gt;mozenda_api-&gt;job_resume($job_id);</p>
<p>[/code]</p>
<p>I would really recommend taking a look at the official documentation on the mozenda website <a href=" https://server31.mozenda.com/api" target="_blank">show here.</a></p>
<h2>That&#8217;s It!</h2>
<p>That pretty much wraps it all up. If you have any questions or find a bug please use the comments and ill do my best to fix it.</p>
<p><em>NOTE: The descriptions of what the commands do was copied from the mozenda documentation to make it easier for the end user to understand. I do not take any credit in writing the descriptions.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://codesanity.net/2009/04/mozenda-data-scraping-codeigniter/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Envato Marketplace API with CodeIgniter</title>
		<link>http://codesanity.net/2009/04/evanto-marketplace-api-codeigniter/</link>
		<comments>http://codesanity.net/2009/04/evanto-marketplace-api-codeigniter/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 04:32:45 +0000</pubDate>
		<dc:creator>Tom Schlick</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[evanto]]></category>

		<guid isPermaLink="false">http://codesanity.net/?p=23</guid>
		<description><![CDATA[Envato recently released an API for thier various Marketplaces. I have taken the various methods of interacting with this data and compiled it into one, easy to use codeigniter library. It can also be used as a standalone php class if you wish. The class is currently PHP5 and requires you have json_encode, json_decode, and curl functions available.]]></description>
			<content:encoded><![CDATA[<h1>Overview</h1>
<p>So I created this library mostly out of boredom. It includes functions to interact with all of the options &amp; functionality that the current version (&#8220;EDGE&#8221;) provides. It was designed to be a CodeIgniter library but it can easily be ported over to php in just a few steps. It allows you to output the data in json, array, or raw (the format that the request was [json, xml]). So lets get to it!</p>
<h1>Download</h1>
<p>[download id="1"]</p>
<h1>Documentation</h1>
<h2 style="padding-left: 30px;">Configuration</h2>
<p style="padding-left: 30px;">There are several options you can set in the configuration that will make the library behave differently.</p>
<ul>
<li>username &#8211; obviously your username for the envato marketplaces</li>
<li>api_key &#8211; your api key for the marketplaces ( you should never set this in view of the public, its sort of like a password ).</li>
<li>api_format &#8211; the format you want the library to request, this can be altered with the next option (output format) &#8211; options incude : json, array, xml (default is json)</li>
<li>output_format &#8211; the format you want the library to return to you. options: array (default), json, raw (unaltered/formatted data straight from the feed) note: to get xml format back you need to set this to raw and set api_format to xml</li>
</ul>
<p style="padding-left: 30px;">This is how you can set the config information with a simple function and array.<br />
[code language='php']<br />
$this->envato_api->config(array('api_format' => 'json', 'output_format' => 'array', 'username' => 'joesmith', 'api_key' => 'MYSUPERSECRETKEY'));<br />
[/code]
</p>
<p style="padding-left: 30px;">Place the configuration code above the functions listed below.</p>
<h2 style="padding-left: 30px;">Public Functions</h2>
<p style="padding-left: 30px;">These are functions that do not require a username and api key to access. They are mostly things such as the latest files on the marketplaces, the most popular threads, etc.</p>
<p style="padding-left: 30px;">
<h3 style="padding-left: 30px;">Blog Posts</h3>
<p style="padding-left: 30px;">A list of blog posts for a particular site. Requires a site parameter.</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_blog_posts('sitename');<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">Active Threads</h3>
<p style="padding-left: 30px;">Threads with the most recent messages activity. Requires a site parameter.</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_threads_active('sitename');<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">Number of Files in Categories</h3>
<p style="padding-left: 30px;">Shows the number of files in the major categories of a particular site. Requires a site paramater.</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_files_number('sitename');<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">Category New Files</h3>
<p style="padding-left: 30px;">New files, recently uploaded to a particular site. Requires site and category paramaters.</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_files_new('sitename', 'categoryname');<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">Popular Files</h3>
<p style="padding-left: 30px;">Returns the popular files for a particular site. Requires a site paramater.</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_files_popular('sitename');<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">New User Files</h3>
<p style="padding-left: 30px;">Shows the newest 10 files a user has uploaded to a particualr site. Requires username and site paramaters.</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_files_user_new('username', 'sitename');<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">Random New Files</h3>
<p style="padding-left: 30px;">Shows a random list of newly uploaded files from a particular site (i.e. like the homepage). Requires a site paramater.</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_files_new_random('sitename');<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">API Releases</h3>
<p style="padding-left: 30px;">Returns Release and Set information for the API (used to generate the documentation).</p>
<p>[code language='php']<br />
$data = $this->envato_api->public_releases();<br />
$this->evanto_api->clear();<br />
[/code]</p>
<p style="padding-left: 30px;">
<h2 style="padding-left: 30px;">Private User Functions</h2>
<p style="padding-left: 30px;">These are functions that DO require a username and API key to access. They include things such as account information, billing statements, etc. <strong>Make sure to set your username &amp; api key inside the script or with the config function above.</strong></p>
<p style="padding-left: 30px;">
<h3 style="padding-left: 30px;">User Vitals</h3>
<p style="padding-left: 30px;">Return a users username and balance.</p>
<p>[code language='php']<br />
$data = $this->envato_api->user_vitals();<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">User Account</h3>
<p style="padding-left: 30px;">Returns the first name, surname, total earnings, total deposits, balance (deposits + earnings), country and current commission rate for sales.</p>
<p>[code language='php']<br />
$data = $this->envato_api->user_account();<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">User Earnings &amp; Monthly Sales</h3>
<p style="padding-left: 30px;">Returns the monthly sales data, as displayed on the user&#8217;s earnings page.</p>
<p>[code language='php']<br />
$data = $this->envato_api->user_earnings();<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">User Statement</h3>
<p style="padding-left: 30px;">Returns the last 100 events as seen on the user&#8217;s statement page.</p>
<p>[code language='php']<br />
$data = $this->envato_api->user_statement();<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">User Recent Sales</h3>
<p style="padding-left: 30px;">Shows the 50 recent sales of the user&#8217;s items.</p>
<p>[code language='php']<br />
$data = $this->envato_api->user_recent_sales();<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h3 style="padding-left: 30px;">User Multiple</h3>
<p style="padding-left: 30px;">This function will return multiple sets of data at once. if you dont supply anything in the parameters it will return all of the results by default. The options inside the array below are the only options you have. You can use as many or as little as you need.</p>
<p>[code language='php']<br />
$data = $this->envato_api->user_multiple(array('account', 'vitals', 'earnings-adn-sales-by-month', 'statement', 'recent-sales'));<br />
$this->evanto_api->clear();<br />
[/code]</p>
<h2>Done!</h2>
<p>We are all done! If you have any questions, suggestions, bugs or just wanna say thanks then reply in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://codesanity.net/2009/04/evanto-marketplace-api-codeigniter/feed/</wfw:commentRss>
		<slash:comments>1</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:29:23 -->