<?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>unexpected[it]</title>
	<atom:link href="http://www.unexpectedit.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.unexpectedit.com</link>
	<description>Professional IT Blog</description>
	<lastBuildDate>Fri, 03 Sep 2010 09:27:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Handling Non-English Characters UTF8</title>
		<link>http://www.unexpectedit.com/php/php-handling-non-english-characters-utf8</link>
		<comments>http://www.unexpectedit.com/php/php-handling-non-english-characters-utf8#comments</comments>
		<pubDate>Wed, 18 Aug 2010 12:49:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[same length]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[utf8_decode]]></category>
		<category><![CDATA[utf8_encode]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=300</guid>
		<description><![CDATA[
	/**
	* Returns an string with the same length.
	* - If it is smaller than num it will fill out with the fill character.
	* - If it is larger than num it will cut the string.
	* www.unexpectedit.com
	*/
	function formatcell($data, $num, $fill=' '){
	    $data = trim($data);
		$data=str_replace(chr(13),' ',$data);
		$data=str_replace(chr(10),' ',$data);
		// translate UTF8 to English characters
		$data = iconv('UTF-8', [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: php;">
	/**
	* Returns an string with the same length.
	* - If it is smaller than num it will fill out with the fill character.
	* - If it is larger than num it will cut the string.
	* www.unexpectedit.com
	*/
	function formatcell($data, $num, $fill=' '){
	    $data = trim($data);
		$data=str_replace(chr(13),' ',$data);
		$data=str_replace(chr(10),' ',$data);
		// translate UTF8 to English characters
		$data = iconv('UTF-8', 'ASCII//TRANSLIT', $data);
		$data = preg_replace(&quot;/[\'\&quot;\^\~\`]/i&quot;, '', $data);

		// fill it up with spaces
    	for ($i = strlen($data); $i &lt; $num; $i++) {
    		$data .= $fill;
    	}
    	// limit string to num characters
   		$data = substr($data, 0, $num);

		return $data;
    }

    echo formatcell(&quot;YES UTF8 String Zürich&quot;, 25, 'x'); //YES UTF8 String ZÃ¼richxxx
    echo formatcell(&quot;NON UTF8 String Zurich&quot;, 25, 'x'); //NON UTF8 String Zurichxxx
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-handling-non-english-characters-utf8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Xcode Link Interface to Code</title>
		<link>http://www.unexpectedit.com/iphone-ipad-cocoa-objectivec/how-xcode-link-interface-to-code</link>
		<comments>http://www.unexpectedit.com/iphone-ipad-cocoa-objectivec/how-xcode-link-interface-to-code#comments</comments>
		<pubDate>Thu, 05 Aug 2010 16:36:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iPhone - iPad - Cocoa - ObjectiveC]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=283</guid>
		<description><![CDATA[Follow the images to see how is linked Inteface with the code in an iPhone Application.
Download UnexpectedIT iPhone Xcode Project





]]></description>
			<content:encoded><![CDATA[<p><strong>Follow the images to see how is linked Inteface with the code in an iPhone Application.</strong><br />
<a href='http://www.unexpectedit.com/wp-content/uploads/2010/08/UnexpectedIT.zip'>Download UnexpectedIT iPhone Xcode Project</a></p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/view1.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/08/view1.jpg" alt="" title="view1" width="700" height="461" class="alignnone size-medium wp-image-284" /></a></p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/view2.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/08/view2.jpg" alt="" title="view2" width="700" height="461" class="alignnone size-medium wp-image-287" /></a></p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/view3.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/08/view3.jpg" alt="" title="view3" width="700" height="485" class="alignnone size-medium wp-image-288" /></a></p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/view4.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/08/view4.jpg" alt=""<br />
title="view4" width="700" height="432" class="alignnone size-medium wp-image-290" /></a></p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/view5.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/08/view5.jpg" alt="" title="view5" width="700" height="432" class="alignnone size-medium wp-image-291" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/iphone-ipad-cocoa-objectivec/how-xcode-link-interface-to-code/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix Box Handbook</title>
		<link>http://www.unexpectedit.com/webserver/unix-box-handbook</link>
		<comments>http://www.unexpectedit.com/webserver/unix-box-handbook#comments</comments>
		<pubDate>Thu, 05 Aug 2010 13:37:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Webserver]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[sendmail]]></category>
		<category><![CDATA[telnet test]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=271</guid>
		<description><![CDATA[
#
# Variable file, Write all global vars in
#
.bash_login
PATH=$PATH:/Applications/MAMP/Library/bin/
alias ls=&#34;ls -G&#34;

#
# Size of a folder
#
du -kH

#
# Find
#
find . -name &#34;sendmail.cf&#34;
find . -type f -name &#34;*.java&#34; -exec grep -l sendEmailPassword {} \;

#
# Virtual Box
#
VBoxManage internalcommands sethduuid

#
# Mails (Mac Snow Leopard)
# See the mail queue
/usr/sbin/sendmail -bp
# Start Postfix daemon
 /usr/bin/sudo /bin/launchctl load -w /Library/LaunchDaemons/com.cutedgesystems.postfix.plist
# Stop Postfix daemon
 /usr/bin/sudo [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">
#
# Variable file, Write all global vars in
#
.bash_login
PATH=$PATH:/Applications/MAMP/Library/bin/
alias ls=&quot;ls -G&quot;

#
# Size of a folder
#
du -kH

#
# Find
#
find . -name &quot;sendmail.cf&quot;
find . -type f -name &quot;*.java&quot; -exec grep -l sendEmailPassword {} \;

#
# Virtual Box
#
VBoxManage internalcommands sethduuid

#
# Mails (Mac Snow Leopard)
# See the mail queue
/usr/sbin/sendmail -bp
# Start Postfix daemon
 /usr/bin/sudo /bin/launchctl load -w /Library/LaunchDaemons/com.cutedgesystems.postfix.plist
# Stop Postfix daemon
 /usr/bin/sudo /bin/launchctl unload -w /Library/LaunchDaemons/com.cutedgesystems.postfix.plist
# Mail out folder
/var/spool/postfix/maildrop

#
# Test Mail Sever through telnet
#
telnet 127.0.0.1 25
EHLO 127.0.0.1
MAIL FROM:root@localhost
RCPT TO: ignacio@richardmason.net
DATA
SUBJECT: test message
Test message
.
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/webserver/unix-box-handbook/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSTL Handbook</title>
		<link>http://www.unexpectedit.com/java/jstl/jstl-handbook</link>
		<comments>http://www.unexpectedit.com/java/jstl/jstl-handbook#comments</comments>
		<pubDate>Thu, 05 Aug 2010 08:52:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JSTL]]></category>
		<category><![CDATA[c:choose]]></category>
		<category><![CDATA[c:forEach]]></category>
		<category><![CDATA[c:set]]></category>
		<category><![CDATA[fmt:formatDate]]></category>
		<category><![CDATA[fn:substring]]></category>
		<category><![CDATA[jsp:setProperty]]></category>
		<category><![CDATA[jsp:useBean]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=254</guid>
		<description><![CDATA[
&#60;!--
*
* JSP Fundamentals
*
--&#62;
&#60;%@ page ... %&#62;
&#60;!--
- Specify the syntax of a page: html, xml...
- Session Tracking
- Error page
--&#62;
&#60;%@ include ...%&#62; &#60;!-- Includes a file --&#62;
&#60;%@ taglib ... %&#62; &#60;!-- Declares a custom tag library. --&#62;

&#60;%jsp:useBean %&#62;
&#60;%jsp:getProperty ...%&#62;
&#60;%jsp:setProperty ...%&#62;
&#60;%jsp:include ...%&#62; &#60;!-- includes the response from a servlet or JSP --&#62;
&#60;%jsp:forward ...%&#62; &#60;!-- forwards the processing to [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: xml;">
&lt;!--
*
* JSP Fundamentals
*
--&gt;
&lt;%@ page ... %&gt;
&lt;!--
- Specify the syntax of a page: html, xml...
- Session Tracking
- Error page
--&gt;
&lt;%@ include ...%&gt; &lt;!-- Includes a file --&gt;
&lt;%@ taglib ... %&gt; &lt;!-- Declares a custom tag library. --&gt;

&lt;%jsp:useBean %&gt;
&lt;%jsp:getProperty ...%&gt;
&lt;%jsp:setProperty ...%&gt;
&lt;%jsp:include ...%&gt; &lt;!-- includes the response from a servlet or JSP --&gt;
&lt;%jsp:forward ...%&gt; &lt;!-- forwards the processing to another page --&gt;
&lt;%jsp:param ...%&gt; &lt;!-- adds a parameter value to a request --&gt;
&lt;%jsp:plugin ...%&gt; &lt;!-- browser dependent elements --&gt;

&lt;% code %&gt;
&lt;%= print %&gt;
&lt;%!declaration %&gt;

&lt;c:out value=&quot;${1+2+3}&quot; /&gt; &lt;!-- Setting a bean property --&gt;
&lt;jsp:useBean id=&quot;msg&quot; class=&quot;com.org...&quot;/&gt;

&lt;jsp:setProperty name=&quot;msg&quot; property=&quot;category&quot; value&quot;for him&quot; /&gt;

&lt;!-- FUNDAMENTALS --&gt;
&lt;!-- Output --&gt;
&lt;c:out value=&quot;${type}&quot; /&gt;

&lt;!-- Loops --&gt;
&lt;c:forEach var=&quot;i&quot; begin=&quot;1&quot; end=&quot;20&quot; step=&quot;1&quot; varStatus =&quot;status&quot;&gt;
	&lt;c:out value=&quot;${i}&quot; /&gt;
&lt;/c:forEach&gt;
&lt;c:forEach items=&quot;${types}&quot; var=&quot;type&quot;&gt;
	&lt;option value=&quot;${type}&quot;&gt;&lt;c:out value=&quot;${type}&quot; /&gt;&lt;/option&gt;
&lt;/c:forEach&gt;
&lt;!-- Note: Do not use &quot;param&quot; as var name. --&gt;

&lt;!-- Set --&gt;
&lt;c:set var=&quot;m_cols&quot; value=&quot;3&quot;/&gt;
&lt;c:set var=&quot;m_cols&quot; value=&quot;${m_cols+1}&quot;/&gt;

&lt;!-- If ... Else --&gt;
&lt;c:choose&gt;
&lt;c:when test=&quot;&quot;&gt;
...
&lt;/c:when&gt;
&lt;c:otherwise&gt;
...
&lt;/c:otherwise&gt;
&lt;/c:choose&gt;

&lt;!-- Dates --&gt;
//Add library in the header
&lt;%@ taglib prefix=&quot;fmt&quot; uri=&quot;http://java.sun.com/jsp/jstl/fmt&quot; %&gt;
//Use
&lt;fmt:formatDate value=&quot;${now}&quot; type=&quot;both&quot; pattern=&quot;E, dd/MM/yyyy 'at' HH:MM:ss&quot;/&gt;

&lt;!-- String --&gt;
&lt;c:out value=&quot;${fn:substring(feed.name, 0, 50)}&quot; /&gt;

&lt;c:out value=&quot;${fn:substringAfter(task.class, '.task.')}&quot; /&gt;

&lt;c:if test=&quot;${fn:length(feed.name) &gt; 50}&quot;&gt; 

&lt;c:out value=&quot;${fn:toUpperCase('text')}&quot; /&gt;

&lt;!-- Get / Post Params --&gt;
&lt;c:if test=&quot;${! empty param.productId}&quot;&gt;

&lt;!-- Reporting errors, hasBindErrors --&gt;
//Use the next library:
&lt;%@ taglib prefix=&quot;spring&quot; uri=&quot;http://www.springframework.org/tags&quot; %&gt;
//Print all errors (1/3) simple:
&lt;form:errors path=&quot;*&quot;/&gt;

//Print all errors (2/3) simple/compact:
&lt;spring:hasBindErrors name=&quot;feedgroup&quot;&gt;
	&lt;div class=&quot;alert&quot;&gt;
		&lt;form:errors path=&quot;*&quot; /&gt;
	&lt;/div&gt;
&lt;/spring:hasBindErrors&gt;

//Print all errors (3/3) detailed method:
	&lt;spring:hasBindErrors name=&quot;feed&quot;&gt;
		&lt;c:if test=&quot;${errors.errorCount &gt; 0}&quot; &gt;
			&lt;div class=&quot;alert&quot;&gt;
				Sorry, you can't submit your feed. Check the errors and please try again.&lt;br /&gt;&lt;br /&gt;
		         &lt;ul&gt;
		            &lt;c:forEach var=&quot;errMsgObj&quot; items=&quot;${errors.allErrors}&quot;&gt;
		               &lt;li&gt;
		                  &lt;spring:message code=&quot;${errMsgObj.code}&quot; text=&quot;${errMsgObj.defaultMessage}&quot;/&gt;
		               &lt;/li&gt;
		            &lt;/c:forEach&gt;
		         &lt;/ul&gt;
			&lt;/div&gt;
		&lt;/c:if&gt;
	&lt;/spring:hasBindErrors&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/java/jstl/jstl-handbook/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.htaccess PHP Error Reporting</title>
		<link>http://www.unexpectedit.com/php/htaccess-php-error-reporting</link>
		<comments>http://www.unexpectedit.com/php/htaccess-php-error-reporting#comments</comments>
		<pubDate>Wed, 04 Aug 2010 20:59:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[display_errors]]></category>
		<category><![CDATA[error_reporting]]></category>
		<category><![CDATA[E_ALL]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=238</guid>
		<description><![CDATA[
php_flag display_errors off
php_value error_reporting 7

]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">
php_flag display_errors off
php_value error_reporting 7
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/htaccess-php-error-reporting/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Http Password in Directory</title>
		<link>http://www.unexpectedit.com/webserver/apache-http-password-in-directory</link>
		<comments>http://www.unexpectedit.com/webserver/apache-http-password-in-directory#comments</comments>
		<pubDate>Wed, 04 Aug 2010 20:54:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Webserver]]></category>
		<category><![CDATA[AuthName]]></category>
		<category><![CDATA[AuthUserFile]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[htpasswd]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=233</guid>
		<description><![CDATA[1) Create the password file .htpasswd
Go to the directory to protect and type in the shell

htpasswd -c -m .htpasswd webuser

-c means create file.
-m MD5  algorithm.

&#8230;if you want to get the generated MD5 password in the screen just type

htpasswd -n -bm  webuser 123456

2) Create a file .htaccess

AuthName &#34;Restricted Area&#34;
AuthType Basic
AuthUserFile /var/www/html/.htpasswd  #This is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1)</strong> Create the password file <strong>.htpasswd</strong><br />
Go to the directory to protect and type in the shell</p>
<pre class="brush: bash;">
htpasswd -c -m .htpasswd webuser
</pre>
<p><em>-c means create file.<br />
-m MD5  algorithm.<br />
</em><br />
&#8230;if you want to get the generated MD5 password in the screen just type</p>
<pre class="brush: bash;">
htpasswd -n -bm  webuser 123456
</pre>
<p><strong>2)</strong> Create a file <strong>.htaccess</strong></p>
<pre class="brush: bash;">
AuthName &quot;Restricted Area&quot;
AuthType Basic
AuthUserFile /var/www/html/.htpasswd  #This is the file you generated before
AuthGroupFile /dev/null
require valid-user
</pre>
<p><strong>3)</strong> Test it<br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-21.48.28.png"><img class="alignnone size-full wp-image-234" title="htpasswd in action" src="http://www.unexpectedit.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-21.48.28.png" alt="" width="560" height="254" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/webserver/apache-http-password-in-directory/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Handbook and Tips</title>
		<link>http://www.unexpectedit.com/javascript/javascript-handbook-and-tips</link>
		<comments>http://www.unexpectedit.com/javascript/javascript-handbook-and-tips#comments</comments>
		<pubDate>Sun, 01 Aug 2010 16:32:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[createElement]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[onkeyup]]></category>
		<category><![CDATA[round]]></category>
		<category><![CDATA[window.open]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=280</guid>
		<description><![CDATA[
/**
* Fundamentals
*
**/
//Get Html Objects
document.getElementById('id')

//Timeout, delay...
setTimeout(&#34;alert('hi!')&#34;,3000);

//Change url, location, href
window.location = &#34;/index.php&#34;;

//Replace texts dynamically
document.getElementById('FlashCode').innerHTML = flashcode

//Replace strings in vars
string.replace(findstring,newstring);

//Html Check Buttons
document.forms.form.license.checked='checked'; //set value
if(document.forms.form. license.checked) {} //check value

//Print html
document.write(&#34;&#34;);

//Visibility elements
document.getElementById('error2').style.visibility = 'visible';
document.getElementById('error2').style.visibility = 'hidden';	

//Radio buttons
0.12&#60;input type=&#34;radio&#34; class=&#34;text&#34; name=&#34;ProfilePriceID&#34; checked=&#34;checked&#34; value=&#34;0.12&#34;&#62;
0.56&#60;input type=&#34;radio&#34; class=&#34;text&#34; name=&#34;ProfilePriceID&#34; value=&#34;0.56&#34;&#62;
//set value
document.forms.frmemail.ProfilePriceID_New[0].checked=true
//get value
document.forms.frmemail.ProfilePriceID[0].value -&#62; 0.12
//if checked
document.forms.frmemail.ProfilePriceID[0].checked -&#62; on
//PHP get by post
$_POST[&#34;ProfilePriceID&#34;] -&#62; 0.12 (the value [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript;">
/**
* Fundamentals
*
**/
//Get Html Objects
document.getElementById('id')

//Timeout, delay...
setTimeout(&quot;alert('hi!')&quot;,3000);

//Change url, location, href
window.location = &quot;/index.php&quot;;

//Replace texts dynamically
document.getElementById('FlashCode').innerHTML = flashcode

//Replace strings in vars
string.replace(findstring,newstring);

//Html Check Buttons
document.forms.form.license.checked='checked'; //set value
if(document.forms.form. license.checked) {} //check value

//Print html
document.write(&quot;&quot;);

//Visibility elements
document.getElementById('error2').style.visibility = 'visible';
document.getElementById('error2').style.visibility = 'hidden';	

//Radio buttons
0.12&lt;input type=&quot;radio&quot; class=&quot;text&quot; name=&quot;ProfilePriceID&quot; checked=&quot;checked&quot; value=&quot;0.12&quot;&gt;
0.56&lt;input type=&quot;radio&quot; class=&quot;text&quot; name=&quot;ProfilePriceID&quot; value=&quot;0.56&quot;&gt;
//set value
document.forms.frmemail.ProfilePriceID_New[0].checked=true
//get value
document.forms.frmemail.ProfilePriceID[0].value -&gt; 0.12
//if checked
document.forms.frmemail.ProfilePriceID[0].checked -&gt; on
//PHP get by post
$_POST[&quot;ProfilePriceID&quot;] -&gt; 0.12 (the value of the radio button checked)

// Html Select - Drop Down Element
document.getElementById('giftfinderprice').selectedIndex=3;
//or
&lt;option selected value='3'&gt;three&lt;/option&gt;
//select the option by value in a select box
&lt;select id=&quot;filterBy&quot;&gt;
	&lt;option name=&quot;one&quot;&gt;one&lt;/option&gt;
	&lt;option name=&quot;two&quot;&gt;two&lt;/option&gt;
	&lt;option name=&quot;three&quot;&gt;three&lt;/option&gt;
&lt;/select&gt;
&lt;script&gt;
	document.getElementById(&quot;filterBy&quot;).selectedIndex = document.getElementById(&quot;filterBy&quot;).options['two'].index;
&lt;/script&gt;

//New Window
window.open('www.google.es',null,'width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes')&quot;
//To make IE compatible: don't change the null var and don't add spaces beween the properties.

//How to round with 2 decimals: save two decimals with times 100, round it, and divide by 100
Math.round(5.95 * 1.15 * 100) / 100

/**
* Cookies
*
**/
// Read
		var nameEQ = &quot;played&quot; + &quot;=&quot;; //look for the value 'played'
		var ca = document.cookie.split(';');
		var value;
		for(var i=0;i &lt; ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) value=c.substring(nameEQ.length,c.length);
		}
// Write
		var expirationDate = new Date;
		expirationDate.setMonth(expirationDate.getMonth()+6);
		document.cookie = &quot;played=1; expires=&quot;+ expirationDate.toGMTString(); // Create the cookie

/**
* Useful Snippets
*
**/

// Dynamic load source file
var fileref=document.createElement('script');
fileref.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);
fileref.setAttribute(&quot;src&quot;, &quot;http://localhost:8888/floating.js&quot;);
document.getElementsByTagName('head')[0].appendChild(fileref);  

// Destroy element
var webactorsmovie=document.getElementById('FLVPlayer');
webactorsmovie.parentNode.removeChild(webactorsmovie);

//Print function using containers
    function PrintProduct()
    {
	//mark the container as 'divtoprint' to use it
	    var DocumentContainer = document.getElementById('divtoprint');
	    WindowObject.document.writeln(DocumentContainer.innerHTML);
	    WindowObject.document.close();
	    WindowObject.focus();
	    WindowObject.print();
	    WindowObject.close();
    }

//Add bookmark javascript link
&lt;a href=&quot;javascript:if(document.all) window.external.AddFavorite(location.href,document.title); else if(window.sidebar)window.sidebar.addPanel (document.title,location.href,'');&quot;&gt; Bookmark this site!&lt;/a&gt;

//Pointer change mouseover
onmouseover=&quot;document.body.style.cursor='pointer';&quot; onmouseout=&quot;document.body.style.cursor='auto';&quot;

//Add event
referenceToElement.onclick = function () { alert('here'); };

//Refresh window
&lt;a href=&quot;javascript:location.reload(true)&quot;&gt;Refresh this page&lt;/a&gt;

//Input box only numbers
&lt;input... onkeyup=&quot;javascript:this.value=this.value.replace(/[^0-9]/g, '');&quot; /&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/javascript/javascript-handbook-and-tips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Photoshop Rounded Borders Frame Image</title>
		<link>http://www.unexpectedit.com/web-design/photoshop-rounded-borders-frame-image</link>
		<comments>http://www.unexpectedit.com/web-design/photoshop-rounded-borders-frame-image#comments</comments>
		<pubDate>Sun, 01 Aug 2010 13:20:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[rounded borders]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=262</guid>
		<description><![CDATA[1) Create rounded rectangle with radius 5 or 10px on image
2) Make a selection in &#8220;paths&#8221; (3rd tab in layers)

3) Invert selection
4) Paint of web background color or delete to make it transparent
5) Save as gift with transparency

]]></description>
			<content:encoded><![CDATA[<p><strong>1)</strong> Create rounded rectangle with radius 5 or 10px on image</p>
<p><strong>2)</strong> Make a selection in &#8220;paths&#8221; (3rd tab in layers)</p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/a.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/08/a.jpg" alt="" title="a" width="700" height="399" class="alignnone size-full wp-image-267" /></a></p>
<p><strong>3)</strong> Invert selection</p>
<p><strong>4)</strong> Paint of web background color or delete to make it transparent</p>
<p><strong>5)</strong> Save as gift with transparency<br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2010/08/b.jpg"><img src="http://www.unexpectedit.com/wp-content/uploads/2010/08/b.jpg" alt="" title="b" width="700" height="424" class="alignnone size-full wp-image-268" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/web-design/photoshop-rounded-borders-frame-image/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Cluster on Amazon EC2</title>
		<link>http://www.unexpectedit.com/webserver/mysql-cluster-on-amazon-ec2</link>
		<comments>http://www.unexpectedit.com/webserver/mysql-cluster-on-amazon-ec2#comments</comments>
		<pubDate>Thu, 29 Jul 2010 16:15:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Webserver]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ndb]]></category>
		<category><![CDATA[ndb_mgm]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=210</guid>
		<description><![CDATA[I created two cluster servers and one management server for MySQL Cluster
AMI: Minimal Fedora Core 8, 32-bit architecture, Apache 2.0, and Amazon EC2 AMI Tools
MySQL Cluster version 7.1
Fedora Version: 8
Security Group: default

1) Download RPM files
From http://www.mysql.com/downloads/cluster/#downloads all rpm files for Red Hat &#38; Oracle Enterprise Linux for (x86, 32-bit).
2) In each instance

yum --enablerepo=remi erase mysql [...]]]></description>
			<content:encoded><![CDATA[<p>I created two cluster servers and one management server for MySQL Cluster</p>
<p>AMI: Minimal Fedora Core 8, 32-bit architecture, Apache 2.0, and Amazon EC2 AMI Tools<br />
MySQL Cluster version 7.1<br />
Fedora Version: 8<br />
Security Group: default</p>
<p><a href="http://www.unexpectedit.com/wp-content/uploads/2010/07/Screen-shot-2010-07-29-at-16.22.381.jpg"><img class="alignnone size-full wp-image-217" title="Amzon MySQL Cluster Instances" src="http://www.unexpectedit.com/wp-content/uploads/2010/07/Screen-shot-2010-07-29-at-16.22.381.jpg" alt="" width="666" height="187" /></a></p>
<p><strong>1) Download RPM files</strong><br />
From <a href="http://www.mysql.com/downloads/cluster/#downloads">http://www.mysql.com/downloads/cluster/#downloads</a> all rpm files for Red Hat &amp; Oracle Enterprise Linux for (x86, 32-bit).</p>
<p><strong>2) In each instance</strong></p>
<pre class="brush: bash;">
yum --enablerepo=remi erase mysql mysql-libs mysql-server mysqlclient15.i386
rpm -iv MySQL-Cluster-gpl-*
</pre>
<p><strong>3) Config Management Server</strong><br />
Server IP ( ec2-79-11-111-11.eu-west-1.compute.amazonaws.com )</p>
<pre class="brush: bash;">
vi /var/lib/mysql-cluster/config.ini
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=ec2-79-11-111-11.eu-west-1.compute.amazonaws.com		# the IP of THIS SERVER
# Storage Engines
[NDBD]
HostName=ec2-79-22-222-22.eu-west-1.compute.amazonaws.com		# the IP of the FIRST SERVER
DataDir= /var/lib/mysql-cluster
[NDBD]
HostName=ec2-79-33-333-33.eu-west-1.compute.amazonaws.com		# the IP of the SECOND SERVER
DataDir=/var/lib/mysql-cluster
# 2 MySQL Clients
# I personally leave this blank to allow rapid changes of the mysql clients;
# you can enter the hostnames of the above two servers here. I suggest you dont.
[MYSQLD]
[MYSQLD]

ndb_mgmd -f /var/lib/mysql-cluster/config.ini
</pre>
<p><em>The Management Server is now ready, you can check the conexions with the other servers doing this</em></p>
<pre class="brush: bash;">
ndb_mgm
ndb_mgm&gt; show
Cluster Configuration
---------------------
[ndbd(NDB)]	2 node(s)
id=2	@79.22.222.22  (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0, Master)
id=3	@79.33.333.33  (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0, Master)

[ndb_mgmd(MGM)]	1 node(s)
id=1	@79.11.111.11  (mysql-5.1.44 ndb-7.1.4)

[mysqld(API)]	2 node(s)
id=4	@79.22.222.22  (mysql-5.1.44 ndb-7.1.4)
id=5	@79.33.333.33  (mysql-5.1.44 ndb-7.1.4)
</pre>
<p><strong>4) Config Cluster Servers </strong><br />
Cluster Server IPs: (ec2-79-22-222-22.eu-west-1.compute.amazonaws.com and ec2-79-33-333-33.eu-west-1.compute.amazonaws.com )</p>
<pre class="brush: bash;">
/etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=ec2-79-11-111-11.eu-west-1.compute.amazonaws.com     # the IP of the MANAGMENT SERVER
[mysql_cluster]
ndb-connectstring=ec2-79-11-111-11.eu-west-1.compute.amazonaws.com	# the IP of the MANAGMENT SERVER

