<?xml version="1.0" encoding="iso-8859-1"?>
<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>CrankBerry Blog</title>
	<atom:link href="http://www.crankberryblog.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.crankberryblog.com</link>
	<description>Sharing ideas on web design, development and the internet economy</description>
	<lastBuildDate>Thu, 22 Apr 2010 21:46:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Random row from your MySQL table with PHP, alternative to ORDER BY rand()</title>
		<link>http://www.crankberryblog.com/2010/random-row-from-your-mysql-table-with-php-alternative-to-order-by-rand</link>
		<comments>http://www.crankberryblog.com/2010/random-row-from-your-mysql-table-with-php-alternative-to-order-by-rand#comments</comments>
		<pubDate>Thu, 22 Apr 2010 21:28:04 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Script]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=379</guid>
		<description><![CDATA[Working with MySQL and PHP is awesome. Its one of the best way to manage your data, but once in a while you may want to do some randomizing. One problem I came across recently was how to select a random row from your MySQL table with PHP. Using the ORDER BY rand() method in your query maybe a bit slow so here's what we've got.]]></description>
			<content:encoded><![CDATA[<p>Working with MySQL and PHP is awesome. Its one of the best way to manage your data, but once in a while you may want to do some randomizing. One problem I came across recently was how to select a random row from your MySQL table with PHP. Using the ORDER BY rand() method in your query maybe a bit slow so here&#039;s what we&#039;ve got.</p>
<h3>The Premade Method</h3>
<p>As I mentioned in the beginning. MySQL actually has a premade method that allows you to select a random row by querying for it.</p>
<div class="dean_ch" style="white-space: wrap;"><a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&quot;SELECT * FROM table ORDER BY rand() LIMIT 0,1&quot;</span><span class="br0">&#41;</span>;</div>
<p>This method is great but if you are randomizing from a large table this method is not very efficient and with a high volume of queries it really puts a strain on your DB.</p>
<h3>The New Method &#8211; Randomizing 1 Entry</h3>
<p>Now here&#039;s the new solution by selecting a random row with the offset. This method will query exactly to the random entry; thus, making this process much faster.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="re0">$query</span> = <span class="st0">&quot;SELECT * FROM table&quot;</span><br />
<span class="re0">$num_rows</span> = <a href="http://www.php.net/mysql_num_rows"><span class="kw3">mysql_num_rows</span></a><span class="br0">&#40;</span> <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span> <span class="re0">$query</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>;</p>
<p><span class="co1">//Random Number</span><br />
<span class="re0">$rand_row</span> = <a href="http://www.php.net/rand"><span class="kw3">rand</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="re0">$num_rows</span> &#8211; <span class="nu0">1</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">//Selecting the Random Row</span><br />
<span class="re0">$rand_row</span> = <span class="re0">$query</span> .= <span class="st0">&quot; LIMIT $rand_row, 1&quot;</span>;</div>
<p>Now you can modify the $query line to include your filters and sorting stuff, whatever you need.</p>
<h3>The New Method &#8211; Randomizing More than 1 Entry</h3>
<p>The above method right now can only select a single row. What if you want to randomized more than one item. Here&#039;s a method to select multiple items without overlap.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="co1">//Set the Amount of Random Rows you want</span><br />
<span class="re0">$rand_amount</span> = <span class="nu0">5</span>;</p>
<p><span class="re0">$query</span> = <span class="st0">&quot;SELECT * FROM table&quot;</span><br />
<span class="re0">$num_rows</span> = <a href="http://www.php.net/mysql_num_rows"><span class="kw3">mysql_num_rows</span></a><span class="br0">&#40;</span> <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span> <span class="re0">$query</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>;</p>
<p><span class="co1">//Make sure you have more than the amount of random count you want</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$num_rows</span> &lt;= <span class="re0">$rand_amount</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//An Array of Numbers Choosen</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$rand_array</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Do IT!!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">1</span>; <span class="re0">$i</span> &gt;= <span class="re0">$rand_amount</span>; <span class="re0">$i</span>++ <span class="br0">&#41;</span> <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$rand_added</span> = <span class="kw2">FALSE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$rand_num</span> = <a href="http://www.php.net/rand"><span class="kw3">rand</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="re0">$num_rows</span> &#8211; <span class="nu0">1</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Should We Add to Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!<a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><span class="re0">$rand_num</span>, <span class="re0">$rand_array</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$rand_array</span><span class="br0">&#91;</span><span class="br0">&#93;</span> = <span class="re0">$rand_num</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$rand_added</span> = <span class="kw2">TRUE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">while</span> <span class="br0">&#40;</span>!<span class="re0">$rand_added</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//You now have a set of random row numbers to choose from</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Display The Result of What you have</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re0">$rand_array</span> <span class="kw1">as</span> <span class="re0">$rand_num</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_query</span> = <span class="re0">$query</span> . <span class="st0">&quot; LIMIT $rand_num, 1&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Displaying What you have</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$current_row</span> = <a href="http://www.php.net/mysql_fetch_array"><span class="kw3">mysql_fetch_array</span></a><span class="br0">&#40;</span> <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span> <span class="re0">$new_query</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>To be honest you can use the multiple randomizer and just set the random amount to 1 but the other method saves you like 20 lines of code. Imagine how much faster that could be!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2010/random-row-from-your-mysql-table-with-php-alternative-to-order-by-rand/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automated MySQL database backup with PHP and cronjob</title>
		<link>http://www.crankberryblog.com/2010/automated-mysql-database-backup-with-php-and-cronjob</link>
		<comments>http://www.crankberryblog.com/2010/automated-mysql-database-backup-with-php-and-cronjob#comments</comments>
		<pubDate>Fri, 16 Apr 2010 17:04:36 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Owners]]></category>
		<category><![CDATA[Cronjob]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP Script]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=373</guid>
		<description><![CDATA[At some point of working on your website you'll want to back up you MySQL database. This is they key for all of you building dynamic sites. If one day your server goes down or something you may have the files backed up but without the database you'll have to start from scratch again. If you operate a very slow-paced site then manual back up is fine but if you want to backup your database daily then it becomes tedious. I, myself is lazy so I came up with a PHP and Cronjob solution to automatically backup MySQL database.]]></description>
			<content:encoded><![CDATA[<p>At some point of working on your website you&#039;ll want to back up you MySQL database. This is they key for all of you building dynamic sites. If one day your server goes down or something you may have the files backed up but without the database you&#039;ll have to start from scratch again. If you operate a very slow-paced site then manual back up is fine but if you want to backup your database daily then it becomes tedious. I, myself is lazy so I came up with a PHP and Cronjob solution to automatically backup MySQL database.</p>
<h3>Automating It</h3>
<p><strong>What you need?</strong> The first thing you need to know how to do it set cronjobs. If you don&#039;t know how to do that you can <a href="http://www.crankberryblog.com/2009/setting-php-cron-job-with-crontab" title="Learn to set cronjobs">learn how to set cronjobs here</a>. The cronjob is what will automate your server to run the script and how often to run it.</p>
<h3>The Files</h3>
<p>All you&#039;ll need is two files to make this work. The first file, <strong>mysqldump.php</strong> can be grabbed from <a href="http://www.creativefactory.it/lab/">CreativeFactory.it</a>. The next thing you need is my backup.php file. Just create a file called <strong>backup.php</strong> and dump the following script inside.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span></p>
<p><span class="co1">//The File Name You Want To Use</span><br />
<span class="re0">$fileName</span> = <span class="st0">&#039;Filename&#039;</span>;</p>
<p><span class="co1">//Global</span><br />
<span class="re0">$sqlhost</span> = <span class="st0">&#039;localhost&#039;</span>;<br />
<span class="re0">$sqluser</span> = <span class="st0">&#039;db_user&#039;</span>;<br />
<span class="re0">$sqlpass</span> = <span class="st0">&#039;db_password&#039;</span>;<br />
<span class="re0">$sqldb</span> = <span class="st0">&#039;db_name&#039;</span>;</p>
<p><span class="co1">//**********************************</span><br />
<span class="co1">//You Don&#039;t Need to Edit This</span><br />
<span class="co1">//**********************************</span></p>
<p><span class="co1">//Today&#039;s Timestamp</span><br />
<span class="re0">$today_ts</span> = <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="st0">&quot;now&quot;</span><span class="br0">&#41;</span>;</p>
<p>
<span class="re0">$backupDate</span> = <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&#039;y.m.d.h.i&#039;</span>, <span class="re0">$today_ts</span><span class="br0">&#41;</span>;<br />
<span class="re0">$backupFile</span> = &nbsp;<span class="re0">$backupDate</span>.<span class="st0">&#039;- &#039;</span>.<span class="re0">$fileName</span>.<span class="st0">&#039;.txt&#039;</span>;</p>
<p><span class="co1">//Connect to mysql server</span><br />
<span class="re0">$connessione</span> = @<a href="http://www.php.net/mysql_connect"><span class="kw3">mysql_connect</span></a><span class="br0">&#40;</span><span class="re0">$sqlhost</span>,<span class="re0">$sqluser</span>,<span class="re0">$sqlpass</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">//Include class</span><br />
<span class="kw1">require_once</span><span class="br0">&#40;</span><span class="st0">&#039;mysqldump.php&#039;</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">//Create new instance of MySQLDump</span><br />
<span class="re0">$dumper</span> = <span class="kw2">new</span> MySQLDump<span class="br0">&#40;</span><span class="re0">$sqldb</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">//If you want to write the MySQL dump to file</span><br />
<span class="re0">$dumper</span>-&gt;<span class="me1">writeDump</span><span class="br0">&#40;</span><span class="re0">$backupFile</span><span class="br0">&#41;</span>;</p>
<p><span class="kw2">?&gt;</span></div>
<h3>The Setup</h3>
<p>Configure the first file variables of the script and then just leave the rest. Put the backup.php and mysqldump.php in the same folder where you want the back up files to be dumped. Set the cronjob to run backup.php you don&#039;t need to worry about mysqldump.php. That&#039;s it, it&#039;ll automatically backup.</p>
<h3>Possible Problems</h3>
<p>The problems that you may experience is the MySQL privileges. If your account doesn&#039;t have enough privilege then you may not be able to properly query the database. Another problem maybe the CHMOD of the folder you&#039;re backing up to. You need to have write access into that folder.</p>
<h3>Recovering from Backup</h3>
<p>To recover you database just log into your phpMyAdmin, open the database you want to recover. Select the import tab and just browse for the file. If I recall the file itself should overwrite tables that are already in place if not then you may have to drop all the tables first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2010/automated-mysql-database-backup-with-php-and-cronjob/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My new portfolio JerryLow.com</title>
		<link>http://www.crankberryblog.com/2010/my-new-portfolio-jerrylow-com</link>
		<comments>http://www.crankberryblog.com/2010/my-new-portfolio-jerrylow-com#comments</comments>
		<pubDate>Thu, 18 Mar 2010 18:49:43 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=360</guid>
		<description><![CDATA[I've been a bit absent from Crankberry because 1. I've taken on a bit of design work and 2. I've been redoing my portfolio - <a href="http://www.jerrylow.com" target="_blank">JerryLow.com</a>. This was not one of those reskin design its a full on rebuild from scratch. I thought it was going to be small but ended up taking a few weeks. A lot of focus on making a smooth and fluid experience. Well if you need a designer or programming check out the hire me button.

<img src="http://www.crankberryblog.com/images/jerry-low-portfolio-1.jpg" />]]></description>
			<content:encoded><![CDATA[<p>I&#039;ve been a bit absent from Crankberry because 1. I&#039;ve taken on a bit of design work and 2. I&#039;ve been redoing my portfolio &#8211; <a href="http://www.jerrylow.com" target="_blank">JerryLow.com</a>. This was not one of those reskin design its a full on rebuild from scratch. I thought it was going to be small but ended up taking a few weeks. A lot of focus on making a smooth and fluid experience. Well if you need a designer or programming check out the hire me button.</p>
<p><a href="http://www.jerrylow.com" target="_blank"><img src="http://www.crankberryblog.com/images/jerry-low-portfolio-1.jpg" /></a></p>
<p><a href="http://www.jerrylow.com" target="_blank"><img src="http://www.crankberryblog.com/images/jerry-low-portfolio-2.jpg" /></a></p>
<p>If you didn&#039;t see the link above here it is again:<br />
<a href="http://www.jerrylow.com" target="_blank">JerryLow.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2010/my-new-portfolio-jerrylow-com/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Relax, some web designer/developer comics</title>
		<link>http://www.crankberryblog.com/2010/relax-some-web-designerdeveloper-comics</link>
		<comments>http://www.crankberryblog.com/2010/relax-some-web-designerdeveloper-comics#comments</comments>
		<pubDate>Tue, 02 Mar 2010 20:18:01 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[Comic]]></category>
		<category><![CDATA[Comics]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=352</guid>
		<description><![CDATA[It doesn't always have to be "all work and no play makes webmasters a dull person". Here are some comics that can maybe lighten up the day.

<a href="http://theoatmeal.com/comics/design_hell" target="_blank"><img src="http://www.crankberryblog.com/images/comic/theoatmeal.jpg" alt="Web Designer Comic" /></a>]]></description>
			<content:encoded><![CDATA[<p>It doesn&#039;t always have to be &#034;all work and no play makes webmasters a dull person&#034;. Here are some comics that can maybe lighten up the day.</p>
<p><a href="http://theoatmeal.com/comics/design_hell" target="_blank"><img src="http://www.crankberryblog.com/images/comic/theoatmeal.jpg" alt="Web Designer Comic" /></a><br />
<a href="http://theoatmeal.com/comics/design_hell" target="_blank">Click for this full cartoon&#8230;</a></p>
<p><a href="http://www.northstudio.com/images/web_development_comic.jpg" target="_blank"><img src="http://www.crankberryblog.com/images/comic/north-studio.jpg" alt="Web Designer Comic" /></a></p>
<p><a href="http://colbowdesign.com/blog2/?m=200809" target="_blank"><img src="http://www.crankberryblog.com/images/comic/collowdesign.jpg" alt="Web Designer Comic" /></a></p>
<p><a href="http://www.niteodesign.com/weblog/127/127" target="_blank"><img src="http://www.crankberryblog.com/images/comic/nitrodesign.jpg" alt="Web Designer Comic" /></a></p>
<p><a href="http://blog.jivaldi.com/2009/worry-about-the-small-things/" target="_blank"><img src="http://www.crankberryblog.com/images/comic/jivaldi.jpg" alt="Web Designer Comic" /></a></p>
<p><a href="http://takip.tumblr.com/page/2" target="_blank"><img src="http://www.crankberryblog.com/images/comic/takip.jpg" alt="Web Designer Comic" /></a></p>
<p><a href="http://questionmark.blogsome.com/category/web/" target="_blank"><img src="http://www.crankberryblog.com/images/comic/question-mark.jpg" alt="Web Developer Comic" /></a></p>
<p><a href="http://blog.iampaddy.com/tag/web-design-comic/" target="_blank"><img src="http://www.crankberryblog.com/images/comic/i-am-paddy.jpg" alt="Web Developer Comic" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2010/relax-some-web-designerdeveloper-comics/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awesome image cropper/thumbnail maker script &#8211; Modified Marquee Tool</title>
		<link>http://www.crankberryblog.com/2010/awesome-image-cropperthumbnail-maker-script-modified-marquee-tool</link>
		<comments>http://www.crankberryblog.com/2010/awesome-image-cropperthumbnail-maker-script-modified-marquee-tool#comments</comments>
		<pubDate>Tue, 23 Feb 2010 17:59:31 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Thumbnail]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=344</guid>
		<description><![CDATA[As I'm recoding my portfolio right now, I thought to myself - how great would it be to have a thumbnail maker tool. Some PHP or Javascript solution to crop images dynamically without the use of Photoshop. I would hate to fire up Photoshop every time I want to upload something. I'm sure you've all been there before. Anyways I landed upon a script that suited my need exactly. The <a href="http://marqueetool.net/">Rectangle Marquee Tool</a>. The tool looks great but was a bit confusing for me to get working and based on the comment for a few others too. Now I've also done some slight PHP modification to get the script working to my needs and generating the correct thumbnails. 

See what I'm mumbling on about right here:
<strong><a href="http://www.crankberryblog.com/demo/marqueetool/">Demonstration of Marquee Tool</a></strong>


<img src="http://www.crankberryblog.com/images/thumbnail-cropper-script.jpg" />]]></description>
			<content:encoded><![CDATA[<p>As I&#039;m recoding my portfolio right now, I thought to myself &#8211; how great would it be to have a thumbnail maker tool. Some PHP or Javascript solution to crop images dynamically without the use of Photoshop. I would hate to fire up Photoshop every time I want to upload something. I&#039;m sure you&#039;ve all been there before. Anyways I landed upon a script that suited my need exactly. The <a href="http://marqueetool.net/">Rectangle Marquee Tool</a>. The tool looks great but was a bit confusing for me to get working and based on the comment for a few others too. Now I&#039;ve also done some slight PHP modification to get the script working to my needs and generating the correct thumbnails. </p>
<p>See what I&#039;m mumbling on about right here:<br />
<strong><a href="http://www.crankberryblog.com/demo/marqueetool/">Demonstration of Marquee Tool</a></strong></p>
<p><img src="http://www.crankberryblog.com/images/thumbnail-cropper-script.jpg" /></p>
<p>Once again I&#039;d like to clarify that I did not make the Rectangular Marquee Tool, it was written by Sergey Koksharov using certain functions of the Prototype/Scriptaculous framework. I&#039;m merely just doing some tweaks to make it work better in my circumstance. So all credits goes to Sergey and the Scriptaculous team.</p>
<p>My modification will allow you to do certain things such as:</p>
<ul>
<li>Define a input image dynamically</li>
<li>Define the output image dynamically</li>
<li>Generate a final output image</li>
</ul>
<p>I believe the PHP included in the original script was a bit dated so it wasn&#039;t working on my machine and servers that&#039;s why I made my own version.</p>
<p>So to start off you need to download the required files from: <a href="http://marqueetool.net/download/">here</a>. Then you need to extract the files into a scripts folder or whichever you prefer just remember to rename the source path after. The real files you need are:</p>
<ul>
<li>marker.css</li>
<li>prototype_reduced.js</li>
<li>rectmarquee.js</li>
</ul>
<p>Once you&#039;ve got the files extract them to the proper folders and create fresh PHP file to work with. This is the file your script will run from. I&#039;ll break down my code into chunks for you to understand, but I&#039;ll go in order so if you copy each chunk and paste them in the same order it should work. That is if you&#039;re reading this instruction right ;)</p>
<h3>Before the HTML</h3>
<p>So this piece of code starts off your whole document even before the HTML code. There&#039;s only two codes you need to modify which is the $img_src (original file) and $img_dst (final thumbnail file).</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span></p>
<p><span class="co1">//Source Image to Crop From</span><br />
<span class="re0">$img_src</span> = <span class="st0">&#039;img/&#039;</span>;</p>
<p><span class="co1">//Thumbnail Location</span><br />
<span class="re0">$img_dst</span> = <span class="st0">&#039;img/&#039;</span>;</p>
<p><span class="co1">//If you want to feed this dynamically you can use</span><br />
<span class="co1">//$_GET tags or draw them in through a database</span></p>
<p><span class="co1">//Some coding here not just for looks.</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$img_src</span>!=<span class="st0">&#034;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Check if Image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Image Dimension</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!<a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="re0">$img_src</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Not A Valid Image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$img_error</span> = <span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Getting Image Dimension</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$img_dim</span> = <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="re0">$img_src</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Verfiy This Is An Image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$img_verify</span> = @imagecreatefromjpeg<span class="br0">&#40;</span><span class="re0">$img_src</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!<span class="re0">$img_verify</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$img_error</span> = <span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Getting Dimensions</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$img_w</span> = imagesx<span class="br0">&#40;</span><span class="re0">$img_verify</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$img_h</span> = imagesy<span class="br0">&#40;</span><span class="re0">$img_verify</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$img_error</span> == <span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#039;Not a valid image&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span class="kw3">exit</span></a>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">?&gt;</span></div>
<h3>The HTML and HEAD Tags</h3>
<p>This is the code to begin your HTML tag and your chunk of HEAD tag. Note that if you didn&#039;t place your files in the same location you have to change the source path.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;html&gt;<br />
&lt;head&gt;</p>
<p>&lt;link rel=<span class="st0">&quot;stylesheet&quot;</span> type=<span class="st0">&quot;text/css&quot;</span> href=<span class="st0">&quot;css/marker.css&quot;</span> /&gt;</p>
<p>&lt;script type=<span class="st0">&quot;text/javascript&quot;</span> src=<span class="st0">&quot;scripts/prototype_reduced.js&quot;</span>&gt;&lt;/script&gt;<br />
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span> src=<span class="st0">&quot;scripts/rectmarquee.js&quot;</span>&gt;&lt;/script&gt; </p>
<p>&lt;/head&gt;</p></div>
<h3>Your BODY and Closing HTML Tag</h3>
<p>So all that&#039;s left is the BODY tag. There&#039;s really no modification you need to do here except for the (don&#039;t paste this in your code in order):</p>
<div class="dean_ch" style="white-space: wrap;">coords: <span class="br0">&#123;</span>x1: <span class="nu0">0</span>, y1: <span class="nu0">0</span>, width: <span class="nu0">100</span>, height: <span class="nu0">50</span><span class="br0">&#125;</span></div>
<p>This line defines where the crop box starts and how big it should be. You can play around with it if you want. Anyways here&#039;s the coding (do paste this in).</p>
<div class="dean_ch" style="white-space: wrap;">&lt;body&gt;</p>
<p>&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt; &nbsp;<br />
<span class="kw2">var</span> MarqueeTool;</p>
<p><span class="kw2">function</span> onMarqueeUpdate<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> coords = MarqueeTool.getCoords<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#039;coord_x&#039;</span><span class="br0">&#41;</span>.value = coords.x1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#039;coord_y&#039;</span><span class="br0">&#41;</span>.value = coords.y1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#039;coord_w&#039;</span><span class="br0">&#41;</span>.value = coords.width;<br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#039;coord_h&#039;</span><span class="br0">&#41;</span>.value = coords.height;<br />
<span class="br0">&#125;</span></p>
<p>
<span class="kw2">function</span> onWindowLoad<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; MarqueeTool = <span class="kw2">new</span> Marquee<span class="br0">&#40;</span><span class="st0">&#039;sampleid&#039;</span>, <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; preview: <span class="st0">&#039;preview&#039;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color: <span class="st0">&#039;#000&#039;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacity: <span class="nu0">0.45</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; coords: <span class="br0">&#123;</span>x1: <span class="nu0">0</span>, y1: <span class="nu0">0</span>, width: <span class="nu0">100</span>, height: <span class="nu0">50</span><span class="br0">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; MarqueeTool.setOnUpdateCallback<span class="br0">&#40;</span>onMarqueeUpdate<span class="br0">&#41;</span>;</p>
<p><span class="br0">&#125;</span> </p>
<p>Event.observe<span class="br0">&#40;</span>window, <span class="st0">&#039;load&#039;</span>, onWindowLoad<span class="br0">&#41;</span>; </p>
<p><span class="kw2">&lt;/script&gt;</span> </p>
<p>&lt;div style=<span class="st0">&quot;width: &lt;?php echo $img_w; ?&gt;; height: &lt;?php echo $img_h; ?&gt;; position: relative;&quot;</span>&gt;<br />
&nbsp; &nbsp; &lt;img src=<span class="st0">&quot;&lt;?php echo $img_src; ?&gt;&quot;</span> alt=<span class="st0">&quot;&quot;</span> id=<span class="st0">&quot;sampleid&quot;</span> /&gt; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &lt;div id=<span class="st0">&quot;preview&quot;</span> style=<span class="st0">&quot;position: absolute; right: 10px; bottom: 10px; border: 2px solid #FFF;&quot;</span>&gt;&lt;/div&gt; <br />
&lt;/div&gt;</p>
<p>&lt;form name=<span class="st0">&quot;coordsform&quot;</span> action=<span class="st0">&quot;crop.php&quot;</span> target=<span class="st0">&quot;_blank&quot;</span> method=<span class="st0">&quot;get&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=<span class="st0">&quot;hidden&quot;</span> name=<span class="st0">&quot;img&quot;</span> value=<span class="st0">&quot;&lt;?php echo $img_src; ?&gt;&quot;</span> /&gt;<br />
&nbsp; &nbsp; &lt;input type=<span class="st0">&quot;hidden&quot;</span> name=<span class="st0">&quot;img_dst&quot;</span> value=<span class="st0">&quot;&lt;?php echo $img_dst; ?&gt;&quot;</span> /&gt;<br />
&nbsp; &nbsp; &lt;input type=<span class="st0">&quot;hidden&quot;</span> name=<span class="st0">&quot;x&quot;</span> value=<span class="st0">&quot;5&quot;</span> id=<span class="st0">&quot;coord_x&quot;</span> /&gt;<br />
&nbsp; &nbsp; &lt;input type=<span class="st0">&quot;hidden&quot;</span> name=<span class="st0">&quot;y&quot;</span> value=<span class="st0">&quot;0&quot;</span> id=<span class="st0">&quot;coord_y&quot;</span> /&gt;<br />
&nbsp; &nbsp; &lt;input type=<span class="st0">&quot;hidden&quot;</span> name=<span class="st0">&quot;w&quot;</span> value=<span class="st0">&quot;0&quot;</span> id=<span class="st0">&quot;coord_w&quot;</span> /&gt;<br />
&nbsp; &nbsp; &lt;input type=<span class="st0">&quot;hidden&quot;</span> name=<span class="st0">&quot;h&quot;</span> value=<span class="st0">&quot;0&quot;</span> id=<span class="st0">&quot;coord_h&quot;</span> /&gt;</p>
<p>&nbsp; &nbsp; <br />
&nbsp; &nbsp; &lt;input name=<span class="st0">&quot;submit&quot;</span> type=<span class="st0">&quot;submit&quot;</span> value=<span class="st0">&quot;Make Thumbnail&quot;</span>&gt;<br />
&lt;/form&gt; </p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Now we&#039;re just about complete here. All this tool does right now is let you select an area to crop. To actually make the thumbnail you need the assistant of PHP (you can do it in JS but I prefer PHP). You need to have the GD library enabled in order for this to work. </p>
<p>At this point you need to create your last file which is named crop.php. All you need in crop.php is this:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span> </p>
<p><span class="co1">//Variables</span><br />
<span class="re0">$img_w</span> = <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#039;w&#039;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$img_h</span> = <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#039;h&#039;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$img_x</span> = <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#039;x&#039;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$img_y</span> = <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#039;y&#039;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$img_src</span> = <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#039;img&#039;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$img_dst</span> = <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#039;img_dst&#039;</span><span class="br0">&#93;</span>;</p>
<p><span class="co1">//There&#039;s a Set Thumb</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$img_w</span>&gt;<span class="nu0">0</span> &amp;&amp; <span class="re0">$img_h</span>&gt;<span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> </p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Create New Image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$new_img</span> = imagecreatetruecolor<span class="br0">&#40;</span><span class="re0">$img_w</span>, <span class="re0">$img_h</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Loading The Original Image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$old_img</span> = imagecreatefromjpeg<span class="br0">&#40;</span><span class="re0">$img_src</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Copying Image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; imagecopy<span class="br0">&#40;</span><span class="re0">$new_img</span>, <span class="re0">$old_img</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$img_x</span>, <span class="re0">$img_y</span>, <span class="re0">$img_w</span>, <span class="re0">$img_h</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&quot;Content-Type: image/jpeg&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; @imagejpeg<span class="br0">&#40;</span><span class="re0">$new_img</span>, <span class="re0">$img_dst</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; imagejpeg<span class="br0">&#40;</span><span class="re0">$new_img</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Destroy the Old Images</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$old_img</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$new_img</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">?&gt;</span></div>
<p>That&#039;s it, and everything should work like planed. I&#039;ve tested this script out a few times but if anything doesn&#039;t work just let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2010/awesome-image-cropperthumbnail-maker-script-modified-marquee-tool/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP password strength detector script</title>
		<link>http://www.crankberryblog.com/2010/php-password-strength-detector-script</link>
		<comments>http://www.crankberryblog.com/2010/php-password-strength-detector-script#comments</comments>
		<pubDate>Wed, 17 Feb 2010 08:23:34 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Script]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=333</guid>
		<description><![CDATA[If you operate a user registration script on your website you may want to ensure users are protected. There are certain aspects of this you cannot control such as the user's self selected password. Here I have a script that will detect the user's password strength and base on that you could reject the password or just make notice to the user their password's strength.

<img src="http://www.crankberryblog.com/images/password-strength-detector.jpg" alt="PHP Password Strength Detector Script" />]]></description>
			<content:encoded><![CDATA[<p>If you operate a user registration script on your website you may want to ensure users are protected. There are certain aspects of this you cannot control such as the user&#039;s self selected password. Here I have a script that will detect the user&#039;s password strength and base on that you could reject the password or just make notice to the user their password&#039;s strength.</p>
<p><img src="http://www.crankberryblog.com/images/password-strength-detector.jpg" alt="PHP Password Strength Detector Script" /></p>
<p>Basically we&#039;re checking against a few things here and we give a rating to each criteria and then add up the final score to see where they rank. Here is what we&#039;ll be checking against:</p>
<ul>
<li>Length &#8211; 10 Points</li>
<li>Lower Case Characters &#8211; 20 Points</li>
<li>Upper Case Characters &#8211; 20 Points</li>
<li>Numbers &#8211; 20 Points</li>
<li>Special Characters &#8211; 30 Points</li>
</ul>
<p></p>
<p>The points are given based on how much value they may add to the password. Enough talking I present you the function:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> password_strength<span class="br0">&#40;</span><span class="re0">$password</span>, <span class="re0">$display</span> = <span class="kw2">TRUE</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Strength Scoring</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass_score</span> = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass_len</span> = <span class="kw2">FALSE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass_lc</span> = <span class="kw2">FALSE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass_uc</span> = <span class="kw2">FALSE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass_num</span> = <span class="kw2">FALSE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass_weird</span> = <span class="kw2">FALSE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Pad</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$password</span> = <span class="nu0">0</span> . <span class="re0">$password</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Check Length</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/strlen"><span class="kw3">strlen</span></a><span class="br0">&#40;</span><span class="re0">$password</span><span class="br0">&#41;</span>&gt;<span class="nu0">6</span><span class="br0">&#41;</span> <span class="re0">$pass_len</span> = <span class="kw2">TRUE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Check Lowercase Characters</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">97</span>; <span class="re0">$i</span> &lt;=<span class="nu0">122</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>@<a href="http://www.php.net/strpos"><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$password</span>, <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="re0">$i</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="re0">$pass_lc</span> = <span class="kw2">TRUE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Check Uppercase Characters</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">65</span>; <span class="re0">$i</span> &lt;=<span class="nu0">90</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>@<a href="http://www.php.net/strpos"><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$password</span>, <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="re0">$i</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="re0">$pass_uc</span> = <span class="kw2">TRUE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Check Numbers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">48</span>; <span class="re0">$i</span> &lt;=<span class="nu0">57</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>@<a href="http://www.php.net/strpos"><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$password</span>, <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="re0">$i</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="re0">$pass_num</span> = <span class="kw2">TRUE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Check Weird Characters</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">33</span>; <span class="re0">$i</span> &lt;=<span class="nu0">126</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Excempt</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$i</span>&gt;<span class="nu0">47</span> &amp;&amp; <span class="re0">$i</span>&lt;<span class="nu0">58</span><span class="br0">&#41;</span> || <span class="br0">&#40;</span><span class="re0">$i</span>&gt;<span class="nu0">64</span> &amp;&amp; <span class="re0">$i</span>&lt;<span class="nu0">91</span><span class="br0">&#41;</span> || <span class="br0">&#40;</span><span class="re0">$i</span>&gt;<span class="nu0">96</span> &amp;&amp; <span class="re0">$i</span>&lt;<span class="nu0">123</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>@<a href="http://www.php.net/strpos"><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$password</span>, <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="re0">$i</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="re0">$pass_weird</span> = <span class="kw2">TRUE</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Points</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_len</span><span class="br0">&#41;</span> <span class="re0">$pass_score</span> = <span class="re0">$pass_score</span> + <span class="nu0">10</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_lc</span><span class="br0">&#41;</span> <span class="re0">$pass_score</span> = <span class="re0">$pass_score</span> + <span class="nu0">20</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_uc</span><span class="br0">&#41;</span> <span class="re0">$pass_score</span> = <span class="re0">$pass_score</span> + <span class="nu0">20</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_num</span><span class="br0">&#41;</span> <span class="re0">$pass_score</span> = <span class="re0">$pass_score</span> + <span class="nu0">20</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_weird</span><span class="br0">&#41;</span> <span class="re0">$pass_score</span> = <span class="re0">$pass_score</span> + <span class="nu0">30</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Displaying</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$display</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#039;&lt;div style=&quot;width: 210px; height: 15px; border: 1px solid #919191; padding: 1px; font-size: 9px; color: #FFFFFF; font-family: Arial;&quot;&gt;&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_score</span> &lt;= <span class="nu0">40</span><span class="br0">&#41;</span> <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#039;&lt;div style=&quot;width: 65px; height: 13px; background: #910e0e; padding: 2px 0 0 5px;&quot;&gt;WEAK&lt;/div&gt;&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_score</span> &gt; <span class="nu0">40</span> &amp;&amp; <span class="re0">$pass_score</span> &lt; <span class="nu0">70</span><span class="br0">&#41;</span> <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#039;&lt;div style=&quot;width: 135px; height: 13px; background: #ceb827; padding: 2px 0 0 5px;&quot;&gt;AVERAGE&lt;/div&gt;&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$pass_score</span> &gt;= <span class="nu0">71</span><span class="br0">&#41;</span> <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#039;&lt;div style=&quot;width: 205px; height: 13px; background: #3ca01a; padding: 2px 0 0 5px;&quot;&gt;STRONG&lt;/div&gt;&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#039;&lt;/div&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$pass_score</span>;<br />
<span class="br0">&#125;</span></div>
<p>The script itself has a built in display bar which will visuallize how strong or weak the password maybe which could turn off. Here&#039;s an example of calling the script:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="re0">$password</span> = <span class="st0">&quot;GoodBoy&quot;</span>;</p>
<p><span class="co1">//Showing the Password Strength with Visual Bar</span><br />
password_strength<span class="br0">&#40;</span><span class="re0">$password</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">//Not Showing anything at all but storing strength as a variable</span><br />
<span class="re0">$strength</span> = password_strength<span class="br0">&#40;</span><span class="re0">$password</span>, <span class="kw2">FALSE</span><span class="br0">&#41;</span>;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2010/php-password-strength-detector-script/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Image optimization for web design and development</title>
		<link>http://www.crankberryblog.com/2010/image-optimization-for-web-design-and-development</link>
		<comments>http://www.crankberryblog.com/2010/image-optimization-for-web-design-and-development#comments</comments>
		<pubDate>Tue, 16 Feb 2010 19:40:03 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[Image Optimization]]></category>
		<category><![CDATA[Load Size Reduction]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=311</guid>
		<description><![CDATA[Between a good design a good development there's a path in between that we all must cross which is converting your design into a functional website. An aspect to really consider now a days is loading time of the website. There are many variables that contribute to a site's load time which includes server and client aspects and everything in between. Today we will focus specifically on loading the images on the site and how you can optimize them for best performance.

<img src="http://www.crankberryblog.com/images/image-optimization.jpg" alt="Image Optimization" />]]></description>
			<content:encoded><![CDATA[<p>Between a good design a good development there&#039;s a path in between that we all must cross which is converting your design into a functional website. An aspect to really consider now a days is loading time of the website. There are many variables that contribute to a site&#039;s load time which includes server and client aspects and everything in between. Today we will focus specifically on loading the images on the site and how you can optimize them for best performance.</p>
<p><img src="http://www.crankberryblog.com/images/image-optimization.jpg" alt="Image Optimization" /></p>
<h2>The Design Aspect</h2>
<p>I always tell myself and people who design for me to not worry about the design. I can always code it and optimize it for the web. Although this maybe true I don&#039;t always design with that mentality. I usually keep the user of the website in mind. I never try to overkill the design just because I want to, but this is coming from a developer&#039;s thoughts. </p>
<p>Regardless, if you are one who is highly concerned about the graphical load time then design with that in mind. You can cut down on size by using design elements that you know can be replaced by CSS 2.0 standard coding. So we&#039;re talking about solid boxes, solid lines and etc. We&#039;ll go further into that in the CSS section. Using heavy graphics and lots of blending will add up in size. Something like that looks like Crankberry will cost you around 700 KB in image size with the whole page loading around 1 MB. I cater to designers and developers so fairly average for today&#039;s standard. </p>
<p>With that, keep those thoughts in mind when designing because if you design first then noticed that the site bogs down then you&#039;ll be going back many steps just to make revisions to that.</p>
<h2>Keeping the Balance</h2>
<p>As mentioned in the beginning of the article that there are many things that dampens the load time of your site. The way your content is drawn onto the pages is also a factor that may affect the speed. Static contents won&#039;t pull you down much unless you&#039;re uploading novels and encylclopedias on one page but then you have other problems to worry about don&#039;t you. Anyways, if your website pulls a lot of content from your database per page with lots of joins and queries then your content is also factored in. In these scenarios I usually recommend keeping a balance to mitigate high load times. So if you have a lot of heavy database interaction I would recommend keeping the design and graphics to a lower end. On the contrary if you don&#039;t have a lot of database interaction I may not recommend super heavy design just means that you&#039;re more flexible. Refer back to the last section as to how to optimize your design.</p>
<h2>JPEG vs GIF vs PNG</h2>
<p>Now that you&#039;re done your designing its time to slice the images up and start structuring your HTML and CSS. When saving your image files you have so many options as to which file format to save it as. You&#039;ve got JPEG, GIF, PNG, Bitmap, TIFF and the list goes on and on. Just to shorten your list down, I would stick to three primary formats: JPEG, GIF, and PNG. All the other formats for development wise can be forgotten. Now some people like to consistenty use one format throughout their whole website but I like to switch it up. I prefer to use JPEG, GIF and sometimes PNG. I&#039;ll go into further details about which I use and when I use it in a bit. First of all you should understand the difference between all these formats. There has been many articles written over this topic so it would be super redundant to do it again. I&#039;ll spare you the theatrics and give you the highlights.</p>
<p><strong>JPEG</strong></p>
<ul>
<li>Lossly compression</li>
<li>Compresses colors and grayscale</li>
<li>Used for complex images</li>
</ul>
<p><strong>GIF</strong></p>
<ul>
<li>Lossless compression</li>
<li>256 Colors</li>
<li>Good for line and simple drawings</li>
<li>Supports animation</li>
<li>Supports transparency</li>
</ul>
<p><strong>PNG</strong></p>
<ul>
<li>Lossless compression</li>
<li>Patent-free GIF</li>
<li>Supports transparency with opacity setting</li>
</ul>
<h2>Which to Use</h2>
<p>After reading the above part you maybe wondering how this infomation reflects on your files format and which one you should use. Here&#039;s how you look at it. Lean towards GIF and JPEG and if necessary then use PNG.</p>
<p>Lets start with why minimal use of PNG. PNG is a nice format format in replacement of GIF. When saving the same simple GIF file in PNG you can end up with a smaller file size as PNG does a better job in compression. The reason I still don&#039;t use PNG much is because some of the older, non-main stream and mobile browsers don&#039;t have a good support for PNGs. There are ways to go abouts for this but to accomodate for all browsers would be very timely. As I always focus to present a cross-browser compatible website I stay away from this format.</p>
<p>Now then, we&#039;re left with the JPEG and the GIF. It is very simple when it comes down to these two contenders. If the image you&#039;re saving has lots of colors and blending then go for the JPEG if it has simple lines and text and solid color go for the GIF. Your sizes will optimized this way.</p>
<p><img src="http://www.crankberryblog.com/images/image-optimization-example-jpeg.jpg" alt="Image Optimization with JPEG" /></p>
<p><img src="http://www.crankberryblog.com/images/image-optimization-example-gif.jpg" alt="Image Optimization with GIF" /></p>
<p>Here I took a screenshot of my currently portfolio (top design) which should most of the images should be saved in JPEG due to the complexity of the images and colors. The second screenshot is of FusedEffects which should mostly be saved in GIF due to the simple lines and large blobs of solid colors.</p>
<h2>Good Practice</h2>
<p>Obviously if you&#039;ve got all that down you can quickly decide which format to use and how much compression you may want to do. If you&#039;re lazy like myself and you have Photoshop the best thing to do is to use their [Save as for Web] setting. The window it popups up with will give you the image size before you even save it.</p>
<p><img src="http://www.crankberryblog.com/images/image-optimization-good-practice.jpg" alt="Image Optimization Practices" /></p>
<p>This way you can switch between JPEG, GIF, PNG and different settings until you get the quality and size that pleases you.</p>
<h2>The Role of CSS</h2>
<p>Ok ok ok, I mentioned a few times (at least I think) that you can replace certain elements with CSS to eliminate the use of graphics where necessary. I always prefer this method when possible as I tend to think a few lines of code is always smaller than an image size. </p>
<p>Now a days, developers have come up with many creative ways to achieve graphical effects with just a few lines of coding. Such as rounded corners. The trend right now seems to be using rounded corner boxes instead of plain old square. Since CSS 2.0 has no support for rounded corners on div tags people rely on images and positioning. As I have released months ago a script that is <a href="http://www.crankberryblog.com/tool/css-rounded-corners-generator.php">purely css, cross-browser compatible and image-less for rounded corners.</a></p>
<p><img src="http://www.crankberryblog.com/images/css-rounded-corners-with-borders.jpg" /></p>
<p>That&#039;s only one of the many examples in which graphical elements can be replaced by CSS coding. I will be doing a full article on this in the near future so stay tuned for that.</p>
<h3>If You Can&#039;t Replace The Image, Work With It</h3>
<p>In certain cases some pure CSS solutions aren&#039;t as stable yet such as gradient effects you can combine images with CSS to create the effect. So for a full stretch gradient instead of making an image 5000px x 10px just save it as 1px x 10px and use the background: repeat-x; This will save you lots.</p>
<p>In summary, how much can you save by going through so much optimization. This really depends on how heavily you designed your site. As you can tell by my style I like to go heavy with personal designs and light on business designs. Sometimes its not up to you. I work with a designer who over does gradients and shadows everywhere so its up to me to optimized the images. Sometimes I can save up to 500+ KB by doing the right optimization. You maybe thinking that with the advancement of cable internet and the cost of bandwidth going down it doesn&#039;t really matter. Remember its all about the user experience. There are lots of factors involved that contibutes to your site&#039;s load time, try to optimized everything so there&#039;s is minimal lag time. You should also understand that with the advancement of technology more and more people are surfing with their mobile phones or laptops tethered through their mobile phones. Its always a plus for your users when they get the things they&#039;re looking for, faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2010/image-optimization-for-web-design-and-development/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Wave Invitations &#8211; Does it work for you?</title>
		<link>http://www.crankberryblog.com/2009/google-wave-invitations-does-it-work-for-you</link>
		<comments>http://www.crankberryblog.com/2009/google-wave-invitations-does-it-work-for-you#comments</comments>
		<pubDate>Tue, 01 Dec 2009 17:25:37 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=312</guid>
		<description><![CDATA[<div class="excerpt_screen_right"><img src="http://www.crankberryblog.com/images/google-wave.jpg" /></div>Well, the Google Wave has been out for a couple months now and I'm still not sure what's so crazy about this thing. Either way, I've got <strong>some invites</strong> sitting here, if you're interested in joining the crazy crowd and seeing what this new Google product is all about just leave me a line. Try it out and then let me know how it has worked or not worked for you!]]></description>
			<content:encoded><![CDATA[<div class="excerpt_screen_right"><img src="http://www.crankberryblog.com/images/google-wave.jpg" /></div>
<p>Well, the Google Wave has been out for a couple months now and I&#039;m still not sure what&#039;s so crazy about this thing. Either way, I&#039;ve got <strong>some invites</strong> sitting here, if you&#039;re interested in joining the crazy crowd and seeing what this new Google product is all about just leave me a line. Try it out and then let me know how it has worked or not worked for you!</p>
<p><strong>My Take on Google Wave</strong></p>
<p>Google Wave isn&#039;t all that I had anticipated, or maybe I was expecting a lot. When it was first introduced it showed people communicating and working on projects together. It was like a shared community online to&#8230; work on things. So far I have not used it for such. I&#039;m not going to go in details and put out a review as everybody probably sees a different use for this application. Let me know, how has Google Wave changed your life?</p>
<p>I believe Google Wave is one of those web application made to compliment with the Chrome OS that Google will be releasing. The Wave will play a key role in the work and communication aspect for the OS, just like how all their online applications are.</p>
<p><strong>Get a Google Wave Invite</strong></p>
<p>Once again, get an invite &#8211; leave a line or message.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2009/google-wave-invitations-does-it-work-for-you/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Realistic Coffee Cup &#8211; Photoshop Tutorial</title>
		<link>http://www.crankberryblog.com/2009/a-realistic-coffee-cup-photoshop-tutorial</link>
		<comments>http://www.crankberryblog.com/2009/a-realistic-coffee-cup-photoshop-tutorial#comments</comments>
		<pubDate>Thu, 19 Nov 2009 01:55:00 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[photoshop tutorial]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=304</guid>
		<description><![CDATA[Its been overdone but a friend of mine asked me to show him how to draw a realistic coffee cup in Photoshop, he said he's not using it for web design so I guess I'll show him here. This is what the final result looks like:

<img src="http://www.crankberryblog.com/images/tutorial-coffee-final.jpg" alt="Coffee Cup Photoshop Tutorial" />]]></description>
			<content:encoded><![CDATA[<p>Its been overdone but a friend of mine asked me to show him how to draw a realistic coffee cup in Photoshop, he said he&#039;s not using it for web design so I guess I&#039;ll show him here. This is what the final result looks like:</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-final.jpg" alt="Coffee Cup Photoshop Tutorial" /></p>
<h3>Step 1</h3>
<p>Using the select tool create a circle for where you want the coffee cup to begin.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-1.jpg" alt="Coffee Cup Tutorial Step 1" /></p>
<h3>Step 2</h3>
<p>Gradient it in with a colour of your choice in which you want the colour of the cup to be. Use a darker colour near the center going to a lighter colour.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-2.jpg" alt="Coffee Cup Tutorial Step 2" /></p>
<h3>Step 3</h3>
<p>Create a new layer named [inner cup]. Select a smaller area in the mug to the lower right part of the circle you just created and gradient this one in a darker colour. This in 3D aspect is the bottom part of the mug. We&#039;re going to set this in so we have an area to work with.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-3.jpg" alt="Coffee Cup Tutorial Step 3" /></p>
<h3>Step 4</h3>
<p>Duplicate the smaller circle you just created by pressing Ctrl+J. Now select the bottom layer of the two and transform the object (Ctrl+T). Right click and select Distort. Drag out the shape to make something like so:</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-4.jpg" alt="Coffee Cup Tutorial Step 4" /></p>
<h3>Step 5</h3>
<p>Press Enter to confirm the change of shape. Change the layer blending mode to multiple.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-5.jpg" alt="Coffee Cup Tutorial Step 5" /></p>
<h3>Step 6</h3>
<p>Enhance the lighting by dodging and burning the following areas, go in circular motion like the shape of the cup. Blue arrows mean dodge and red arrows mean burn.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-6.jpg" alt="Coffee Cup Tutorial Step 6" /></p>
<h3>Step 7</h3>
<p>Create a layer underneath [inner cup]. Select a circle area just smaller than your overall cup size. Fill it in with white, now offset the selection to the left 3 or 4px and crop out the remainder.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-7.jpg" alt="Coffee Cup Tutorial Step 7" /></p>
<h3>Step 8</h3>
<p>Using the eraser soften up the middle part of the white curve line you just created and the tips of the line as well.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-8.jpg" alt="Coffee Cup Tutorial Step 8" /></p>
<h3>Step 9</h3>
<p>Create another layer on top and make another circular selection about 30 &#8211; 40 px away from the edge of your cup. Fill this in with a very dark brown gradient. Contract the selection 5px and crop out the center of it.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-9.jpg" alt="Coffee Cup Tutorial Step 9" /></p>
<h3>Step 10</h3>
<p>Using the eraser soften up the two sides of the rim line you just created.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-10.jpg" alt="Coffee Cup Tutorial Step 10" /></p>
<h3>Step 11</h3>
<p>Moving back to the [inner cup]. Using the burn tool burn out the top left of the [inner cup] until it looks like the one below. Don&#039;t worry about being bold and making it too dark, once the coffee is one top it&#039;ll look good.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-11.jpg" alt="Coffee Cup Tutorial Step 11" /></p>
<h3>Step 12</h3>
<p>Create a layer on top of [inner cup]. Make a circular selection slightly bigger than [inner cup] but offset the selection more to the left and up more. Gradient fill this with a dark brown and dark orange. Change the opacity of the coffee layer to 70%.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-12.jpg" alt="Coffee Cup Tutorial Step 12" /></p>
<h3>Step 13</h3>
<p>Create a new layer on top of the coffee layer with the same selection size as the coffee, fill in the section with a soft color close to white (but not gray). Deselect your selection (Ctrl+D) and Gaussian blur it for 5px (Filter > Blur > Gaussian Blur).</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-13.jpg" alt="Coffee Cup Tutorial Step 13" /></p>
<h3>Step 14</h3>
<p>At this point I noticed the cup wasn&#039;t very vivid in lighting and shadow so I dodged and burned a bit more of the edges and inner side as the arrows has shown. I also added a white mark in the coffee and blurred it as a reflection.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-14.jpg" alt="Coffee Cup Tutorial Step 14" /></p>
<h3>Step 15</h3>
<p>On the edge I made a reflection mark on the cup. Basically drew a shape of the reflection I wanted, filled it in in white. Crop out the unwanted area and changed the opacity to 30%.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-15.jpg" alt="Coffee Cup Tutorial Step 15" /></p>
<h3>Step 16</h3>
<p>Now we draw the ear of the cup. Create a layer under everything you just drew. Draw out the shape like the one shown below with the pen tool and select the path. Gradient fill it with the light side to the outer part of the ear and darker towards the cup.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-16.jpg" alt="Coffee Cup Tutorial Step 16" /></p>
<h3>Step 17</h3>
<p>Create another layer under the ear as the bottom/end part of it. Finish off the shape as shown below and fill it in with a much darker colour of the cup.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-17.jpg" alt="Coffee Cup Tutorial Step 17" /></p>
<h3>Step 18</h3>
<p>Give some waves to the coffee by giving a couple of dodge and burn strokes as follows.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-18.jpg" alt="Coffee Cup Tutorial Step 18" /></p>
<h3>Step 19</h3>
<p>Create another layer below everything, this will be your shadow layer. Just draw out any random shape that looks like your cup and fill it in with a dark gray. The shape doesn&#039;t need to be that accurate as it will be blurred.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-19.jpg" alt="Coffee Cup Tutorial Step 19" /></p>
<h3>Step 20</h3>
<p>Blur (Filter > Blur > Gaussian Blur) at 20px and change the layer blending option to multiply.</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-20.jpg" alt="Coffee Cup Tutorial Step 20" /></p>
<p>Tweak around with the lighting and contrast and you&#039;ll get something that looks like this:</p>
<p><img src="http://www.crankberryblog.com/images/tutorial-coffee-final.jpg" alt="Coffee Cup Photoshop Tutorial" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2009/a-realistic-coffee-cup-photoshop-tutorial/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stats you should know before making a website</title>
		<link>http://www.crankberryblog.com/2009/stats-you-should-know-before-making-a-website</link>
		<comments>http://www.crankberryblog.com/2009/stats-you-should-know-before-making-a-website#comments</comments>
		<pubDate>Wed, 18 Nov 2009 19:15:07 +0000</pubDate>
		<dc:creator>Jerry Low</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Internet Economy]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.crankberryblog.com/?p=300</guid>
		<description><![CDATA[Making a website or a blog now-a-days is not easy, given all the tools we have today compared to the early 90's means its not only easier for us but easier for others too. The competitive playground is just so big now a days. This is why your website not only has to be unique but has to cover a few basic things first. Here are some stats and guidelines to help you get started. As well as a look into the business aspect of making a website.]]></description>
			<content:encoded><![CDATA[<p>Making a website or a blog now-a-days is not easy, given all the tools we have today compared to the early 90&#039;s means its not only easier for us but easier for others too. The competitive playground is just so big now a days. This is why your website not only has to be unique but has to cover a few basic things first. Here are some stats and guidelines to help you get started. As well as a look into the business aspect of making a website.</p>
<h3>Website Name</h3>
<p>When I was a younger starting a website or a project was easy. Just come up with a name that I liked and then just purchase the relevant domain after. Today, its not the case, we name websites and projects based on domain availabilities and possibly price. Just to give you a scope there are 112,961,783 active domains currently, with 83,320,335 of that being a .com domain (1). Although the combination of words for domain is near endless, it&#039;ll be harder and harder to get the name you want.</p>
<p>It will eventually boils down to resorting to a longer domain name, unique play on words or purchasing pre-owned domains at a premium pricing.</p>
<h3>The Design</h3>
<p>Once you&#039;re ready to start designing your website you&#039;ll have to put into perspective how big or small to design it. Just because you have a 14&#034; or a 36&#034; monitor doesn&#039;t mean that everybody does as well. As of January 2009 57% of detectable users are displaying at higher than 1024&#215;768 px. There are 36% users at 1024&#215;768 and 4% less than that (2).</p>
<p>Understanding your target users is very important. If you cater to teenagers than a higher percentage of your user will end up in the 1024&#215;768+ category. If you cater to an older or well aged audience then you&#039;ll probably have more users in the 1024&#215;768 or below category. If you cater to graphic artists and designers then you most like have a much higher resolution to work with. </p>
<p>I tend to use a 1400&#215;1100 canvas for my design and keep content within a 1200&#215;1100 or 1000&#215;1100 box, the remaining area is for the design of the background. Just like shown below:</p>
<p><img src="http://www.crankberryblog.com/images/stats-for-web-canvas.jpg" alt="Canvas for Web Design" /></p>
<p><strong>Color Wise</strong></p>
<p>You shouldn&#039;t have to worry too much about colors as 95% of users has 24bit or 32 bit hardware supporting up to 16,777,216 colors.</p>
<h3>Developing</h3>
<p>The biggest concern that you should have is how the users view your website once its made into HTML. The most recent stats indicate that 47.5% users online are using Firefox and a collective percentage of 37.5% of users are using IE6, 7 and 8 (3). As you can see a significantly outstanding of majorities use Firefox and IE. </p>
<p>When developing offline I like to test and view my scripts in Firefox and IE7. Once done, I like to view it in IE 6 and tweak things. This step should be the biggest tweaking stage. If everything works in Firefox and IE 6 and 7 the probability (and this is not a probability of 1) of it working on other browsers is pretty good.</p>
<p>When I have time I also like to test the page on different machines and different mobile devices to get a glimpse of how its working out.</p>
<h3>The Money</h3>
<p>With that, lets get to where some of you are truly interested in &#8211; the money. Is there money to be made making websites? Yes, but the competition as said before is high. With 112,961,783 active domains and 50 million blogs (detected in 2006) there arena is just too crowded (4). Ask yourself what you want to do and how that can be done in a unique way.</p>
<p><strong>Who to Target</strong></p>
<p>Defining your target market is a key to a good business and marketing plan. Which demographic do you want to be your key audience? Currently 72% of advertisers find it beneficial to target the 35-44 and 25-34 year old category with them making up 29% and 28% of users online, respectively (5). Don&#039;t let age be the only determining factor for you though, targeting a common interest amongst a group of users could be a break-through factor as well. This may be people who loves sour candies, office interiors or just residing in the same local area. A combination of criteria may make it more unique for you as well such as people aged 16-24 who likes sour candies or people of aged 35-44 living in the same city.</p>
<p>By detailing and being more specific about your target market may give you a bit of a competitive edge but understand that by adding more criteria to the list you are shrinking the size of your target. Ask yourself, if you have a smaller market to serve can you still sustain? If you sell a product that&#039;s $1 and you target 25-34 y/o male residents a suburban area you may not have enough potential clients to survive. Do some math and see where you want to end up, that should give you a scope of how many people you may potential need to target.</p>
<p><strong>Making Money Through Advertisement</strong></p>
<p>Some of you webmasters are planning to make money through advertisement, this maybe through a 3rd party company such as Google Adsense or Adbrite or just handle advertisement internally. You should know that there&#039;s still plenty of advertising dollars floating around the internet for you to make, it all just depends if you know how to get it. </p>
<p>Focusing on North American market here, despite the depression and economic downturn organizations are keeping a budget ready for internet advertisement. There&#039;s many factors why this is, which is slightly irrelevant here but keep in mind that this dollar amount will continue to grow proportionate to the growth of how many and how often people access the internet on a daily base.</p>
<p>The outlook for 2009 was an 8.9% growth in overall internet advertisement spending which equates to $25.7 billion US dollars. This is a good enough motivation for those who wishes to make a career out of websites and advertisements (6).</p>
<p>I am just so tire right now so I suppose I&#039;ll edit and update this article as I go.</p>
<p>1. http://www.domaintools.com/internet-statistics/<br />
2. http://www.w3schools.com/browsers/browsers_display.asp<br />
3. http://www.w3schools.com/browsers/browsers_stats.asp<br />
4. http://www.cyberjournalist.net/news/003674.php<br />
5. http://www.eiaa.net/ftp/casestudiesppt/EIAA_Marketers_Internet_Ad_Barometer_2009_PR_Presentation.pdf<br />
6. http://www.emarketer.com/Article.aspx?R=1006813</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crankberryblog.com/2009/stats-you-should-know-before-making-a-website/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
