<?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>Coding Friends</title>
	<atom:link href="http://www.codingfriends.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingfriends.com</link>
	<description>Coding Friends, place for developers.</description>
	<lastBuildDate>Sun, 04 Dec 2011 21:11:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Google python code, string2.py</title>
		<link>http://www.codingfriends.com/index.php/2011/12/04/google-python-code-string2-py/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-python-code-string2-py</link>
		<comments>http://www.codingfriends.com/index.php/2011/12/04/google-python-code-string2-py/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 21:11:08 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[google code]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1764</guid>
		<description><![CDATA[As from the previous post, I am doing the google&#8217;s python class code and if any one comes up different solutions to the googles version or mine, please post. So here is the string2.py solutions from me. Verbing, needs to check for string over 3 and then only compare the last 3 characters for &#8216;ing&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>As from the <a href="http://www.codingfriends.com/index.php/2011/12/04/google-python-code/">previous post</a>, I am doing the google&#8217;s python class code and if any one comes up different solutions to the googles version or mine, please post.  So here is the string2.py solutions from me.</p>
<p>Verbing, needs to check for string over 3 and then only compare the last 3 characters for &#8216;ing&#8217;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># D. verbing</span>
<span style="color: #808080; font-style: italic;"># Given a string, if its length is at least 3,</span>
<span style="color: #808080; font-style: italic;"># add 'ing' to its end.</span>
<span style="color: #808080; font-style: italic;"># Unless it already ends in 'ing', in which case</span>
<span style="color: #808080; font-style: italic;"># add 'ly' instead.</span>
<span style="color: #808080; font-style: italic;"># If the string length is less than 3, leave it unchanged.</span>
<span style="color: #808080; font-style: italic;"># Return the resulting string.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> verbing<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">3</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s
  <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: black;">&#40;</span>s<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">3</span>:<span style="color: black;">&#93;</span> ==<span style="color: #483d8b;">'ing'</span><span style="color: black;">&#41;</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s + <span style="color: #483d8b;">'ly'</span>
  <span style="color: #ff7700;font-weight:bold;">else</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s + <span style="color: #483d8b;">'ing'</span></pre></div></div>

<p>Not bad, find the &#8216;not&#8217; and &#8216;bad&#8217;, if bad after not then replace.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># E. not_bad</span>
<span style="color: #808080; font-style: italic;"># Given a string, find the first appearance of the</span>
<span style="color: #808080; font-style: italic;"># substring 'not' and 'bad'. If the 'bad' follows</span>
<span style="color: #808080; font-style: italic;"># the 'not', replace the whole 'not'...'bad' substring</span>
<span style="color: #808080; font-style: italic;"># with 'good'.</span>
<span style="color: #808080; font-style: italic;"># Return the resulting string.</span>
<span style="color: #808080; font-style: italic;"># So 'This dinner is not that bad!' yields:</span>
<span style="color: #808080; font-style: italic;"># This dinner is good!</span>
<span style="color: #ff7700;font-weight:bold;">def</span> not_bad<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  notV = s.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'not'</span><span style="color: black;">&#41;</span>
  badV = s.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'bad'</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>badV <span style="color: #66cc66;">&gt;</span> notV<span style="color: black;">&#41;</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s<span style="color: black;">&#91;</span>:notV<span style="color: black;">&#93;</span> + <span style="color: #483d8b;">'good'</span> + s<span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>badV+<span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> s</pre></div></div>

<p>Font back, here we needed the modulus function to find out the reminder of a division.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># F. front_back</span>
<span style="color: #808080; font-style: italic;"># Consider dividing a string into two halves.</span>
<span style="color: #808080; font-style: italic;"># If the length is even, the front and back halves are the same length.</span>
<span style="color: #808080; font-style: italic;"># If the length is odd, we'll say that the extra char goes in the front half.</span>
<span style="color: #808080; font-style: italic;"># e.g. 'abcde', the front half is 'abc', the back half 'de'.</span>
<span style="color: #808080; font-style: italic;"># Given 2 strings, a and b, return a string of the form</span>
<span style="color: #808080; font-style: italic;">#  a-front + b-front + a-back + b-back</span>
<span style="color: #ff7700;font-weight:bold;">def</span> front_back<span style="color: black;">&#40;</span>a, b<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  aV = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>a<span style="color: black;">&#41;</span>/<span style="color: #ff4500;">2</span>+<span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>a<span style="color: black;">&#41;</span><span style="color: #66cc66;">%</span>2<span style="color: black;">&#41;</span>
  bV = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>b<span style="color: black;">&#41;</span>/<span style="color: #ff4500;">2</span>+<span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>b<span style="color: black;">&#41;</span><span style="color: #66cc66;">%</span>2<span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> a<span style="color: black;">&#91;</span>:aV<span style="color: black;">&#93;</span>+b<span style="color: black;">&#91;</span>:bV<span style="color: black;">&#93;</span>+a<span style="color: black;">&#91;</span>aV:<span style="color: black;">&#93;</span>+b<span style="color: black;">&#91;</span>bV:<span style="color: black;">&#93;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/12/04/google-python-code-string2-py/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google python code</title>
		<link>http://www.codingfriends.com/index.php/2011/12/04/google-python-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-python-code</link>
		<comments>http://www.codingfriends.com/index.php/2011/12/04/google-python-code/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 21:04:00 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[google code]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1762</guid>
		<description><![CDATA[After been talking with some friends, they said about putting some of the google code from there classes online encase other people come up with any other versions. So from the first of the classes that they was talking about was Python , so here is my code for these, may be other people may [...]]]></description>
			<content:encoded><![CDATA[<p>After been talking with some friends, they said about putting some of the <a href="http://code.google.com/edu/">google code</a> from there classes online encase other people come up with any other versions.  So from the first of the classes that they was talking about was <a href="http://code.google.com/edu/languages/google-python-class/">Python </a>, so here is my code for these, may be other people may be doing and come up with different code ?</p>
<p>For first string1.py test there is 4 functions that you have code up and in order from the source code.</p>
<p>Donut, as from the below you just need do a compare on the parameter in.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># A. donuts</span>
<span style="color: #808080; font-style: italic;"># Given an int count of a number of donuts, return a string</span>
<span style="color: #808080; font-style: italic;"># of the form 'Number of donuts: &lt;count&gt;', where &lt;count&gt; is the number</span>
<span style="color: #808080; font-style: italic;"># passed in. However, if the count is 10 or more, then use the word 'many'</span>
<span style="color: #808080; font-style: italic;"># instead of the actual count.</span>
<span style="color: #808080; font-style: italic;"># So donuts(5) returns 'Number of donuts: 5'</span>
<span style="color: #808080; font-style: italic;"># and donuts(23) returns 'Number of donuts: many'</span>
<span style="color: #ff7700;font-weight:bold;">def</span> donuts<span style="color: black;">&#40;</span>count<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> count <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff4500;">10</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'Number of donuts: many'</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'Number of donuts: '</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>count<span style="color: black;">&#41;</span></pre></div></div>

<p>Both end, it is string manipulation and returning part of the string if longer enough.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># B. both_ends</span>
<span style="color: #808080; font-style: italic;"># Given a string s, return a string made of the first 2</span>
<span style="color: #808080; font-style: italic;"># and the last 2 chars of the original string,</span>
<span style="color: #808080; font-style: italic;"># so 'spring' yields 'spng'. However, if the string length</span>
<span style="color: #808080; font-style: italic;"># is less than 2, return instead the empty string.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> both_ends<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">2</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">''</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> s<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> + s<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span></pre></div></div>

<p>Fix start, replace the characters within the string with a * that the same as the first character, so just need to concatenate the first character with the rest of the characters with any replaced <img src='http://www.codingfriends.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># C. fix_start</span>
<span style="color: #808080; font-style: italic;"># Given a string s, return a string</span>
<span style="color: #808080; font-style: italic;"># where all occurences of its first char have</span>
<span style="color: #808080; font-style: italic;"># been changed to '*', except do not change</span>
<span style="color: #808080; font-style: italic;"># the first char itself.</span>
<span style="color: #808080; font-style: italic;"># e.g. 'babble' yields 'ba**le'</span>
<span style="color: #808080; font-style: italic;"># Assume that the string is length 1 or more.</span>
<span style="color: #808080; font-style: italic;"># Hint: s.replace(stra, strb) returns a version of string s</span>
<span style="color: #808080; font-style: italic;"># where all instances of stra have been replaced by strb.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> fix_start<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> s<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + s<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>,<span style="color: #483d8b;">'*'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Mix up, change the first 2 characters from the two parameters around.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># D. MixUp</span>
<span style="color: #808080; font-style: italic;"># Given strings a and b, return a single string with a and b separated</span>
<span style="color: #808080; font-style: italic;"># by a space '&lt;a&gt; &lt;b&gt;', except swap the first 2 chars of each string.</span>
<span style="color: #808080; font-style: italic;"># e.g.</span>
<span style="color: #808080; font-style: italic;">#   'mix', pod' -&gt; 'pox mid'</span>
<span style="color: #808080; font-style: italic;">#   'dog', 'dinner' -&gt; 'dig donner'</span>
<span style="color: #808080; font-style: italic;"># Assume a and b are length 2 or more.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> mix_up<span style="color: black;">&#40;</span>a, b<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> b<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>+a<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span>+<span style="color: #483d8b;">' '</span>+a<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>+b<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/12/04/google-python-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Final and auto load a class</title>
		<link>http://www.codingfriends.com/index.php/2011/11/09/final-and-auto-load/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=final-and-auto-load</link>
		<comments>http://www.codingfriends.com/index.php/2011/11/09/final-and-auto-load/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 22:18:31 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[auto load]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[final]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1759</guid>
		<description><![CDATA[To include a class within many languages you have to define it at the top and then off you go with programming with using that class. Well within PHP you can use the __autoload function that is called when you try to create a new instance of a class. function __autoload&#40;$class_name&#41; &#123; include &#34;classes/&#34;.$class_name.&#34;.php&#34;; &#125; [...]]]></description>
			<content:encoded><![CDATA[<p>To include a class within many languages you have to define it at the top and then off you go with programming with using that class.  Well within PHP you can use the __autoload function that is called when you try to create a new instance of a class.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> __autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$class_name</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;classes/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$class_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>this __autoload function above takes a parameter as the class name to load and then within the code it will try and load that class with how ever you want to, in this case I have placed the classes within the directory called classes and under there classname.php filename.</p>
<p>So if you try to load the class</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$newclass</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> basic<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>it will look within the classes directory for the file basic.php for the autoload function above, you can alter it to load from where ever and how ever you want to.</p>
<p>The next part of this post is about the keyword &#8216;final&#8217;, the final keyword means that it is final so if you try and extend that class and extend the function that has been declared as final this will cause php interpretor to fail due to syntax error with something similar to</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Fatal error: Cannot override final method class_name::function_name<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>For an example here is two classes one is called basic and the other is called extendbasic, where the basic class has the final function within it</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> basic
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">get_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; : Hello&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	final <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> sayGoodbye<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">get_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; : Goodbye&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and here is the extendclass</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> extendbasic <span style="color: #000000; font-weight: bold;">extends</span> basic
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">get_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; : the newer hello!!&quot;</span><span style="color: #339933;">;</span>	
		parent<span style="color: #339933;">::</span><span style="color: #004000;">sayHello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">// this will cause the php engine to fail!!!!!. because it is trying to over load the function sayGoogbye which has been declared as final</span>
<span style="color: #666666; font-style: italic;">/*	public function sayGoodbye()
	{
		echo &quot;I should not get here!!&quot;;
	}*/</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here is some code to call them both which they have been placed within a directory called &#8216;classes&#8217;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> __autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$class_name</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;classes/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$class_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$basicClass</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> basic<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$basicClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sayHello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$basicClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sayGoodbye</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$basicClass</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> extendbasic<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$basicClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sayHello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$basicClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sayGoodbye</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and the output would be</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">basic : Hello
basic : Goodbye
extendbasic : the newer hello<span style="color: #000000; font-weight: bold;">!!</span>
extendbasic : Hello
extendbasic : Goodbye</pre></div></div>

<p>I am calling the parent function from within the extendbasic class sayHello function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/11/09/final-and-auto-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node &#8211; install and test</title>
		<link>http://www.codingfriends.com/index.php/2011/11/03/node-install-and-test/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=node-install-and-test</link>
		<comments>http://www.codingfriends.com/index.php/2011/11/03/node-install-and-test/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 20:44:12 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Linux install and configurations]]></category>
		<category><![CDATA[Windows install and configuration]]></category>
		<category><![CDATA[node]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1752</guid>
		<description><![CDATA[One of my friends asked me what is Node and also how do you install and test to make sure it is working. Well, Node is in essence a javascript server side environment that allows you to write code that will allow the event model to handle requests very quickly since it does not handle [...]]]></description>
			<content:encoded><![CDATA[<p>One of my friends asked me what is Node and also how do you install and test to make sure it is working.</p>
<p>Well, <a href="http://nodejs.org/" title="Node" target="_blank">Node</a> is in essence a javascript server side environment that allows you to write code that will allow the event model to handle requests very quickly since it does not handle the I/O (well almost of all of the functions within node do not!) so there is no-blocking of code.</p>
<p>Node has a very quick and capable http class that allows for the user to create a server that is capable of doing some very quick responses to multiple connections.  </p>
<p>To install Node you just need to do this in ubuntu</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-s</span>
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> python-software-properties
add-apt-repository ppa:chris-lea<span style="color: #000000; font-weight: bold;">/</span>node.js
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> nodejs
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<p>the first line allows you to be the root and thus the next commands are as the user root.</p>
<p>Or if you are using windows just download the executable from <a href="http://nodejs.org/#download">here</a></p>
<p>To test the node to make sure it is working with a basic &#8220;Hello world!&#8221; example if you save this below as helloworld.js.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> http <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// create the http server function req'uest, res'ult</span>
http.<span style="color: #660066;">createServer</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>req<span style="color: #339933;">,</span> res<span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// 200 = means http response code of found page, then a array of the content type</span>
    res.<span style="color: #660066;">writeHead</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'Content-Type'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'text/plain'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    res.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello world!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// write out the text</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">8080</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'127.0.0.1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// listen on port 8080 on the ip address 127.0.0.1</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'We have started, check your browser on http://127.0.0.1:8080/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I am using a higher number than 1024 for the port because below that you need to be a root user or administrator on windows to allow anything to connect to those port numbers.  </p>
<p>So if you now run the program with the javascript file above as the second parameter</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">node helloworld.js</pre></div></div>

<p>and then if you open your browser at 127.0.0.1:8080  then you will see </p>
<p>Hello world!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/11/03/node-install-and-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu upgrade server to the latest version</title>
		<link>http://www.codingfriends.com/index.php/2011/11/02/ubuntu-upgrade-server-to-the-latest-version/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntu-upgrade-server-to-the-latest-version</link>
		<comments>http://www.codingfriends.com/index.php/2011/11/02/ubuntu-upgrade-server-to-the-latest-version/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 20:20:19 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Linux install and configurations]]></category>
		<category><![CDATA[Ubuntu/Kubuntu]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1749</guid>
		<description><![CDATA[As normal with most of the ubuntu / linux setups, it is easy to upgrade to the latest version and with the ubuntu server being on the command line you just need to run the commmand do-release-upgrade and it will update to the latest version of ubuntu, how simple is that.]]></description>
			<content:encoded><![CDATA[<p>As normal with most of the ubuntu / linux setups, it is easy to upgrade to the latest version and with the ubuntu server being on the command line you just need to run the commmand</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">do-release-upgrade</pre></div></div>

<p>and it will update to the latest version of ubuntu, how simple is that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/11/02/ubuntu-upgrade-server-to-the-latest-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IIS redirector &#8211; application request routing</title>
		<link>http://www.codingfriends.com/index.php/2011/10/19/iis-redirector-application-request-routing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iis-redirector-application-request-routing</link>
		<comments>http://www.codingfriends.com/index.php/2011/10/19/iis-redirector-application-request-routing/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 20:34:34 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Windows install and configuration]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Redirect]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1747</guid>
		<description><![CDATA[A great thing with apache webserver is that you can redirect HTTP requests to another place within the site or even hosting local port, well with IIS you can achieve the same with Application Request Routing. It is a great add-on that really empowers the admin users to achieve allot more &#8220;fun&#8221; things with IIS.]]></description>
			<content:encoded><![CDATA[<p>A great thing with apache webserver is that you can redirect HTTP requests to another place within the site or even hosting local port, well with IIS you can achieve the same with <a href="http://www.iis.net/download/applicationrequestrouting" target="_blank">Application Request Routing</a>.</p>
<p>It is a great add-on that really empowers the admin users to achieve allot more &#8220;fun&#8221; things with IIS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/10/19/iis-redirector-application-request-routing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ckeditor &#8211; not allow posting of images from the local harddrive</title>
		<link>http://www.codingfriends.com/index.php/2011/10/19/ckeditor-not-allow-posting-of-images-from-the-local-harddrive/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ckeditor-not-allow-posting-of-images-from-the-local-harddrive</link>
		<comments>http://www.codingfriends.com/index.php/2011/10/19/ckeditor-not-allow-posting-of-images-from-the-local-harddrive/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 20:26:51 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[CKEditor]]></category>
		<category><![CDATA[local harddrive]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1743</guid>
		<description><![CDATA[Within the CKEditor you can also add on to the prototypes that allow more control of what is allowed on your website. Sometimes you do not want to allow the user to copy and paste local files to the CKEditor so this is what I done to remove the file:// from within the img tag [...]]]></description>
			<content:encoded><![CDATA[<p>Within the <a href="http://ckeditor.com/" title="CKEDITOR" target="_blank">CKEditor</a> you can also add on to the prototypes that allow more control of what is allowed on your website.</p>
<p>Sometimes you do not want to allow the user to copy and paste local files to the CKEditor so this is what I done to remove the file:// from within the img tag within the copy and paste with using the CKEditor htmlDataProcessor group of functions, in this case the &#8216;toHtml&#8217; function which is called when the user pastes any content into the CKEditor window.  All I am doing it using the regular expression to search for the &lt;img src=&#8221;file .. and replace with a &lt;mg tag&gt; which when they double click on that it will open the CKEditor&#8217;s image browser (which you can include a upload part to it as well <img src='http://www.codingfriends.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">CKEDITOR.<span style="color: #660066;">htmlDataProcessor</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">toHtml</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> data<span style="color: #339933;">,</span> fixForBody <span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> data.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\&lt;img src=\&quot;file:([^\&gt;])*\&gt;/ig</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&lt;img title=<span style="color: #000099; font-weight: bold;">\&quot;</span>Please use the Media/Image uploader because can not show files on your harddrive<span style="color: #000099; font-weight: bold;">\&quot;</span> alt=<span style="color: #000099; font-weight: bold;">\&quot;</span>Please use the Media/Image uploader because can not show files on your harddrive<span style="color: #000099; font-weight: bold;">\&quot;</span>/&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It was very helpful for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/10/19/ckeditor-not-allow-posting-of-images-from-the-local-harddrive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