/usr/sbin/ndbd --initial

/etc/init.d/mysql start
</pre>
<p><strong>5) Testing</strong><br />
You can check in FIRST or SECOND server this and it will be duplicated in both servers.</p>
<pre class="brush: bash;">
mysql -u root -p
use test;
CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;
INSERT INTO ctest () VALUES (1);
SELECT * FROM ctest;
</pre>
<p><strong>6) Starting and Shutting down the MySQL Cluster</strong><br />
<strong> Starting</strong><br />
Management Server: <em>db_mgmd -f /var/lib/mysql-cluster/config.ini</em><br />
Cluster Servers: <em>ndbd</em></p>
<p><strong>Shutting down</strong><br />
Management Server: <em>ndb_mgm&gt; shutdown</em></p>
<p><strong>Notes</strong><br />
<span style="color: #993300;"> Error: ERROR 1005 (HY000): Can&#8217;t create table &#8216;test.ctest&#8217; (errno: 157)<br />
<span style="color: #000000;">Try to track the error with SHOW WARNINGS; When I have this problem I had disabled SELinux with &#8220;setenforce 0&#8243;.</span></span></p>
<p><span style="color: #993300;">Error: There is no populating changes trough the cluster servers.<br />
<span style="color: #000000;">Make sure they are connected each other, you can check this from management server with ndb_mgm&gt; SHOW<br />
Also double check all servers are in the security group &#8220;default&#8221; to leave the ports open. (see image)<br />
<a href="http://www.unexpectedit.com/wp-content/uploads/2010/07/Screen-shot-2010-07-29-at-16.22.03.jpg"><img class="alignnone size-medium wp-image-212" title="Amazon Security Groups Default" src="http://www.unexpectedit.com/wp-content/uploads/2010/07/Screen-shot-2010-07-29-at-16.22.03-300x71.jpg" alt="" width="300" height="71" /></a> </span></span></p>
<p><span style="color: #993300;"> </span></p>
<p>Pages related: <a href="http://dev.mysql.com/tech-resources/articles/mysql-cluster-for-two-servers.html" target="_blank">http://dev.mysql.com/tech-resources/articles/mysql-cluster-for-two-servers.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/webserver/mysql-cluster-on-amazon-ec2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a Magento Server in Amazon Cloud EC2</title>
		<link>http://www.unexpectedit.com/webserver/setting-up-a-magento-server-in-amazon-cloud-ec2</link>
		<comments>http://www.unexpectedit.com/webserver/setting-up-a-magento-server-in-amazon-cloud-ec2#comments</comments>
		<pubDate>Thu, 29 Jul 2010 15:39:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Webserver]]></category>
		<category><![CDATA[aim]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Config]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[exim]]></category>
		<category><![CDATA[fedora 8]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=203</guid>
		<description><![CDATA[How to create an instance for Magento in Amazon Cloud EC2
You can also get this ebs Image in Amazon EC2. Choose &#8220;426063643107/Magento 1.4.x on Fedora 8&#8243;
when you launch an instance in the tab &#8220;Community AMIs&#8221;
MySQL Admin Username: root Password: 123456 
Once the image is initialized
a) Install Magento 1.4.1.1 (For demo store follow 5.1)
In your browser [...]]]></description>
			<content:encoded><![CDATA[<h2>How to create an instance for Magento in Amazon Cloud EC2</h2>
<p class="note">You can also get this ebs Image in Amazon EC2. Choose <strong>&#8220;426063643107/Magento 1.4.x on Fedora 8&#8243;</strong><br />
when you launch an instance in the tab <strong>&#8220;Community AMIs&#8221;<br />
MySQL Admin </strong>Username:<strong> root </strong>Password:<strong> 123456 </strong></p>
<p>Once the image is initialized<br />
<strong>a) Install Magento 1.4.1.1 (For demo store follow 5.1)</strong><br />
In your browser go to: http://YOUREC2NAME.compute-1.amazonaws.com/magento/<br />
<strong>b) Install Magento 1.4.1.1 DEMO Version</strong><br />
In your browser go to: http://YOUREC2NAME.compute-1.amazonaws.com/magento-demo/</p>
<p><strong>1) Choose the simplest Instance Fedora Core 8 (AMI Id: ami-df1e35ab)</strong><br />
Minimal Fedora Core 8, 32-bit architecture, Apache 2.0, and Amazon EC2 AMI Tools.</p>
<p><strong>2) Installing Remi Repository with Apache, MySQL and PHP</strong></p>
<pre class="brush: bash;">
wget http://rpms.famillecollet.com/remi-release-8.rpm
rpm -Uvh remi-release-8.rpm
vi /etc/apt/sources.list.d/remi.list # Uncomment: repomd http://rpms.famillecollet.com/ fc$(VERSION).$(ARCH)

