<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Amoeba Solution Kiosk</title>
	<atom:link href="http://ask.amoeba.co.in/feed/" rel="self" type="application/rss+xml" />
	<link>http://ask.amoeba.co.in</link>
	<description>Providing solutions for PHP, MySQL, Flash, Flex, Action Script, Javascript, YUI, JQuery, CSS, XHTML problems.</description>
	<lastBuildDate>Wed, 01 Sep 2010 16:02:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Protect your SWF (AS2 or AS3). Prevent SWF Decompile using SWF Protector</title>
		<link>http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/</link>
		<comments>http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 16:01:04 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[Flash & Action Script]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[action script]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[dcomsoft]]></category>
		<category><![CDATA[decomipler]]></category>
		<category><![CDATA[decompile]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[obfuscate]]></category>
		<category><![CDATA[obfuscation]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[protection]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[sothink]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[swfprotector]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=150</guid>
		<description><![CDATA[Being a flash programmer, I have always had this concern. The way a flash application works differs from a php application. We don’t really need to worry about protecting the PHP code because the code is interpreted in the server and only the html codes are sent to the client browser. But a Flash engine basically lies in the user browser and the AS2 or AS3 codes are rendered in the user Browser. Though a Flash application is compiled in to a compact SWF file which is served to the user, this file contains all the codes we have written, thus making it easy for hackers or other developers to steal codes from our SWF application. And the Actionscript code is the most important part of any Flash/Flex application.]]></description>
			<content:encoded><![CDATA[<p>Being a flash programmer, I have always had this concern. The way a flash application works differs from a php application. We don’t really need to worry about protecting the PHP code because the code is interpreted in the server and only the html codes are sent to the client browser. But a Flash engine basically lies in the user browser and the AS2 or AS3 codes are rendered in the user Browser. Though a Flash application is compiled in to a compact SWF file which is served to the user, this file contains all the codes we have written, thus making it easy for hackers or other developers to steal codes from our SWF application. And the Actionscript code is the most important part of any Flash/Flex application.</p>
<p>I normally share codes I write with the developer community. But there are occasions when I don’t want others to see the source code of my application. This could be when I have concerns over the security of my application or when it is a proprietary application built for a customer.  But unfortunately stealing the source code of a Flash SWF application is very easy. With reverse engineering technologies gaining popularity day by day among the Flash development communities, protecting the Actionscript code is a big problem. There are plenty of SWF decompilers like Sothink available in the market making it easy for anyone to decompile an SWF file fetched from a browser and see the whole source code written for the application.</p>
<p>This is when we need to really think about code security and protecting our source codes from being stolen. There are some flash protector applications available and I tried SWF Protector from DComSoft. It works out really well. The application is available for Windows, Mac and Linux. Protecting an SWF application using the SWF Protector is really easy. Add your SWF files to the SWF Protector and click on the Protect All button. The SWF Protector uses different algorithms for AS2 and AS3 versions. For AS2, it uses “Mix Script” and “Mask Script” methods which basically mix up functions, arguments and variables names, so it becomes difficult for understanding after de-compilation. For AS3, the code can be “Protected” which modifies the scripts in such way that SWF files can play in Flash player, but cannot be decompiled, or “Obfuscated” which renames variable and other objects in the code making it impossible to compile the code further.</p>
<p>There is another method to protect your SWF code without using any application. That is by creating a loader SWF which will embed the actual SWF as a byteArray and it can be loaded using  Loader.loadBytes().</p>
<p>When someone tries to decomplile an SWF file which is protected using SWF Protector the code would look something like this.</p>
<pre class="brush: as3;">
do {
// unexpected jump
} while (true);
// swfAction0xAD hexdata 0x52,0x17,0x99,0x02,0x00,0x39,0x00,0x9A,0x01,0x00,0x00,0x99... // Unknown action
}
&quot;holder1&quot;.holder1.loadMovie();
// unexpected jump
/* Error1016 */
// unexpected jump
do {
(this);// not popped
if (true) {
// unexpected jump
} while (this);
(this);// not popped
// unexpected jump
}
}
}
Set(&quot;\x0B\x1A\x13\x16&quot;, true);
} while (true);
</pre>
<p>Now you say, would this be useful for someone? No, of course!</p>
<p>The SWF Protector is not free but comes with a small price tag. But it’s more than worth the money you pay and better than concerning over the security of your code. You can get more information or buy this tool from <a href="http://www.dcomsoft.com/" target="_blank">http://www.dcomsoft.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Search in an Array for Values Matching a Pattern &#8211; Regex, Wildcard</title>
		<link>http://ask.amoeba.co.in/php-search-in-an-array-for-values-matching-a-pattern-regex-wildcard/</link>
		<comments>http://ask.amoeba.co.in/php-search-in-an-array-for-values-matching-a-pattern-regex-wildcard/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 14:22:13 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array_search]]></category>
		<category><![CDATA[in_array]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[preg_grep]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[search in array]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=140</guid>
		<description><![CDATA[I have an array with many values and I need to do a search to find all the values that match a pattern. We have functions like in_array &#38; array_search in PHP, but these functions basically try to match the exact needle value in the array. I need to use my Regular Expression Pattern and [...]]]></description>
			<content:encoded><![CDATA[<p>I have an array with many values and I need to do a search to find all the values that match a pattern. We have functions like <strong>in_array</strong> &amp; <strong>array_search</strong> in PHP, but these functions basically try to match the exact needle value in the array. I need to use my <strong>Regular Expression Pattern</strong> and find all the array values that match the regex pattern.</p>
<p>The PHP function <strong>preg_grep</strong> handles this beautifully. It accepts the <strong>Regex </strong>pattern and the array to search for as its parameters. It then returns the array consisting of the elements of the input array that match the given pattern. The returned array is indexed using the keys from the input array.</p>
<p>Here is my array:<br />
Array<br />
(<br />
[0] =&gt; Armenia<br />
[1] =&gt; America<br />
[2] =&gt; Algeria<br />
[3] =&gt; India<br />
[4] =&gt; Brazil<br />
[5] =&gt; Croatia<br />
[6] =&gt; Denmark<br />
)<br />
I want to find all the countries in the array which start with the letter &#8216;A&#8217;. We need to form a regular expression which will match all the strings starting with letter A.</p>
<p>I have got this simple regular expression: <strong>&#8216;/^A.*/&#8217;</strong></p>
<p>Now here is the PHP code to find the values from the Array.</p>
<pre class="brush: php; html-script: true;">
&lt;?php
$array = array('Armenia', 'America', 'Algeria', 'India', 'Brazil', 'Croatia', 'Denmark');
$fl_array = preg_grep('/^A.*/', $array);
echo '&lt;pre&gt;';
print_r($fl_array);
echo '&lt;/pre&gt;';
?&gt;
</pre>
<p>Which then gives you this output:<br />
Array<br />
(<br />
[0] =&gt; Armenia<br />
[1] =&gt; America<br />
[2] =&gt; Algeria<br />
)</p>
<p>Here are some Regular Expression Patterns you could use.</p>
<p>Find whole numbers: <strong>&#8216;/^\d+$/&#8217;</strong><br />
Floating numbers: <strong>&#8216;/^\d+\.{1}\d+$/&#8217;</strong><br />
Lowercase Words: <strong>&#8216;/^[a-z]+$/&#8217; </strong></p>
<p>Play with Regular Expressions and let me know if you have any questions or if you need more patterns. I am planning to publish an article on Regular Expressions soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/php-search-in-an-array-for-values-matching-a-pattern-regex-wildcard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; How to Get Browser Properties and Capabilities &#8211; get_browser()</title>
		<link>http://ask.amoeba.co.in/php-how-to-get-browser-properties-and-capabilities-get_browser/</link>
		<comments>http://ask.amoeba.co.in/php-how-to-get-browser-properties-and-capabilities-get_browser/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 12:18:15 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[Enterprise Web]]></category>
		<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[browscap]]></category>
		<category><![CDATA[browscap.ini]]></category>
		<category><![CDATA[browser capability]]></category>
		<category><![CDATA[browser properties]]></category>
		<category><![CDATA[gary keith]]></category>
		<category><![CDATA[get_browser]]></category>
		<category><![CDATA[http_user_agent]]></category>
		<category><![CDATA[ini]]></category>
		<category><![CDATA[ismobiledevice]]></category>
		<category><![CDATA[is_mobile_device]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[mobile application]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=136</guid>
		<description><![CDATA[In this tutorial, learn about the get_browser() PHP function and its configuration. We'll learn how to use Gary Keith's browser information database (browscap.ini)  with the PHP browscap directive.

I wanted one of my web applications to have a different appearance on mobile phones and devices. I didn't really want to set up an entirely different domain or use a sub domain particularly for mobile devices (like http://mobile.facebook.com). Instead I want to tackle the device inside my application logic so that all users access the same URL.]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, learn about the<strong> get_browser()</strong> PHP function and its configuration. We&#8217;ll learn how to use Gary Keith&#8217;s browser information database <strong>(<a title="A special version of browscap.ini for PHP users " rel="nofollow" href="http://browsers.garykeith.com/downloads.asp" target="_blank">browscap.ini</a>)</strong> with the <strong>PHP browscap directive</strong>.</p>
<p>I wanted one of my web applications to have a different appearance on mobile phones and devices. I didn&#8217;t really want to set up an entirely different domain or use a sub domain particularly for mobile devices (like http://mobile.facebook.com). Instead I want to tackle the device inside my application logic so that all users access the same URL.</p>
<p>PHP&#8217;s <span style="color: #000080;"><strong>$_SERVER['HTTP_USER_AGENT']</strong></span> is cool. You can play around this variable and achieve what you want. But you don&#8217;t get all you want. Let&#8217;s look at the string output of the above variable on my browser:</p>
<p><strong><em><span style="color: #993300;">Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6)  Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)</span><br />
</em></strong></p>
<p>This gives you some information. I wanted an easy way to see whether the request was from a mobile device.</p>
<p>PHP has this function, <strong>get_browser</strong> which attempts to determine the capabilities of the  user&#8217;s browser, by looking up the browser&#8217;s information in the <strong><var>browscap.ini</var></strong> file.</p>
<p>In order for this to work, your <strong>browscap </strong>configuration setting  in <strong><var>php.ini</var></strong> must point to the correct location of the  <var>browscap.ini</var> file on your system. <var>browscap.ini</var> is not bundled with PHP, but you may find an  up-to-date <a title="Link : http://browsers.garykeith.com/downloads.asp" href="http://browsers.garykeith.com/downloads.asp" target="_blank">» php_browscap.ini</a> file  here. While <var>browscap.ini</var> contains information on  many browsers, it relies on user updates to keep the database current.</p>
<p>First, Download the browscap.ini file for PHP from the above website. There are many files and this is the one you need: <strong><a title="Gary Keith's browscap.ini for PHP" href="http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI" target="_blank">Gary Keith&#8217;s browscap.ini for PHP</a></strong></p>
<p>Now, open your PHP.ini file and find for &#8220;browscap&#8221;. You will see something like this:</p>
<p><span style="color: #993300;"><strong>[browscap]<br />
;browscap = extras\browscap.ini</strong></span></p>
<p>Remove the semicolon and change the path to point to the <strong>php_browscap.ini</strong> you just downloaded. Your PHP.ini directive now looks like this:</p>
<p><span style="color: #993300;"><strong>[browscap]<br />
browscap = C:\Inetpub\PHP5\extras\php_browscap.ini</strong></span></p>
<p>Save the PHP.ini file and restart your Web server.</p>
<p>Now use the get_browser function in your PHP code to get user&#8217;s browser properties and capabilities.</p>
<pre class="brush: php; html-script: false;">
&lt;?php
$browser = get_browser(null, true);
echo &quot;&lt;pre&gt;&quot;;
print_r($browser);
echo &quot;&lt;/pre&gt;&quot;;
?&gt;
</pre>
<p>This is the output I got when I accessed the script using a Computer Browser.</p>
<pre class="brush: php; html-script: false;">
Array
(
    [browser_name_regex] =&gt; ^mozilla/5\.0 (windows; .*; windows nt 5\.1; .*; rv:1\.9\.2.*) gecko/.* firefox/3\.6.*$
    [browser_name_pattern] =&gt; Mozilla/5.0 (Windows; *; Windows NT 5.1; *; rv:1.9.2*) Gecko/* Firefox/3.6*
    [parent] =&gt; Firefox 3.6
    [platform] =&gt; WinXP
    [win32] =&gt; 1
    [browser] =&gt; Firefox
    [version] =&gt; 3.6
    [majorver] =&gt; 3
    [minorver] =&gt; 6
    [frames] =&gt; 1
    [iframes] =&gt; 1
    [tables] =&gt; 1
    [cookies] =&gt; 1
    [javaapplets] =&gt; 1
    [javascript] =&gt; 1
    [cssversion] =&gt; 3
    [supportscss] =&gt; 1
    [alpha] =&gt;
    [beta] =&gt;
    [win16] =&gt;
    [win64] =&gt;
    [backgroundsounds] =&gt;
    [cdf] =&gt;
    [vbscript] =&gt;
    [activexcontrols] =&gt;
    [isbanned] =&gt;
    [ismobiledevice] =&gt;
    [issyndicationreader] =&gt;
    [crawler] =&gt;
    [aol] =&gt;
    [aolversion] =&gt; 0
)
</pre>
<p>When I accessed the same script using a mobile phone, here&#8217;s what I got:</p>
<pre class="brush: php; html-script: false;">
Array
(
    [browser_name_regex] =&gt; ^.*nokia.*/.*$
    [browser_name_pattern] =&gt; *Nokia*/*
    [parent] =&gt; Nokia
    [browser] =&gt; Nokia
    [tables] =&gt; 1
    [cookies] =&gt; 1
    [ismobiledevice] =&gt; 1
    [version] =&gt; 0
    [majorver] =&gt; 0
    [minorver] =&gt; 0
    [platform] =&gt; unknown
    [frames] =&gt;
    [iframes] =&gt;
    [javaapplets] =&gt;
    [javascript] =&gt;
    [cssversion] =&gt; 0
    [supportscss] =&gt;
    [alpha] =&gt;
    [beta] =&gt;
    [win16] =&gt;
    [win64] =&gt;
    [backgroundsounds] =&gt;
    [cdf] =&gt;
    [vbscript] =&gt;
    [activexcontrols] =&gt;
    [isbanned] =&gt;
    [ismobiledevice] =&gt;
    [issyndicationreader] =&gt;
    [crawler] =&gt;
    [aol] =&gt;
    [aolversion] =&gt; 0
)
</pre>
<p>I was just looking at this,</p>
<pre><span style="color: #993300;"><strong>[ismobiledevice] =&gt; 1</strong></span>

Interesting uh!</pre>
<p>If your shared hosting service doesn&#8217;t allow you to modify the PHP.INI file, you would want to use a stand alone implementation of the same concept by Jonathan. <a href="http://code.google.com/p/phpbrowscap/">http://code.google.com/p/phpbrowscap/ </a></p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/php-how-to-get-browser-properties-and-capabilities-get_browser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CakePHP &#8211; Search for records between two dates inclusively</title>
		<link>http://ask.amoeba.co.in/cakephp-search-for-records-between-two-dates-inclusively/</link>
		<comments>http://ask.amoeba.co.in/cakephp-search-for-records-between-two-dates-inclusively/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 13:45:10 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[app import]]></category>
		<category><![CDATA[between]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[dayassql]]></category>
		<category><![CDATA[daysassql]]></category>
		<category><![CDATA[from]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[time helper]]></category>
		<category><![CDATA[to]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=132</guid>
		<description><![CDATA[Often we search for records in a database table for fetching records that were created or modified on a particular date or between two dates. We match against a date field and add multiple conditions to find records with a date field value ranging between two dates.
It would look something like this:
Select * from tables [...]]]></description>
			<content:encoded><![CDATA[<p>Often we search for records in a database table for fetching records that were created or modified on a particular date or between two dates. We match against a date field and add multiple conditions to find records with a date field value ranging between two dates.</p>
<p>It would look something like this:<br />
<code>Select * from tables where CREATE_TIME &gt;=  "2007-03-14 00:00:00<code>" and CREATE_TIME &lt;= "2007-03-16 23:59:59"</code></code></p>
<p>CakePHP has built-in functions to format a query like this if you have two dates, the FROM DATE and the TO DATE.</p>
<p>See the Example below:</p>
<pre class="brush: php; html-script: true;">
$from = '14-Mar-2007';
$to = '16-03-2007';
App::import('Helper', 'Time');
$time = new TimeHelper();
echo '('.$time-&gt;daysAsSql(($from)?$from:$to, ($to)?$to:$from, &quot;created&quot;).')';
</pre>
<p>In this example, we have two variables to store FROM and TO date limits. The function we used here is &#8220;daysAsSql&#8217; and its a method available with the Time Helper Class. Basically these helper functions are designed to use in Views. When we need to use Helper functions in  a Controller, we import the Helper using the App:import function.</p>
<p>After importing the Time Helper into your controller, create an instance of the Time Helper, <strong>$time = new TimeHelper();</strong></p>
<p>Now call this function by passing the date ranges and the field name as parameters. <strong>$time-&gt;daysAsSql(($from)?$from:$to,  ($to)?$to:$from, &#8220;date_field&#8221;)</strong><br />
I have additional calculations here:<strong> ($from)?$from:$to</strong> &amp;<strong> ($to)?$to:$from</strong>. This makes sure that, if one of the date input values are null or not defined, it searches all the records with the date_field value on a particular day. Explained below.</p>
<p>The above example outputs this:</p>
<p>((created &gt;= &#8216;2007-03-14 00:00:00&#8242;) AND (created &lt;= &#8216;2007-03-16  23:59:59&#8242;))</p>
<p>Now you can use this as a Condition in your Find functions or as a Filter in your Pagination queries.</p>
<p>Examples:</p>
<pre class="brush: php; html-script: true;">
$filters = array();
$filters = '('.$time-&gt;daysAsSql(($from)?$from:$to, ($to)?$to:$from, &quot;created&quot;).')';
$records = $this-&gt;paginate('ModelName', $filters);
</pre>
<p>or</p>
<pre class="brush: php; html-script: true;">
$conditions = array();
$conditions = '('.$time-&gt;daysAsSql(($from)?$from:$to, ($to)?$to:$from,  &quot;created&quot;).')';
$this-&gt;data = $this-&gt;ModelName-&gt;find('all', array('conditions' =&amp;gt; $conditions));
</pre>
<p>If $from was null the query generated would look like this:<br />
((created &gt;= &#8216;2007-03-16 00:00:00&#8242;) AND (created &lt;= &#8216;2007-03-16   23:59:59&#8242;))</p>
<p>Please let me know if you have any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/cakephp-search-for-records-between-two-dates-inclusively/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notebook/Laptop hangs frequently/random (on Low Battery when AC power is connected)</title>
		<link>http://ask.amoeba.co.in/notebooklaptop-hangs-frequentlyrandom-on-low-battery-when-ac-power-is-connected/</link>
		<comments>http://ask.amoeba.co.in/notebooklaptop-hangs-frequentlyrandom-on-low-battery-when-ac-power-is-connected/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 12:16:41 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[ac power]]></category>
		<category><![CDATA[always on]]></category>
		<category><![CDATA[battery]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[dell]]></category>
		<category><![CDATA[hang]]></category>
		<category><![CDATA[hanging]]></category>
		<category><![CDATA[high performance]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[laptop]]></category>
		<category><![CDATA[netlogon]]></category>
		<category><![CDATA[notebook]]></category>
		<category><![CDATA[power plans]]></category>
		<category><![CDATA[power schemes]]></category>
		<category><![CDATA[speedstep]]></category>
		<category><![CDATA[vostro]]></category>
		<category><![CDATA[windows xp]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=129</guid>
		<description><![CDATA[Dell Vostro 1520 Laptop Freezes &#8211; Problem with Dell Laptop.
I am using a Dell Vostro 1520 laptop and recently I came across this problem. My laptop hangs randomly and every time it does (it freezes stops responding completely), I have to restart my laptop by pressing the Power button for a few seconds. If some [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Dell Vostro 1520 Laptop Freezes &#8211; Problem with Dell Laptop.</strong></p>
<p>I am using a Dell Vostro 1520 laptop and recently I came across this problem. My laptop hangs randomly and every time it does (it freezes stops responding completely), I have to restart my laptop by pressing the Power button for a few seconds. If some music was being played when it hangs, you now hear a buzzing noise. My OS is Windows XP Service Pack 3. I had absolutely no idea about the reason why my system hangs. When I looked at the event logs, I could see Netlogon errors being thrown when the system hangs. I did everything I could do to prevent a Netlogon error but with no luck. The Netlogon errors made me think that the problem could be with the Domain Controller since I&#8217;m on a Network. I also tried updating my BIOS and re-installing the Network Driver.</p>
<p>Finally I realized that the problem <strong>NEVER </strong>happens when I use my laptop on <strong>Battery Mode</strong> without an External AC Power supply. But as soon as I re-connect my AC Power supply, the system hangs. I found out that system hangs when on Low Battery with an AC Power outlet connected. It never hangs if you run only on your battery or if you run on your AC power with a fully charged battery.</p>
<p>The real problem was with the <strong>Intel SpeedStep technology</strong> which changes some settings to optimize the laptop performance when you switch from one mode of power supply to other (from Battery to AC after using on battery for a while).</p>
<p>To immediate solution to this problem is to change the Power Option Properties (Power Schemes) in your OS.</p>
<p><strong>In Windows XP:</strong></p>
<ul>
<li> <strong>Right click on the Desktop and choose Properties.</strong></li>
<li><strong>Click on ScreenSaver Tab and Click on &#8220;Power&#8221; button at the bottom.</strong></li>
<li><strong>From the Power Schemes drop down, Choose &#8220;Always On&#8221;.</strong></li>
<li><strong>Apply the settings and the problem is solved!</strong></li>
</ul>
<p><strong>In Windows Vista or Windows 7, yo<strong>u can find Power </strong>Schemes (</strong><strong>Power Plans) </strong><strong>option in Control Panel to </strong>choose a Power Plan. Choose &#8220;<strong>High Performance&#8221; </strong>which will disable the Intel SpeedStep.</p>
<p>This problem is often seen in Dell Laptops and you can contact Dell for a replacement if you are covered under a warranty.</p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/notebooklaptop-hangs-frequentlyrandom-on-low-battery-when-ac-power-is-connected/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Swap Values Without Temp or A Third Variable in PHP</title>
		<link>http://ask.amoeba.co.in/swap-values-without-temp-or-a-third-variable-in-php/</link>
		<comments>http://ask.amoeba.co.in/swap-values-without-temp-or-a-third-variable-in-php/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 14:02:46 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[swap]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=126</guid>
		<description><![CDATA[When we need to swap the values of two variables, we use a third variable temporarily to hold the data between swapping.  Something like this:

&#60;?php
$tmp = $a;
$a = $b;
$b = $tmp;
?&#62;

Here is another way without using a temp or a third variable.

&#60;?php
list($b, $a) = array($a, $b);
?&#62;

And if you want to make it a function:

&#60;?php
function swapValues(&#38;$a, [...]]]></description>
			<content:encoded><![CDATA[<p>When we need to swap the values of two variables, we use a third variable temporarily to hold the data between swapping.  Something like this:</p>
<pre class="brush: php; html-script: true;">
&lt;?php
$tmp = $a;
$a = $b;
$b = $tmp;
?&gt;
</pre>
<p>Here is another way without using a temp or a third variable.</p>
<pre class="brush: php; html-script: true;">
&lt;?php
list($b, $a) = array($a, $b);
?&gt;
</pre>
<p>And if you want to make it a function:</p>
<pre class="brush: php; html-script: true;">
&lt;?php
function swapValues(&amp;$a, &amp;$b) {
     list($b, $a) = array($a, $b);
 }
$a = 10;
$b = 20;
swapValues($a, $b);
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/swap-values-without-temp-or-a-third-variable-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP &#8211; Auth Login Redirect Problem with Plugins</title>
		<link>http://ask.amoeba.co.in/cakephp-auth-login-redirect-problem-with-plugins/</link>
		<comments>http://ask.amoeba.co.in/cakephp-auth-login-redirect-problem-with-plugins/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 13:34:43 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[auth component]]></category>
		<category><![CDATA[loginaction]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=122</guid>
		<description><![CDATA[The Auth Component in CakePHP redirects the user to the log-in page when a user tries to access any protected pages in the application. The default log-in page is set by defining the loginAction variable in the beforeFilter function in your UsersController or AppController.
But if you have used plug-ins in your application, and if a [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>Auth Component</strong> in CakePHP redirects the user to the log-in page when a user tries to access any protected pages in the application. The default log-in page is set by defining the <strong>loginAction </strong>variable in the <strong>beforeFilter </strong>function in your <strong>UsersController </strong>or <strong>AppController</strong>.</p>
<p>But if you have used plug-ins in your application, and if a user tries to access a controller action of a plug-in the user is redirected to an invalid page like this.</p>
<p><strong>http://domain.com/plugin_name/users/login</strong></p>
<p>This is because, CakePHP assumes the user controller to be a a part of the Plug-in.</p>
<p>Normally, your beforeFilter function could look like this.</p>
<pre class="brush: php; html-script: true;">
function beforeFilter() {
	Security::setHash('md5');
	$this-&gt;Auth-&gt;loginAction = array('controller' =&gt; 'users', 'action' =&gt; 'login');
	$this-&gt;Auth-&gt;loginRedirect = array('controller' =&gt; 'home', 'action' =&gt; 'index');
	$this-&gt;Auth-&gt;loginError = 'Invalid Username or Password.';
	$this-&gt;Auth-&gt;authError = &quot;You are not authorized to access.&quot;;
	$this-&gt;Auth-&gt;logoutRedirect = array('controller' =&gt; 'users', 'action' =&gt; 'login');
}
</pre>
<p>The redirection problem can be avoided by defining the loginAction in the above function like this:</p>
<p><strong>$this-&gt;Auth-&gt;loginAction = array(&#8217;controller&#8217; =&gt; &#8216;users&#8217;, &#8216;action&#8217; =&gt; &#8216;login&#8217;, <span style="color: #ff0000;">&#8216;plugin&#8217; =&gt; null</span>);</strong></p>
<p>This tells CakePHP that the user controller is a global controller.</p>
<p>The same problem occurs when you use <strong>$html-&gt;link or $html-&gt;url</strong> to generate links to global contoller actions from a plugin view. If you didn&#8217;t define the parameter <span style="color: #ff0000;">&#8216;plugin&#8217;=&gt;true</span> in <strong>$html-&gt;link or $html-&gt;url</strong>, CakePHP will assume the controller to be a part of the current plugin and will try to access a controller within the plugin instead of redirecting the user to the global controller.</p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/cakephp-auth-login-redirect-problem-with-plugins/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Convert PHP array to Javascript array</title>
		<link>http://ask.amoeba.co.in/convert-php-array-to-javascript-array/</link>
		<comments>http://ask.amoeba.co.in/convert-php-array-to-javascript-array/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 11:41:04 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[Javascript & Libraries]]></category>
		<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=120</guid>
		<description><![CDATA[A very basic tutorial. For the beginners who want to pass array values from PHP to Javascript for them to be accessible in the client side JS as an array. It&#8217;s really easy to pass PHP array to Javascript.
The below code passes a string array in PHP to Javascript.

&#60;?php
$arr = array(&#34;a&#34;,&#34;b&#34;,&#34;c&#34;);
?&#62;
&#60;script&#62;
var jsArray = [&#34;&#60;?php echo [...]]]></description>
			<content:encoded><![CDATA[<p>A very basic tutorial. For the beginners who want to pass array values from PHP to Javascript for them to be accessible in the client side JS as an array. It&#8217;s really easy to pass PHP array to Javascript.</p>
<p>The below code passes a string array in PHP to Javascript.</p>
<pre class="brush: php; html-script: true;">
&lt;?php
$arr = array(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;);
?&gt;
&lt;script&gt;
var jsArray = [&quot;&lt;?php echo join(&quot;\&quot;, \&quot;&quot;, $arr); ?&gt;&quot;];
alert(jsArray);
&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/convert-php-array-to-javascript-array/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CakePHP &#8211; Accessing a model in AppController or in any Controllers</title>
		<link>http://ask.amoeba.co.in/cakephp-accessing-a-model-in-appcontroller-or-in-any-controllers/</link>
		<comments>http://ask.amoeba.co.in/cakephp-accessing-a-model-in-appcontroller-or-in-any-controllers/#comments</comments>
		<pubDate>Sun, 30 May 2010 16:36:24 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[app_controller]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[loadmodel]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[uses]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=117</guid>
		<description><![CDATA[Sometimes, or very rarely we might need to access a model in AppController (Application Controller). This could be for fetching values from a table and make it available for all the controllers in the application (AppController is inherited by all the other controllers). Also, often we need to access models that are not associated with [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, or very rarely we might need to access a model in AppController (Application Controller). This could be for fetching values from a table and make it available for all the controllers in the application (AppController is inherited by all the other controllers). Also, often we need to access models that are not associated with a controller.</p>
<p>I faced this when I had to load some User Session values (which is stored in a database table) in my AppController (app_controller.php) to use with a custom Login process. I was actually integrating a single sign-on process in CakePHP with an external application.</p>
<p>The <strong>loadModel </strong>function came handy here. See the code below.</p>
<p><span style="color: #003366;"><strong>$this-&gt;loadModel(&#8217;UserSession&#8217;);<br />
debug($this-&gt;UserSession-&gt;find(&#8217;all&#8217;));</strong></span></p>
<p>By just calling the loadModel function and passing the Model name, the model now becomes available to the controller and we could perform any operations on that model.</p>
<p>By using <strong>loadModel</strong>, we can reduce the overhead of declaring model names in <strong>$uses </strong>variable.</p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/cakephp-accessing-a-model-in-appcontroller-or-in-any-controllers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save Images from Flash &#8211; Actionscript 3, Filereference.save, JPGEncoder</title>
		<link>http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/</link>
		<comments>http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/#comments</comments>
		<pubDate>Wed, 19 May 2010 10:41:04 +0000</pubDate>
		<dc:creator>Aneeska</dc:creator>
				<category><![CDATA[Flash & Action Script]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[action script]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[as3corelib]]></category>
		<category><![CDATA[bitmapdata]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[cs3]]></category>
		<category><![CDATA[cs4]]></category>
		<category><![CDATA[filereference]]></category>
		<category><![CDATA[filereference.save]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[imageloader]]></category>
		<category><![CDATA[jpegencoder]]></category>
		<category><![CDATA[loader]]></category>
		<category><![CDATA[movieclip to image]]></category>
		<category><![CDATA[save image]]></category>
		<category><![CDATA[save image from flash]]></category>
		<category><![CDATA[save jpg]]></category>
		<category><![CDATA[urlrequest]]></category>

		<guid isPermaLink="false">http://ask.amoeba.co.in/?p=112</guid>
		<description><![CDATA[Saving an image from a flash movie to user&#8217;s local machine hard-disk was a hectic task sometime back. To save Dynamic movie clips (which could be images or any bitmapData) on the stage as Images we had to send the whole pixel data to the server and process it to create an image, then download [...]]]></description>
			<content:encoded><![CDATA[<p>Saving an image from a flash movie to user&#8217;s local machine hard-disk was a hectic task sometime back. To save Dynamic movie clips (which could be images or any bitmapData) on the stage as Images we had to send the whole pixel data to the server and process it to create an image, then download it on to the user machine.</p>
<p>This task has now become very simple with ActionScript3, Flash Player 10 and as3CoreLibrary. We don&#8217;t need to send the BitmapData back to the server to process and create the image. A file can be saved direct from the flash to the user computer. This is possible of a cool new<strong> FileReference.save()</strong> feature added to Flash Player 10. hich allows the Flash Player to write to  the local file system as long  as the save request is requested by the  user. Upon  calling FileReference.save() the default file  system dialog will open and user can save the data from the flash movie to their local machine. No server processing needed!</p>
<p>Please note that <strong>FileReference.save() </strong>can be only invoked if the invoke call is associated with an <strong>OnClick</strong> event.</p>
<p>Additionally we are using JPEGEncoder which comes with the <strong>as3corelib</strong>. You can download this library here: <a class="wpGallery" title="as3CoreLib" href="http://code.google.com/p/as3corelib/" target="_blank"><strong>http://code.google.com/p/as3corelib/ </strong></a><br />
After downloading copy the source files (the <strong>com </strong>folder) on to your Class path or your application root directory. Apart from the <strong>JPEGEncoder</strong>, this library is packaged with a lot of other classes related to Hasing, Text, Date etc.</p>
<p>This is how we save an image from a flash movie to a local machine.</p>
<p><strong>1) Create a BitmapData object out of the MovieClip or the Loader.<br />
2) Encode the BitmapData using the JPEGEncoder and form a ByteArray.<br />
3) Use FileReference.save() to download the image on to the User machine.</strong></p>
<p>See an example:<br />
Create a blank Flash movie and name it as &#8220;ImageSave.fla&#8221;. In the same folder create &#8220;ImageSave.as&#8221; file and copy the below code in to it. You need the &#8220;com&#8221; folder copied from the <strong>as3corelib </strong>to this folder. I have a button on the stage named &#8220;save_mc&#8221; which triggers the saveImage function.</p>
<pre class="brush: as3;">
package {

	import flash.display.MovieClip;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.utils.ByteArray;
	import flash.net.FileReference;
	import flash.net.FileFilter;

	import flash.events.*;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import com.adobe.images.JPGEncoder;

	public class ImageSave extends MovieClip {

		private var imgFile:URLRequest;
		private var img:MovieClip;
		private var imgLoader:Loader;
		private var file:FileReference;

		public function ImageSave() {
			imgFile = new URLRequest(&quot;coffee.jpg&quot;); //change it to your image path
			imgLoader = new Loader();
			imgLoader.load(imgFile);
			imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

			save_mc.addEventListener(MouseEvent.CLICK, saveImage);
		}

		private function onLoaded(evt:Event):void {
			imgLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
			imgLoader.cacheAsBitmap = true;
			addChild(imgLoader);
		}

		function saveImage(e:MouseEvent):void {
			var myBitmapData:BitmapData = new BitmapData(imgLoader.width, imgLoader.height);
			myBitmapData.draw(imgLoader);
			var jpgEncoder:JPGEncoder = new JPGEncoder(80);
			var imgByteData:ByteArray = jpgEncoder.encode(myBitmapData);
			file = new FileReference();
			file.browse(new Array(new FileFilter(&quot;Images (*.jpg, *.jpeg)&quot;, &quot;*.jpg;*.jpeg&quot;)));
			file.save(imgByteData, &quot;test.jpg&quot;);
		}

	}
}
</pre>
<p>For your convenience you can download a working copy of this sample here:<br />
<a class="dLink" href="http://ask.amoeba.co.in/wp-content/uploads/2010/05/ImageSave.zip">Download &#8216;SaveImagefromFlash&#8217; SourceCode &#8211; CS4 [ZIP]</a></p>
<p>This sample contains the as3CoreLib, so you don&#8217;t need to download it separate. The FLA source can be opened only in CS4. However you can still open the AS file and explore the code.</p>
<p>Please let me know if you have any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
