<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>In Object : You can see every thing as Object</title>
	<atom:link href="http://inobject.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://inobject.wordpress.com</link>
	<description>The danger of small error is those errors are never small</description>
	<lastBuildDate>Sat, 22 Aug 2009 01:04:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='inobject.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>In Object : You can see every thing as Object</title>
		<link>http://inobject.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://inobject.wordpress.com/osd.xml" title="In Object : You can see every thing as Object" />
	<atom:link rel='hub' href='http://inobject.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Make Square Image For landscape and portrait in cakePHP</title>
		<link>http://inobject.wordpress.com/2009/08/22/make-square-image-for-landscape-and-portrait-in-cakephp/</link>
		<comments>http://inobject.wordpress.com/2009/08/22/make-square-image-for-landscape-and-portrait-in-cakephp/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 00:08:23 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/?p=213</guid>
		<description><![CDATA[The code is almost closer with my previous article, just change function resize_image to square_image function crop_img($imgname, $scale, $filename) { $filetype = $this-&#62;getFileExtension($imgname); $filetype = strtolower($filetype); switch($filetype){ case &#8220;jpeg&#8221;: case &#8220;jpg&#8221;: $img_src = ImageCreateFromjpeg ($imgname); break; case &#8220;gif&#8221;: $img_src = imagecreatefromgif ($imgname); break; case &#8220;png&#8221;: $img_src = imagecreatefrompng ($imgname); break; } $width = imagesx($img_src); $height [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=213&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The code is almost closer with my previous article, just change function resize_image to square_image</p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">function crop_img($imgname, $scale, $filename) {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$filetype = $this-&gt;getFileExtension($imgname);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$filetype = strtolower($filetype);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">switch($filetype){</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;jpeg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;jpg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$img_src = ImageCreateFromjpeg ($imgname);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;gif&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$img_src = imagecreatefromgif ($imgname);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;png&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$img_src = imagecreatefrompng ($imgname);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$width = imagesx($img_src);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$height = imagesy($img_src);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$ratiox = $width / $height * $scale;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$ratioy = $height / $width * $scale;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">//&#8211; Calculate resampling</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$newheight = ($width &lt;= $height) ? $ratioy : $scale;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$newwidth = ($width &lt;= $height) ? $scale : $ratiox;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">//&#8211; Calculate cropping (division by zero)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$cropx = ($newwidth &#8211; $scale != 0) ? ($newwidth &#8211; $scale) / 2 : 0;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$cropy = ($newheight &#8211; $scale != 0) ? ($newheight &#8211; $scale) / 2 : 0;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">//&#8211; Setup Resample &amp; Crop buffers</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$resampled = imagecreatetruecolor($newwidth, $newheight);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">$cropped = imagecreatetruecolor($scale, $scale);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">//&#8211; Resample</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">imagecopyresampled($resampled, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">//&#8211; Crop</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">imagecopy($cropped, $resampled, 0, 0, $cropx, $cropy, $newwidth, $newheight);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">// Save the cropped image</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">switch($filetype)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;jpeg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;jpg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">imagejpeg($cropped,$filename,80);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;gif&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">imagegif($cropped,$filename,80);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">case &#8220;png&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">imagepng($cropped,$filename,80);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">}</div>
<blockquote><p>function crop_img($tempFile, $scale, $newFile) {</p>
<p>$filetype = $this-&gt;getFileExtension($tempFile);</p>
<p>$filetype = strtolower($tempFile);</p>
<p>switch($filetype) {</p>
<p><span style="white-space:pre;"> </span>case &#8220;jpeg&#8221;:</p>
<p><span style="white-space:pre;"> </span>case &#8220;jpg&#8221;:</p>
<p><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span>$img_src = imagecreatefromjpeg($tempFile);</p>
<p><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span>break;</p>
<p><span style="white-space:pre;"> </span>case &#8220;gif&#8221;:</p>
<p><span style="white-space:pre;"> </span>$img_src = imagecreatefromgif ($tempFile);</p>
<p><span style="white-space:pre;"> </span>break;</p>
<p><span style="white-space:pre;"> </span>case &#8220;png&#8221;:</p>
<p><span style="white-space:pre;"> </span>$img_src = imagecreatefrompng ($tempFile);</p>
<p><span style="white-space:pre;"> </span> case &#8220;bmp&#8221;:</p>
<p><span style="white-space:pre;"> </span>$img_src = imagecreatefromwbmp ($tempFile);</p>
<p><span style="white-space:pre;"> </span>break;</p>
<p>}</p>
<p>$width = imagesx($img_src);</p>
<p>$height = imagesy($img_src);</p>
<p>$scale = explode(&#8216;x&#8217;,strtolower($size));</p>
<p>$ratiox = $width / $height * $scale[0];</p>
<p>$ratioy = $height / $width * $scale[0];</p>
<p>//&#8211; Calculate resampling</p>
<p>$newheight = ($width &lt;= $height) ? $ratioy : $scale[0];</p>
<p>$newwidth = ($width &lt;= $height) ? $scale[0] : $ratiox;</p>
<p>//&#8211; Calculate cropping (division by zero)</p>
<p>$cropx = ($newwidth &#8211; $scale != 0) ? ($newwidth &#8211; $scale) / 2 : 0;</p>
<p>$cropy = ($newheight &#8211; $scale != 0) ? ($newheight &#8211; $scale) / 2 : 0;</p>
<p>//&#8211; Setup Resample &amp; Crop buffers</p>
<p>$resampled = imagecreatetruecolor($newwidth, $newheight);</p>
<p>$cropped = imagecreatetruecolor($scale[0], $scale[0]);</p>
<p>//&#8211; Resample</p>
<p>imagecopyresampled($resampled, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);</p>
<p>//&#8211; Crop</p>
<p>imagecopy($cropped, $resampled, 0, 0, $cropx, $cropy, $newwidth, $newheight);</p>
<p>// Save the cropped image</p>
<p>switch($filetype)</p>
<p>{</p>
<p>case &#8220;jpeg&#8221;:</p>
<p>case &#8220;jpg&#8221;:</p>
<p>imagejpeg($cropped,$newFile,80);</p>
<p>break;</p>
<p>case &#8220;gif&#8221;:</p>
<p>imagegif($cropped,$newFile,80);</p>
<p>break;</p>
<p>case &#8220;png&#8221;:</p>
<p>imagepng($cropped,$newFile,80);</p>
<p>break;</p>
<p>}</p>
<p>}</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/213/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=213&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2009/08/22/make-square-image-for-landscape-and-portrait-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
		<item>
		<title>Resizing and Uploading Image in CakePHP</title>
		<link>http://inobject.wordpress.com/2009/08/21/resizing-and-uploading-image-in-cakephp/</link>
		<comments>http://inobject.wordpress.com/2009/08/21/resizing-and-uploading-image-in-cakephp/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 23:47:46 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/?p=211</guid>
		<description><![CDATA[I have spent many hours to see articles about resizing and uploading image in cakePHP, almost of them are sounding sucks for me like resizing on View by accessing or injecting the url or copy paste by another written without testing code. Event I was trying to convert AkImage from Akelos (Closer to ImageMagick in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=211&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have spent many hours to see articles about resizing and uploading image in cakePHP, almost of them are sounding sucks for me like resizing on View by accessing or injecting the url or copy paste by another written without testing code. Event I was trying to convert AkImage from Akelos (Closer to ImageMagick in Rails) but got bunch of errors.</p>
<p>Any way i got article from <a class="wp-caption" href="http://sabbour.wordpress.com/2008/05/13/image-upload-and-resize-component-for-cakephp-12/" target="_blank">sobbour</a> website, but  i am not satisfied with the code because the component automatically resize for big and thumb by 2 method directly, it will make bounced my hosting with trash image. And some lines were not realible any more with CakePHP, here is my modified Code (save it to /appName/controller/components/image.php)</p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">&lt;?php</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">class ImageComponent extends Object</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">var $contentType = array(&#8216;image/jpg&#8217;,'image/bmp&#8217;,'image/jpeg&#8217;,'image/gif&#8217;,'image/png&#8217;,'image/pjpg&#8217;,'image/pbmp&#8217;,'image/pjpeg&#8217;,'image/ppng&#8217;,'image/pgif&#8217;);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">function upload_image_and_thumbnail($fileData,$size,$subFolder,$prefix) {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">if (strlen($fileData['name'])&gt;4)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$error = 0;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$destFolder = WWW_ROOT.$subFolder;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$realFileName = $fileData['name'];</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>if(!is_dir($destFolder)) mkdir($destFolder,true);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> $filetype = $this-&gt;getFileExtension($fileData['name']);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$filetype = strtolower($filetype);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>if(!in_array($fileData['type'],$this-&gt;contentType)){</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>return false;exit();</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>else if($fileData['size'] &gt; 700000 ){</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>return false;exit();</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>else</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$imgsize = GetImageSize($fileData['tmp_name']);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> if (is_uploaded_file($fileData['tmp_name']))</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">if (!copy($fileData['tmp_name'],$destFolder.&#8217;/&#8217;.$realFileName ))</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> return false;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">exit();</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">else {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> $this-&gt;resize_img($destFolder.&#8217;/&#8217;.$realFileName, $size, $destFolder.&#8217;/&#8217;.$prefix.$realFileName);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> unlink($destFolder.&#8217;/&#8217;.$realFileName);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> }</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> }</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>return $fileData;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">function delete_image($filename)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">unlink($filename);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">function resize_img($tempFile, $size, $newFile)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$filetype = $this-&gt;getFileExtension($tempFile);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$filetype = strtolower($filetype);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">switch($filetype) {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>case &#8220;jpeg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>case &#8220;jpg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span>$img_src = imagecreatefromjpeg($tempFile);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span>break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>case &#8220;gif&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$img_src = imagecreatefromgif ($tempFile);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>case &#8220;png&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$img_src = imagecreatefrompng ($tempFile);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> case &#8220;bmp&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$img_src = imagecreatefromwbmp ($tempFile);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$true_width = imagesx($img_src);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$true_height = imagesy($img_src);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$size = explode(&#8216;x&#8217;,strtolower($size));</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">if ($true_width&gt;=$true_height)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> $width=$size[0];</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> $height = ($width/$true_width)*$true_height;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">else</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> $height=$size[1];</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> $width = ($height/$true_height)*$true_width;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>$img_des = imagecreatetruecolor($width,$height);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">imagecopyresampled ($img_des, $img_src, 0, 0, 0, 0, $width, $height, $true_width, $true_height);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">// Save the resized image</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">switch($filetype)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> case &#8220;jpeg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> case &#8220;jpg&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> imagejpeg($img_des,$newFile,80);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> case &#8220;gif&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span> imagegif($img_des,$newFile,80);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">case &#8220;png&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">imagepng($img_des,$newFile,80);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">case &#8220;bmp&#8221;:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">imagewbmp($img_des,$newFile,80);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">break;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">function getFileExtension($str)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;"><span style="white-space:pre;"> </span>{</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$i = strrpos($str,&#8221;.&#8221;);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">if (!$i) { return &#8220;&#8221;; }</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$l = strlen($str) &#8211; $i;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">$ext = substr($str,$i+1,$l);</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">return $ext;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">}</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:95px;width:1px;height:1px;">?&gt;</div>
<blockquote><p>&lt;?php</p>
<p>class ImageComponent extends Object</p>
<p>{</p>
<p>var $contentType = array(&#8216;image/jpg&#8217;,'image/bmp&#8217;,'image/jpeg&#8217;,'image/gif&#8217;,'image/png&#8217;,'image/pjpg&#8217;,'image/pbmp&#8217;,'image/pjpeg&#8217;,'image/ppng&#8217;,'image/pgif&#8217;);</p>
<p>function upload_image_and_thumbnail($fileData,$size,$subFolder,$prefix) {</p>
<p>if (strlen($fileData['name'])&gt;4)</p>
<p><span style="white-space:pre;"> </span> {</p>
<p><span style="white-space:pre;"> </span>$error = 0;</p>
<p><span style="white-space:pre;"> </span>$destFolder = WWW_ROOT.$subFolder;</p>
<p><span style="white-space:pre;"> </span>$realFileName = $fileData['name'];</p>
<p><span style="white-space:pre;"> </span>if(!is_dir($destFolder)) mkdir($destFolder,true);</p>
<p><span style="white-space:pre;"> </span> $filetype = $this-&gt;getFileExtension($fileData['name']);</p>
<p>$filetype = strtolower($filetype);</p>
<p><span style="white-space:pre;"> </span>if(!in_array($fileData['type'],$this-&gt;contentType)){</p>
<p><span style="white-space:pre;"> </span>return false;exit();</p>
<p><span style="white-space:pre;"> </span>}</p>
<p><span style="white-space:pre;"> </span>else if($fileData['size'] &gt; 700000 ){</p>
<p><span style="white-space:pre;"> </span>return false;exit();</p>
<p><span style="white-space:pre;"> </span>}</p>
<p><span style="white-space:pre;"> </span>else</p>
<p><span style="white-space:pre;"> </span>{</p>
<p><span style="white-space:pre;"> </span>$imgsize = GetImageSize($fileData['tmp_name']);</p>
<p><span style="white-space:pre;"> </span>}</p>
<p><span style="white-space:pre;"> </span> if (is_uploaded_file($fileData['tmp_name']))</p>
<p><span style="white-space:pre;"> </span> {</p>
<p>if (!copy($fileData['tmp_name'],$destFolder.&#8217;/&#8217;.$realFileName ))</p>
<p>{</p>
<p><span style="white-space:pre;"> </span> return false;</p>
<p>exit();</p>
<p>}</p>
<p>else {</p>
<p><span style="white-space:pre;"> </span> $this-&gt;resize_img($destFolder.&#8217;/&#8217;.$realFileName, $size, $destFolder.&#8217;/&#8217;.$prefix.$realFileName);</p>
<p><span style="white-space:pre;"> </span> unlink($destFolder.&#8217;/&#8217;.$realFileName);</p>
<p><span style="white-space:pre;"> </span> }</p>
<p><span style="white-space:pre;"> </span> }</p>
<p><span style="white-space:pre;"> </span>return $fileData;</p>
<p>}</p>
<p>}</p>
<p>function delete_image($filename)</p>
<p><span style="white-space:pre;"> </span>{</p>
<p>unlink($filename);</p>
<p>}</p>
<p>function resize_img($tempFile, $size, $newFile)</p>
<p><span style="white-space:pre;"> </span>{</p>
<p>$filetype = $this-&gt;getFileExtension($tempFile);</p>
<p>$filetype = strtolower($filetype);</p>
<p>switch($filetype) {</p>
<p><span style="white-space:pre;"> </span>case &#8220;jpeg&#8221;:</p>
<p><span style="white-space:pre;"> </span>case &#8220;jpg&#8221;:</p>
<p><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span>$img_src = imagecreatefromjpeg($tempFile);</p>
<p><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span>break;</p>
<p><span style="white-space:pre;"> </span>case &#8220;gif&#8221;:</p>
<p><span style="white-space:pre;"> </span>$img_src = imagecreatefromgif ($tempFile);</p>
<p><span style="white-space:pre;"> </span>break;</p>
<p><span style="white-space:pre;"> </span>case &#8220;png&#8221;:</p>
<p><span style="white-space:pre;"> </span>$img_src = imagecreatefrompng ($tempFile);</p>
<p><span style="white-space:pre;"> </span> case &#8220;bmp&#8221;:</p>
<p><span style="white-space:pre;"> </span>$img_src = imagecreatefromwbmp ($tempFile);</p>
<p><span style="white-space:pre;"> </span>break;</p>
<p>}</p>
<p>$true_width = imagesx($img_src);</p>
<p>$true_height = imagesy($img_src);</p>
<p><span style="white-space:pre;"> </span></p>
<p><span style="white-space:pre;"> </span>$size = explode(&#8216;x&#8217;,strtolower($size));</p>
<p>if ($true_width&gt;=$true_height)</p>
<p>{</p>
<p><span style="white-space:pre;"> </span> $width=$size[0];</p>
<p><span style="white-space:pre;"> </span> $height = ($width/$true_width)*$true_height;</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p><span style="white-space:pre;"> </span> $height=$size[1];</p>
<p><span style="white-space:pre;"> </span> $width = ($height/$true_height)*$true_width;</p>
<p>}</p>
<p><span style="white-space:pre;"> </span>$img_des = imagecreatetruecolor($width,$height);</p>
<p>imagecopyresampled ($img_des, $img_src, 0, 0, 0, 0, $width, $height, $true_width, $true_height);</p>
<p>// Save the resized image</p>
<p>switch($filetype)</p>
<p>{</p>
<p><span style="white-space:pre;"> </span> case &#8220;jpeg&#8221;:</p>
<p><span style="white-space:pre;"> </span> case &#8220;jpg&#8221;:</p>
<p><span style="white-space:pre;"> </span> imagejpeg($img_des,$newFile,80);</p>
<p><span style="white-space:pre;"> </span> break;</p>
<p><span style="white-space:pre;"> </span> case &#8220;gif&#8221;:</p>
<p><span style="white-space:pre;"> </span> imagegif($img_des,$newFile,80);</p>
<p>break;</p>
<p>case &#8220;png&#8221;:</p>
<p>imagepng($img_des,$newFile,80);</p>
<p>case &#8220;bmp&#8221;:</p>
<p>imagewbmp($img_des,$newFile,80);</p>
<p>break;</p>
<p>}</p>
<p>}</p>
<p>function getFileExtension($str)</p>
<p><span style="white-space:pre;"> </span>{</p>
<p>$i = strrpos($str,&#8221;.&#8221;);</p>
<p>if (!$i) { return &#8220;&#8221;; }</p>
<p>$l = strlen($str) &#8211; $i;</p>
<p>$ext = substr($str,$i+1,$l);</p>
<p>return $ext;</p>
<p>}</p>
<p>}</p>
<p>?&gt;</p></blockquote>
<div>And in your class instance method , run this line</div>
<div></div>
<blockquote>
<div>&lt;?php</div>
<div></div>
<div>class DeJavu extends Appcontroller {</div>
<div></div>
<div><span style="white-space:pre;"> </span>var $components = array(&#8220;Image&#8221;);</div>
<div></div>
<div>function add(){</div>
<div>&#8230;.any code&#8230;.</div>
<div>$this-&gt;Image-&gt;upload_image_and_thumbnail($this-&gt;data['Webinfo']['file'],&#8217;150&#215;150&#8242;,&#8217;img&#8217;,'logo_&#8217;);</div>
<div>&#8230;.any code&#8230;.</div>
<div>}</div>
<div></div>
<div>}</div>
<div>?&gt;</div>
</blockquote>
<div></div>
<div>now I am happy to see my app can resize image without annoying script any more. Good Luck for you too.</div>
<div></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/211/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=211&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2009/08/21/resizing-and-uploading-image-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
		<item>
		<title>Flex SharedObject using internet</title>
		<link>http://inobject.wordpress.com/2009/08/14/flex-sharedobject-using-internet/</link>
		<comments>http://inobject.wordpress.com/2009/08/14/flex-sharedobject-using-internet/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 18:50:13 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/?p=204</guid>
		<description><![CDATA[A few days ago i have problem how to implement my live streaming using SharedObject in Red5 because usually SharedObject, as i know, only good implementable for local only (like getting or store cookies), before implemented to my live streaming application, i created simple chat application to remote SharedObject : &#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&#62; &#60;mx:Application xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=204&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few days ago i have problem how to implement my live streaming using SharedObject in Red5 because usually SharedObject, as i know, only good implementable for local only (like getting or store cookies), before implemented to my live streaming application, i created simple chat application to remote SharedObject  :</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;mx:Application xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221; layout=&#8221;absolute&#8221; creationComplete=&#8221;creationComplete()&#8221;&gt;<br />
&lt;mx:Script source=&#8221;streaming.as&#8221;/&gt;<br />
&lt;mx:TextInput x=&#8221;10&#8243; y=&#8221;10&#8243; id=&#8221;rtmpUrl&#8221; text=&#8221;your rtmp address&#8221;/&gt;<br />
&lt;mx:Button x=&#8221;216&#8243; y=&#8221;10&#8243; id=&#8221;connectBtn&#8221;/&gt;<br />
&lt;mx:TextInput x=&#8221;10&#8243; y=&#8221;269&#8243; id=&#8221;enterMsg&#8221; /&gt;<br />
&lt;mx:TextArea x=&#8221;10&#8243; y=&#8221;40&#8243; height=&#8221;221&#8243; id=&#8221;msgBoard&#8221; width=&#8221;222&#8243; /&gt;<br />
&lt;mx:Button x=&#8221;178&#8243; y=&#8221;269&#8243; id=&#8221;sendBtn&#8221;/&gt;<br />
&lt;/mx:Application&gt;</p></blockquote>
<p>And now let create streaming.as script :</p>
<blockquote><p>import flash.events.MouseEvent;<br />
import flash.events.NetStatusEvent;<br />
import flash.events.SyncEvent;<br />
import flash.net.NetConnection;<br />
import flash.net.NetStream;<br />
import flash.net.SharedObject;</p>
<p>import mx.controls.Alert;</p>
<p>public var NetCont:NetConnection;<br />
public var NetStrem:NetStream<br />
public var SharObj:SharedObject;</p>
<p>public function creationComplete():void{<br />
connectBtn.label = &#8220;Connect&#8221;;<br />
connectBtn.addEventListener(MouseEvent.CLICK, ConnectServer);</p>
<p>sendBtn.label = &#8220;Send&#8221;;<br />
sendBtn.addEventListener(MouseEvent.CLICK, SendChat);<br />
}</p>
<p>public function ConnectServer(event:MouseEvent):void{<br />
NetCont = new NetConnection();<br />
NetCont.client = new NetConnectionClient;<br />
NetCont.connect(rtmpUrl.text);<br />
NetCont.addEventListener(NetStatusEvent.NET_STATUS, createSharedObject);<br />
}</p>
<p><strong>public function createSharedObject(event:NetStatusEvent):void{</strong></p>
<p><strong>if(NetCont.connected</strong><strong>){<br />
SharObj = SharedObject.getRemote(&#8220;SampleMessage&#8221;,NetCont.uri,false,false);<br />
SharObj.connect(NetCont);<br />
SharObj.addEventListener(SyncEvent.SYNC, SharObjView);</strong></p>
<p><strong>}else{</strong></p>
<p><strong> Alert.show(&#8216;Unable to Connect Internet or Rtmp Address&#8217;);<br />
</strong></p>
<p><strong>}<br />
}</strong></p>
<p>public function SharObjView(event:SyncEvent):void{<br />
msgBoard.htmlText += SharObj.data['SampleMessage']+&#8221;&lt;br&gt;&#8221;;</p>
<p>}</p>
<p>public function SendChat(event:MouseEvent):void{<br />
<strong>SharObj.setProperty</strong>(&#8220;SampleMessage&#8221;,enterMsg.text);<br />
}</p></blockquote>
<p>There are 2 optional for using SharedObject in ActionScript specially for flex <span><span><span><span>Share</span>d</span></span><span><span>Object</span>.getLocal()</span></span> method or the  <span><span><span><span>Share</span>d</span></span><span><span>Object</span>.getRemote()</span></span></p>
<p>What we use for internet connection is using getRemote. And here is code for next connection client :</p>
<blockquote><p>package<br />
{<br />
public class NetConnectionClient<br />
{<br />
public function NetConnectionClient()<br />
{<br />
}<br />
public function onBWDone(&#8230; rest):void<br />
{</p>
<p>}<br />
public function onBWCheck(&#8230; rest):uint<br />
{<br />
//have to return something, so returning anything <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
return 0;<br />
}</p>
<p>public function onMetaData(info:Object):void {<br />
trace(&#8220;metadata: duration=&#8221; + info.duration + &#8221; width=&#8221; + info.width + &#8221; height=&#8221; + info.height + &#8221; framerate=&#8221; + info.framerate);<br />
}<br />
}<br />
}</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/204/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=204&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2009/08/14/flex-sharedobject-using-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
		<item>
		<title>Javascript Helper For Antispam Email</title>
		<link>http://inobject.wordpress.com/2009/08/14/javascript-helper-for-antispam-email/</link>
		<comments>http://inobject.wordpress.com/2009/08/14/javascript-helper-for-antispam-email/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 18:29:38 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/?p=198</guid>
		<description><![CDATA[In your view : &#60;%= js_antispam_email_link(&#8216;username@domain.com&#8217;) %&#62; Code for your helper # Takes in an email address and (optionally) anchor text, # its purpose is to obfuscate email addresses so spiders and # spammers can&#8217;t harvest them. def js_antispam_email_link(email, linktext=email) user, domain = email.split(&#8216;@&#8217;) user = html_obfuscate(user) domain = html_obfuscate(domain) # if linktext wasn&#8217;t specified, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=198&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In your view : &lt;%= js_antispam_email_link(&#8216;username@domain.com&#8217;) %&gt;</p>
<p>Code for your helper</p>
<blockquote><p># Takes in an email address and (optionally) anchor text,<br />
# its purpose is to obfuscate email addresses so spiders and<br />
# spammers can&#8217;t harvest them.<br />
def js_antispam_email_link(email, linktext=email)<br />
user, domain = email.split(&#8216;@&#8217;)<br />
user   = html_obfuscate(user)<br />
domain = html_obfuscate(domain)<br />
# if linktext wasn&#8217;t specified, throw encoded email address builder into js document.write statement<br />
linktext = &#8220;&#8216;+&#8217;#{user}&#8217;+'@&#8217;+'#{domain}&#8217;+'&#8221; if linktext == email<br />
rot13_encoded_email = rot13(email) # obfuscate email address as rot13<br />
out =  &#8220;#{linktext}&amp;lt;br/&amp;gt;&amp;lt;small&amp;gt;#{user}(at)#{domain}&amp;lt;/small&amp;gt;\n&#8221; # js disabled browsers see this<br />
out += &#8220;// &lt;![CDATA[<br />
\n"<br />
out += "  \n"<br />
out += "    string = '#{rot13_encoded_email}'.replace(/[a-zA-Z]/g, function(c){ return String.fromCharCode((c = (c = c.charCodeAt(0) + 13) ? c : c &#8211; 26);});\n&#8221;<br />
out += &#8221;    document.write(&#8216;#{linktext}&#8217;); \n&#8221;<br />
out += &#8221;  //\n&#8221;<br />
out += &#8220;<br />
// &#8211;&gt;<br />
// ]]&gt;\n&#8221;<br />
return out<br />
end</p>
<p>private<br />
# Rot13 encodes a string<br />
def rot13(string)<br />
string.tr &#8220;A-Za-z&#8221;, &#8220;N-ZA-Mn-za-m&#8221;<br />
end</p>
<p># HTML encodes ASCII chars a-z, useful for obfuscating<br />
# an email address from spiders and spammers<br />
def html_obfuscate(string)<br />
output_array = []<br />
lower = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)<br />
upper = %w(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)<br />
char_array = string.split(&#8221;)<br />
char_array.each do |char|<br />
output = lower.index(char) + 97 if lower.include?(char)<br />
output = upper.index(char) + 65 if upper.include?(char)<br />
if output<br />
output_array &lt;&lt; &#8220;&amp;##{output};&#8221;<br />
else<br />
output_array &lt;&lt; char<br />
end<br />
end<br />
return output_array.join<br />
end</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/198/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=198&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2009/08/14/javascript-helper-for-antispam-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
		<item>
		<title>IF-ELSE in SQL Query</title>
		<link>http://inobject.wordpress.com/2009/08/14/if-else-in-sql-query/</link>
		<comments>http://inobject.wordpress.com/2009/08/14/if-else-in-sql-query/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 18:17:38 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SQL - Database]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/?p=194</guid>
		<description><![CDATA[Example user has many addresses, but part of users have not address. If we want list 1000 users including number of their address, do not count address in View (MVC-Rails) : users.address.size, that will give us 1001 query. How to count for 1 query only ? SELECT *, COUNT(addresses.id) AS jumlah_address FROM users LEFT OUTER [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=194&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Example user has many addresses, but part of users have not address. If we want list 1000 users including number of their address, do not count address in View (MVC-Rails) : users.address.size, that will give us 1001 query. How to count for 1 query only ?</p>
<blockquote><p>SELECT *, COUNT(<a href="http://addresses.id/" target="_blank">addresses.id</a>) AS jumlah_address<br />
FROM users LEFT OUTER JOIN addresses ON addresses.user_id = <a href="http://users.id/" target="_blank">users.id</a><br />
GROUP BY <a href="http://users.id/" target="_blank">users.id</a></p></blockquote>
<p>Is that you will do ? it will give you result = 1, it should be 0. So, let look to query below :</p>
<blockquote><p>SELECT *, IF(<a href="http://addresses.id/" target="_blank">addresses.id</a> IS NULL, 0, COUNT(<a href="http://addresses.id/" target="_blank">addresses.id</a>)) AS jumlah_address<br />
FROM users LEFT OUTER JOIN addresses ON addresses.user_id = <a href="http://users.id/" target="_blank">users.id</a><br />
GROUP BY <a href="http://users.id/" target="_blank">users.id</a></p></blockquote>
<p>For More complex sorting and case :</p>
<p>example if user want sort based on city name then user name, but if Jakarta and Bandung are sorted at the top before other cities alphabetically. Here&#8217;s the way:</p>
<blockquote><p>SELECT *, IF(city == &#8216;Jakarta&#8217;, 0, IF(city == &#8216;Bandung&#8217;, 1, 2)) AS city_index<br />
FROM users LEFT OUTER JOIN addresses ON addresses.user_id = <a href="http://users.id/" target="_blank">users.id</a><br />
GROUP BY <a href="http://users.id/" target="_blank">users.id</a><br />
ORDER BY city_index ASC, city ASC</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=194&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2009/08/14/if-else-in-sql-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
		<item>
		<title>Track Total Coverage of Your Test Unit Code with RCOV</title>
		<link>http://inobject.wordpress.com/2009/08/07/track-total-coverage-of-your-test-unit-code-with-rcov/</link>
		<comments>http://inobject.wordpress.com/2009/08/07/track-total-coverage-of-your-test-unit-code-with-rcov/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 13:47:00 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/2009/08/07/track-total-coverage-of-your-test-unit-code-with-rcov</guid>
		<description><![CDATA[Hi All : I just want share my testing with Ruby coverage code or Rcov. It is fun (for me, dont know for others) playing with Rcov report, i think it is like bugs tracking but i dont know other people called it or maybe it is like tool to coverage test your application codes. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=64&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi All :</p>
<p>I just want share my testing with Ruby coverage code or Rcov. It is fun (for me, dont know for others) playing with Rcov report, i think it is like bugs tracking but i dont know other people called it or maybe it is like tool to coverage test your application codes.</p>
<p>First think you have to do is installing the gem :</p>
<p><b>gem install rcov</b></p>
<p>and then write simple code to run it as rake then save it in your_app/lib/tasks :</p>
<p><i></i><br />
<blockquote><i>require &#8216;rcov/rcovtask&#8217;</p>
<p>namespace :test do<br />namespace :coverage do</p>
<p>desc &#8220;Delete aggregate coverage data.&#8221;</p>
<p>task(:clean) { rm_f &#8220;coverage.data&#8221; }<br />end</p>
<p>desc &#8216;Aggregate code coverage for unit, functional and integration tests&#8217;</p>
<p>  task :coverage =&gt; &#8220;test:coverage:clean&#8221;</p>
<p>    %w[unit functional integration].each do |target|</p>
<p>    namespace :coverage do</p>
<p>      Rcov::RcovTask.new(target) do |t|<br /></i>
<div style="margin-left:40px;color:rgb(51,51,51);"><i>       t.libs &lt;&lt; &quot;test&quot;</i><br /><i>       t.test_files = FileList["test/#{target}/*_test.rb"]</i><br /><i>       t.output_dir = File.dirname(__FILE__)+&#8221;/report_rcov/#{target}&#8221;</i><br /><i>       t.verbose = true</i><br /><i>       t.rcov_opts &lt;&lt; &#39;&#8211;rails &#8211;aggregate coverage.data&#39;</i></div>
<p><i><span style="color:rgb(51,51,51);">       end</span><br /><span style="color:rgb(51,51,51);">    end</span></p>
<p><span style="color:rgb(51,51,51);">      task :coverage =&gt; &#8220;test:coverage:#{target}&#8221;</span></p>
<p><span style="color:rgb(51,51,51);">   end</span></p>
<p><span style="color:rgb(51,51,51);">       system(&#8221; \&#8221;C:/Program Files/Mozilla Firefox/firefox.exe\&#8221; &#8221; +</span><br /><span style="color:rgb(51,51,51);">               &#8220;file:///&#8221;+File.dirname(__FILE__)+&#8221;/report_rcov/unit/index.html&#8221;)</span><br /><span style="color:rgb(51,51,51);">                </span><br /><span style="color:rgb(51,51,51);"> end</span><br /></i>   </p>
<p>Absolutly i am using windows if you are using another OS not windows you could change the 4th line from bottom to :</p>
<p><i>    system(open File.dirname(__FILE__)+&#8221;/report_rcov/unit/index.html&#8221;</i>)</p></blockquote>
<p>Open your shell or CMD then execute <b>rake test:coverage</b> or open <b>rake -T</b></p>
<p><i></i><br />
<blockquote><i>rake test:coverage                      # Aggregate code coverage for unit,&#8230;<br />rake test:coverage:clean                # Delete aggregate coverage data.<br />  rake test:coverage:clobber_functional   # Remove rcov products for functional<br />rake test:coverage:clobber_integration  # Remove rcov products for integration<br />rake test:coverage:clobber_unit         # Remove rcov products for unit<br />  rake test:coverage:functional           # Analyze code coverage with tests &#8230;<br />rake test:coverage:integration          # Analyze code coverage with tests &#8230;<br />rake test:coverage:unit                 # Analyze code coverage with tests &#8230;</i></p></blockquote>
<p>Here I attached sample report from rcov. I hope this written can be useful for you gentleman and ladies.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=64&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2009/08/07/track-total-coverage-of-your-test-unit-code-with-rcov/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
		<item>
		<title>How to use find_by_sql without Model</title>
		<link>http://inobject.wordpress.com/2008/05/31/how-to-use-find_by_sql-without-model/</link>
		<comments>http://inobject.wordpress.com/2008/05/31/how-to-use-find_by_sql-without-model/#comments</comments>
		<pubDate>Sat, 31 May 2008 04:05:00 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/2008/05/31/how-to-use-find_by_sql-without-model</guid>
		<description><![CDATA[many cases, we use model to use find_by_sql like ModelName.find_by_sql, but now how we can find_by_sql without mode? ActiveRecord::Base.connection.execute &#8216;select * from users&#8217; To return array of hashes, you can use it : ActiveRecord::Base.connection.select_all .<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=61&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>many cases, we use model to use find_by_sql like ModelName.find_by_sql, but now how we can find_by_sql without mode?</p>
<blockquote><p>ActiveRecord::Base.connection.execute &#8216;select * from users&#8217;</p>
</blockquote>
<p>To return array of hashes, you can use it :</p>
<blockquote><p>ActiveRecord::Base.connection.select_all</p>
</blockquote>
<p>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/inobject.wordpress.com/61/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/inobject.wordpress.com/61/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=61&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2008/05/31/how-to-use-find_by_sql-without-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
		<item>
		<title>Translation for your Ruby on Rails App</title>
		<link>http://inobject.wordpress.com/2008/05/21/translation-for-your-ruby-on-rails-app/</link>
		<comments>http://inobject.wordpress.com/2008/05/21/translation-for-your-ruby-on-rails-app/#comments</comments>
		<pubDate>Wed, 21 May 2008 18:24:00 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/2008/05/21/translation-for-your-ruby-on-rails-app</guid>
		<description><![CDATA[I am writing this article with accompanied by a cup of coffee while waiting MU Vs Chealsea for Champion Final. Back to the topic. You should know many familiar online translation like google and altavista. Now i will like to introduce you about gibberish in rails. Let start it : Install the plugin to your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=59&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><a href="http://bp3.blogger.com/_syu-nNS58F8/SDRuxq7ntLI/AAAAAAAAAF4/6xCItR9SK-g/s1600-h/gibberish_rails.png"><img src="http://bp3.blogger.com/_syu-nNS58F8/SDRuxq7ntLI/AAAAAAAAAF4/6xCItR9SK-g/s320/gibberish_rails.png" alt="" border="0" /></a></p>
</div>
<p>I am writing this article with accompanied by a cup of coffee while waiting MU Vs Chealsea for Champion Final. Back to the topic. You should know many familiar online translation like google and altavista. Now i will like to introduce you about <a href="http://svn.myutil.com/projects/plugins/gibberish_rails/README">gibberish</a> in rails. Let start it :</p>
<ul>
<li>Install the plugin to your app rails.</li>
</ul>
<blockquote><p>ruby script/plugin install http://svn.myutil.com/projects/plugins/gibberish_rails/<br />or<br />ruby script/plugin install svn://errtheblog.com/svn/plugins/gibberish</p></blockquote>
<ul>
<li>After that go to your Application_controller.rb then use arround_filter for implementation of gibberish :</li>
</ul>
<blockquote><p>class ApplicationController &lt; ActionController::Base<br />around_filter :set_language</p>
<p>private<br />def set_language<br />Gibberish.use_language(session[:language]) { yield }<br />end<br />end</p></blockquote>
<ul>
<li>Another method is described in <a href="http://svn.myutil.com/projects/plugins/gibberish_rails/README">README</a> file. Like :</li>
</ul>
<blockquote><p>  class ApplicationController &lt; ActionController::Base<br /> around_filter :use_best_guess_locale</p>
<p>private<br /> def use_best_guess_locale<br />   session[:locale] = GibberishRails.best_guess_locale(params[:locale], request.env['HTTP_ACCEPT_LANGUAGE']) if ( ! session[:locale] || params[:locale] || RAILS_ENV == &#8216;development&#8217; )</p>
<p>   Gibberish.use_language(session[:locale]) {yield}<br /> end<br />end</p></blockquote>
<ul>
<li>To create new dictionary, you can create it in YAML file such as es.yaml :</li>
</ul>
<blockquote><p>welcome_friend: ¡Recepción, amigo!<br />welcome_user: ¡Recepción, {user}!<br />love_rails: Amo los carriles.</p>
</blockquote>
<ul>
<li>Need more information &amp; interaction ? <a href="http://errtheblog.com/posts/55-ya-talkin-gibberish">Browse here</a></li>
</ul>
<p>_</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/inobject.wordpress.com/59/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/inobject.wordpress.com/59/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=59&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2008/05/21/translation-for-your-ruby-on-rails-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>

		<media:content url="http://bp3.blogger.com/_syu-nNS58F8/SDRuxq7ntLI/AAAAAAAAAF4/6xCItR9SK-g/s320/gibberish_rails.png" medium="image" />
	</item>
		<item>
		<title>Simple &amp; Awesome Rails Form</title>
		<link>http://inobject.wordpress.com/2008/05/20/simple-awesome-rails-form/</link>
		<comments>http://inobject.wordpress.com/2008/05/20/simple-awesome-rails-form/#comments</comments>
		<pubDate>Tue, 20 May 2008 04:38:00 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/2008/05/20/simple-awesome-rails-form</guid>
		<description><![CDATA[How to create Simple, fast and awesome rails form in your rhtml or html.erb ? the answer for now is Super_In_Place_Controls &#38; I tested in Rails 2.0. Let start to use it : Install the plugin to your ruby app ruby script/plugin install http://os.flvorful.com/svn/plugins/super_in_place_controls In your layout or rhtml / html.erb put it : &#60;%= [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=58&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>How to create Simple, fast and awesome  rails form in your rhtml or html.erb ? the answer for now is Super_In_Place_Controls &amp; I tested in Rails 2.0. Let start to use it :</p>
<ul>
<li>Install the plugin to your ruby app</li>
</ul>
<blockquote><p>ruby script/plugin install http://os.flvorful.com/svn/plugins/super_in_place_controls</p>
</blockquote>
<ul>
<li>In your layout or rhtml / html.erb put it :</li>
</ul>
<blockquote><p>&lt;%= stylesheet_link_tag &#8216;in_place_styles&#8217; %&gt;</p>
</blockquote>
<ul>
<li>Done !!, let start to implement it in your view file (click the image below to enlarge).</li>
</ul>
<ul>
<li>For regular text_field you can change it to be :</li>
</ul>
<div style="text-align:center;"><a href="http://bp2.blogger.com/_syu-nNS58F8/SDJg567ntFI/AAAAAAAAAFI/-HsqGxfezXE/s1600-h/Untitled-3.jpg"><img src="http://bp2.blogger.com/_syu-nNS58F8/SDJg567ntFI/AAAAAAAAAFI/-HsqGxfezXE/s320/Untitled-3.jpg" alt="" border="0" /></a>    </div>
<blockquote><p>in_place_text_field :product, :title</p>
</blockquote>
<blockquote></blockquote>
<ul>
<li>For regular text_area, you can change it to be :</li>
</ul>
<div style="text-align:center;"><a href="http://bp3.blogger.com/_syu-nNS58F8/SDJg6K7ntGI/AAAAAAAAAFQ/95peBawENZc/s1600-h/Untitled-4.jpg"><img src="http://bp3.blogger.com/_syu-nNS58F8/SDJg6K7ntGI/AAAAAAAAAFQ/95peBawENZc/s320/Untitled-4.jpg" alt="" border="0" /></a></div>
<blockquote><p>in_place_text_area :product, :description</p>
</blockquote>
<blockquote></blockquote>
<ul>
<li>For regular  select_tag, you can change it to be:</li>
</ul>
<div style="text-align:center;"><a href="http://bp3.blogger.com/_syu-nNS58F8/SDJg6K7ntHI/AAAAAAAAAFY/RoFbFk8pfbA/s1600-h/Untitled-5.jpg"><img src="http://bp3.blogger.com/_syu-nNS58F8/SDJg6K7ntHI/AAAAAAAAAFY/RoFbFk8pfbA/s320/Untitled-5.jpg" alt="" border="0" /></a></div>
<blockquote><p>in_place_select :product, :product_type, :choices =&gt; %w(Awesomeness Coolness Phatness RubyBliss).map { |e| [e, e] }</p>
</blockquote>
<ul>
<li>For regular radio_collection, you can change it to be :</li>
</ul>
<div style="text-align:center;"><a href="http://bp0.blogger.com/_syu-nNS58F8/SDJg6a7ntII/AAAAAAAAAFg/joHQXpE56vQ/s1600-h/Untitled-6.jpg"><img src="http://bp0.blogger.com/_syu-nNS58F8/SDJg6a7ntII/AAAAAAAAAFg/joHQXpE56vQ/s320/Untitled-6.jpg" alt="" border="0" /></a></div>
<blockquote><p>in_place_radio :product, :price, :choices =&gt; %w(199 299 399 499 599 699 799 899 999).map { |e| [e, e] }</p>
</blockquote>
<ul>
<li>For check box collection you can change it to be:</li>
</ul>
<div style="text-align:center;"><a href="http://bp3.blogger.com/_syu-nNS58F8/SDJhMK7ntJI/AAAAAAAAAFo/td5_88qXnJE/s1600-h/Untitled-7.jpg"><img src="http://bp3.blogger.com/_syu-nNS58F8/SDJhMK7ntJI/AAAAAAAAAFo/td5_88qXnJE/s320/Untitled-7.jpg" alt="" border="0" /></a></div>
<blockquote><p>in_place_check_box :product, :category_ids, :choices =&gt; Category.find(:all).map { |e| [e.id, e.title] }, :display_text =&gt; :collection</p>
</blockquote>
<ul>
<li>And for date you can change to be :</li>
</ul>
<div style="text-align:center;"><a href="http://bp2.blogger.com/_syu-nNS58F8/SDJh067ntKI/AAAAAAAAAFw/LB8XApWM6vU/s1600-h/Untitled-8.jpg"><img src="http://bp2.blogger.com/_syu-nNS58F8/SDJh067ntKI/AAAAAAAAAFw/LB8XApWM6vU/s320/Untitled-8.jpg" alt="" border="0" /></a></div>
<blockquote><p>in_place_date_select :product, :display_begin</p>
</blockquote>
<ul>
<li>for more style you can add<code>calendar_date_select_includes "blue"</code> to the pages you want to use the calendar select on. The other styles for the calendar_date_select are &#8220;blue&#8221;, &#8220;plain&#8221;, &#8220;red&#8221;, &#8220;silver&#8221;, &#8220;default&#8221;.</li>
</ul>
<ul>
<li>Online Demo : <a href="http://os.flvorful.com/super_in_place_controls/demo"><span style="font-weight:bold;color:rgb(51,51,153);">DEMO</span></a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/inobject.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/inobject.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=58&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2008/05/20/simple-awesome-rails-form/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>

		<media:content url="http://bp2.blogger.com/_syu-nNS58F8/SDJg567ntFI/AAAAAAAAAFI/-HsqGxfezXE/s320/Untitled-3.jpg" medium="image" />

		<media:content url="http://bp3.blogger.com/_syu-nNS58F8/SDJg6K7ntGI/AAAAAAAAAFQ/95peBawENZc/s320/Untitled-4.jpg" medium="image" />

		<media:content url="http://bp3.blogger.com/_syu-nNS58F8/SDJg6K7ntHI/AAAAAAAAAFY/RoFbFk8pfbA/s320/Untitled-5.jpg" medium="image" />

		<media:content url="http://bp0.blogger.com/_syu-nNS58F8/SDJg6a7ntII/AAAAAAAAAFg/joHQXpE56vQ/s320/Untitled-6.jpg" medium="image" />

		<media:content url="http://bp3.blogger.com/_syu-nNS58F8/SDJhMK7ntJI/AAAAAAAAAFo/td5_88qXnJE/s320/Untitled-7.jpg" medium="image" />

		<media:content url="http://bp2.blogger.com/_syu-nNS58F8/SDJh067ntKI/AAAAAAAAAFw/LB8XApWM6vU/s320/Untitled-8.jpg" medium="image" />
	</item>
		<item>
		<title>Create Realtime World News in Your Site</title>
		<link>http://inobject.wordpress.com/2008/05/18/create-realtime-world-news-in-your-site/</link>
		<comments>http://inobject.wordpress.com/2008/05/18/create-realtime-world-news-in-your-site/#comments</comments>
		<pubDate>Sun, 18 May 2008 18:55:00 +0000</pubDate>
		<dc:creator>inobject</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://inobject.wordpress.com/2008/05/18/create-realtime-world-news-in-your-site</guid>
		<description><![CDATA[What could you do if you had access to the world’s news, and had a standardized and rational way to get quick responses to rich queries about what’s happening in the world? What could you build if you could incorporate dynamic, global, continually refreshed, high quality content into your applications, widgets, and websites? You should [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=57&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What could you do if you had access to the world’s news, and had a standardized and rational way to get quick responses to rich queries about what’s happening in the world? What could you build if you could incorporate dynamic, global, continually refreshed, high quality content into your applications, widgets, and websites? You should have many answers. But I have only 1 act, I will smileproudly. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Let&#8217;s start to implement it by using Ruby on Rails:</p>
<ul>
<li>Get API Key <a href="http://developer.daylife.com/member/register"><span style="font-weight:bold;color:rgb(51,51,153);">HERE</span></a></li>
</ul>
<ul>
<li>Download <a style="color:rgb(51,51,153);" href="http://www.conorhunt.com/code/daylife.rb"><span style="font-weight:bold;">this code</span></a> and paste it to your app_name/lib folder</li>
</ul>
<ul>
<li>Then in your controller, put it :</li>
</ul>
<blockquote><p>require &#8216;daylife&#8217;<br />a = Daylife::API.new(&#8216;your api key&#8217;,'sharedsecret&#8217;)<br />r = a.execute(&#8216;search&#8217;,'getRelatedArticles&#8217;, :query =&gt; &#8216;sam adams&#8217;, :limit =&gt; 5)<br />if(r.success?)<br />r.articles.each {|a| puts a.headline }<br />puts r.articles[1].source.daylife_url<br />else<br /> # output the error message<br /> puts &#8220;Error: #{r.code}: #{r.message}&#8221;<br />end</p></blockquote>
<ul>
<li>Now your dream comes true to have site like Yahoo News or at least like daylife.com</li>
</ul>
<ul>
<li>What else can you do with this dayAPI? <a style="color:rgb(51,51,153);" href="http://cookbook.daylife.com/FAQ"><span style="font-weight:bold;">Read More Here</span></a></li>
</ul>
<ul>
<li>Has been tested and working nice <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/inobject.wordpress.com/57/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/inobject.wordpress.com/57/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/inobject.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/inobject.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/inobject.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/inobject.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/inobject.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/inobject.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/inobject.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/inobject.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/inobject.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/inobject.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/inobject.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/inobject.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/inobject.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/inobject.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=inobject.wordpress.com&amp;blog=9007164&amp;post=57&amp;subd=inobject&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://inobject.wordpress.com/2008/05/18/create-realtime-world-news-in-your-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7833d73d992903f1f66bb155cee88754?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">inobject</media:title>
		</media:content>
	</item>
	</channel>
</rss>