# Installing MySQL
#
yum --enablerepo=remi install mysql mysql-server mysql-devel

# Installing Http Server with PHP
#
yum --enablerepo=remi install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

# Config MySQL
#
/usr/bin/mysqladmin -u root password '123456'

# Config Apache
#
# /etc/httpd/conf/httpd.con on Line 326 change
AllowOverride None
# to
AllowOverride All
# inside &lt;Directory &quot;/var/www/html&quot;&gt; ... &lt;/Directory&gt;

# /etc/php.ini Activate this line to read &lt;? tags
short_open_tag = On

#Try it out with the usual script in /var/www/html/test.php
&amp;lt;?php
phpinfo();
?&gt;
</pre>
<p><strong>3) Installing Exim Mail Server</strong></p>
<pre class="brush: bash;">
yum install exim
/etc/init.d/exim start
mail -s &quot;testing&quot; your@emailaddress.com
Testing purpose!
.
Cc:
# Your Mail Server should be running properly
</pre>
<p><strong>4) SFtp Server Access</strong></p>
<pre class="brush: bash;">
# Just using a SFtp Client Server Vicomsoft Ftp Client
#  configure a new connection without password and use
#  the option &quot;Use SSH keyfile (SFTP only)&quot; to add your
#  .pem file
#  Or just use
sshfs -i MYSECRETKEY.pem root@YOUREC2NAME.compute-1.amazonaws.com:/ /
</pre>
<p><strong>5) Using ntsysv command choose the next services to start automatically</strong><br />
sendmail<br />
httpd<br />
mysqld</p>
<p><strong>6) Optionally you can give NFS support to share files between images</strong></p>
<pre class="brush: bash;">
#Server1
[root@server1]# vi /etc/exports
/var/www/html *(rw)

[root@server1]# /etc/init.d/rpcbind start

[root@server1]# /etc/init.d/nfs start
#Server2
[root@server2]# mount -o nolock ec2-79-xxx-xx-xxx.eu-west-1.compute.amazonaws.com:/var/www/html /mnt
</pre>
<p><strong>7) Download and uncompress Magento versions in /var/www/html</strong></p>
<p><strong> CHANGELOG </strong><br />
<em>File</em> /etc/php.ini <em>change</em> short_open_tag = On</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/webserver/setting-up-a-magento-server-in-amazon-cloud-ec2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
