<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Coders4Fun</title>
	
	<link>http://www.coders4fun.com/en</link>
	<description>Programming blog from programming lovers</description>
	<pubDate>Fri, 20 Jun 2008 21:55:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/coders4fun" type="application/rss+xml" /><item>
		<title>ReviewMe - WebHostingPal</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/316496056/</link>
		<comments>http://www.coders4fun.com/en/2008/06/20/webhostingpal/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 21:54:03 +0000</pubDate>
		<dc:creator>inandrea</dc:creator>
		
		<category><![CDATA[ReviewMe]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[review me]]></category>

		<category><![CDATA[web hosting]]></category>

		<category><![CDATA[webhostingpal]]></category>

		<guid isPermaLink="false">http://www.coders4fun.com/en/?p=72</guid>
		<description><![CDATA[Time ago a friend of mine talks to me about an advertising service: &#8220;ReviewMe&#8221;.
Once you signup, they look your blog and they propose to you to write about a service or a product or a site and in return they give to you a little amount of money.
I accepted to signup because ReviewMe allows you [...]]]></description>
			<content:encoded><![CDATA[<p>Time ago a friend of mine talks to me about an advertising service: &#8220;ReviewMe&#8221;.<br />
Once you signup, they look your blog and they propose to you to write about a service or a product or a site and in return they give to you a little amount of money.<br />
I accepted to signup because ReviewMe allows you to write all you think about the product, not only good words!</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-73 aligncenter shadow" title="webhostingpal" src="http://www.coders4fun.com/en/wp-content/uploads/2008/06/webhostingpal.png" alt="" width="500" height="292" /></p>
<p>Recently they ask to me to write about the site <a href="http://www.webhostingpal.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.webhostingpal.com/');">Web Hosting Pal</a>.This site can help you to find the best web hosting for your requirements. Immediately I visited the website which I chose to promote and I thought what I can write.<br />
<span id="more-72"></span>My first impression wasn’t good because the page look is a “little old” in my opinion!<br />
At once I looked the “beginners guide” section and I observed the guide is still under construction, so I couldn’t have any help for my eventually need! I hope they will complete it soon, because it could be an useful thing for surfers.<br />
About the “top ten web hosting” page, I think is complete and it shows the right information to your best choice.<br />
Moreover, you can find for every top ten item an exhaustive review of the hosting services and of the hosting quality.<br />
Actually I don’t need to change my hosting service, but if you are looking for a new web host, I suggest you read <a href="http://www.webhostingpal.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.webhostingpal.com/');">Web Hosting Pal</a> reviews, you might find useful information.</p>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=ryXtuP"><img src="http://feeds.feedburner.com/~a/coders4fun?i=ryXtuP" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/316496056" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2008/06/20/webhostingpal/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2008/06/20/webhostingpal/</feedburner:origLink></item>
		<item>
		<title>Today is Download Day</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/313689503/</link>
		<comments>http://www.coders4fun.com/en/2008/06/17/download-day/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 10:07:56 +0000</pubDate>
		<dc:creator>inandrea</dc:creator>
		
		<category><![CDATA[News]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[browser war]]></category>

		<category><![CDATA[download day]]></category>

		<category><![CDATA[firefox]]></category>

		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.coders4fun.com/en/?p=70</guid>
		<description><![CDATA[Set a Guinness World Record? YES WE CAN!

Next World Record? Win browser war!
]]></description>
			<content:encoded><![CDATA[<p>Set a Guinness World Record? YES WE CAN!<br />
<a href="http://www.spreadfirefox.com/node&amp;id=0&amp;t=264" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.spreadfirefox.com/node&amp;id=0&amp;t=264');"><img title="Download Day" src="http://www.spreadfirefox.com/files/images/affiliates_banners/dday_badge_fox.png" border="0" alt="Download Day" /></a><br />
Next World Record? Win browser war!</p>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=Z0m1ao"><img src="http://feeds.feedburner.com/~a/coders4fun?i=Z0m1ao" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/313689503" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2008/06/17/download-day/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2008/06/17/download-day/</feedburner:origLink></item>
		<item>
		<title>Growing String in c</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/295815627/</link>
		<comments>http://www.coders4fun.com/en/2008/05/22/growing-string-in-c/#comments</comments>
		<pubDate>Thu, 22 May 2008 13:14:23 +0000</pubDate>
		<dc:creator>dzamir</dc:creator>
		
		<category><![CDATA[C]]></category>

		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[grow]]></category>

		<category><![CDATA[growing]]></category>

		<category><![CDATA[malloc]]></category>

		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://raynor/wordpress/en/?p=24</guid>
		<description><![CDATA[This article contains the source code for a c utility that manages a growing string, and a brief explanation of the code.
To obtain this, we make something similar to a c++ class: a struct with associated functions. The functions add characters to the string in the struct, and allocate more memory space when the string [...]]]></description>
			<content:encoded><![CDATA[<p>This article contains the source code for a c utility that manages a growing string, and a brief explanation of the code.</p>
<p>To obtain this, we make something similar to a c++ class: a struct with associated functions. The functions add characters to the string in the struct, and allocate more memory space when the string is full.</p>
<p>This is usefull when we are working with string with an unknow length (e.g. we are reading a file).</p>
<p>The struct containing the string is the following:</p>
<pre class="prettyprint">// Struct containing the growing string
typedef struct
{
	// string
	char * text;
	// string length (with zero terminator)
	int length;
	// string capacity
	int capacity;
} growing_string;</pre>
<p>The text variable is where the string is allocated, length is the current string lenght and capacity is the memory allocated for the string.</p>
<p>To better understand the difference between length and capacity, look at the next image:</p>
<p><img src="http://www.coders4fun.com/wp-content/uploads/2007/09/lunghezza-capacita.png" alt="Capacity-Length" /></p>
<p>Capacity is the total space allocated for the string, while length is the actual number of character of the string, including the \0 terminator (the special character that close the string). If we add enough characters and the length is greater than the capacity, we need to allocate more memory for the string.</p>
<p><span id="more-20"></span><br />
To create the string use the following method:</p>
<pre class="prettyprint">// Create a new growing string. Return 0 if the operation was done
int new_growing_string(growing_string * str);</pre>
<p>This method allocate the memory space for the string in this way:</p>
<pre class="prettyprint">// alloc string space
str-&gt;text = (char *) malloc(sizeof(char) * DEFAULT_INITIAL_SIZE);</pre>
<p>DEFAULT_INITIAL_SIZE is a #define with the size that the string will occupy when it&#8217;s created. Another #define is DEFAULT_GROW, that indicates the number of characters to add to the string when the capacity is full.</p>
<p>The method that adds characters to the string is the following:</p>
<pre class="prettyprint">// Add a char to the string. Return 0 if the operation was done
int add_char(growing_string * str, char c);</pre>
<p>This method automatically reallocate the memory space for the string when is needed, and adds the character at the end of the string:</p>
<pre class="prettyprint">int add_char(growing_string * str, char c)
{
	// if the string capacity is reached
	if (str-&gt;length &gt;= str-&gt;capacity)
	{
		//  increments the string dimension
	}
	// add the character at the end
	str-&gt;text[str-&gt;length - 1] = (int)c;
	str-&gt;text[str-&gt;length++] = &#8216;\0&#8242;;
	return 0;
}</pre>
<p>If the length is smaller than the capacity, then the character will be added to the end of the string. Otherwise, this code will be executed:</p>
<pre class="prettyprint">//  increments the string dimension
char * backup = str-&gt;text;
int i;
// create the space for the new string
char * tmp = (char *) malloc(sizeof(char) * str-&gt;length + DEFAULT_GROW);
if (tmp == NULL)
	return 1;
str-&gt;text = tmp;
str-&gt;capacity = str-&gt;length + DEFAULT_GROW;
// copy the old string
for (i = 0; i length; i++)
{
	str-&gt;text[i] = backup[i];
}
// free the memory of the old string
free(backup);</pre>
<p>We save the pointer to the old string, assign a larger memory space for the new string, copy the old string into the new space and free the space assigned to the old string.</p>
<p>Other methods of the &#8220;<em>class</em>&#8221; are:</p>
<pre class="prettyprint">// frees the space allocated for the string
void delete_growing_string(growing_string * str)
// add to the growing string the string text
int add_string(growing_string * str, char * text)</pre>
<p>Following, a code sample that adds to a growing string all ASCII char from 32th to 127th:</p>
<pre class="prettyprint">int main()
{
	growing_string str;
	new_growing_string(&amp;str);
	for (i = 32; i &lt; 128; i++)
	{
		add_char(&amp;str, (char)i);
	}
	printf("%s", str.text);
	delete_growing_string(&amp;str);
	return (0);
}</pre>
<p>In the source code you will find the files <em>growing_string.h,</em> <em>growing_string.c </em>and <em>main.c </em>with an example on how to use the code.</p>
<p>Download <a href="http://www.coders4fun.com/en/wp-content/plugins/download-monitor/download.php?id=14"  title="Version 1.0 downloaded 153 times" >Growing String</a>. Downloads: 153</p>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=di77hX"><img src="http://feeds.feedburner.com/~a/coders4fun?i=di77hX" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/295815627" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2008/05/22/growing-string-in-c/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2008/05/22/growing-string-in-c/</feedburner:origLink></item>
		<item>
		<title>Coders4fun Quiz #4</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/290081585/</link>
		<comments>http://www.coders4fun.com/en/2008/05/14/coders4fun-quiz-4/#comments</comments>
		<pubDate>Wed, 14 May 2008 10:30:49 +0000</pubDate>
		<dc:creator>dzamir</dc:creator>
		
		<category><![CDATA[Quiz]]></category>

		<guid isPermaLink="false">http://www.coders4fun.com/en/?p=68</guid>
		<description><![CDATA[Main.java

public class Main {

  public static void main(String[] args) {
    System.out.print(Quiz.GetMagicNumber());
  }

}

Quiz.java

public class Quiz {

  static int magicNumber = 3;

  public static int GetMagicNumber()
  {
    return magicNumber;
  }
}

What we need to add in Quiz class to print 5 instead of 3?
]]></description>
			<content:encoded><![CDATA[<p><em>Main.java</em></p>
<pre class="prettyprint">
public class Main {

  public static void main(String[] args) {
    System.out.print(Quiz.GetMagicNumber());
  }

}
</pre>
<p><em>Quiz.java</em></p>
<pre class="prettyprint">
public class Quiz {

  static int magicNumber = 3;

  public static int GetMagicNumber()
  {
    return magicNumber;
  }
}
</pre>
<p>What we need to add in <em>Quiz</em> class to print 5 instead of 3?</p>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=QBqoyG"><img src="http://feeds.feedburner.com/~a/coders4fun?i=QBqoyG" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/290081585" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2008/05/14/coders4fun-quiz-4/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2008/05/14/coders4fun-quiz-4/</feedburner:origLink></item>
		<item>
		<title>Coders4fun Quiz #3: Will it compile?</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/288603468/</link>
		<comments>http://www.coders4fun.com/en/2008/01/09/coders4fun-quiz-3-en/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 09:20:41 +0000</pubDate>
		<dc:creator>dzamir</dc:creator>
		
		<category><![CDATA[Quiz]]></category>

		<guid isPermaLink="false">http://raynor/wordpress/en/2008/01/09/coders4fun-quiz-3-en/</guid>
		<description><![CDATA[Will this code compile??? Why?
foo.h
class Foo
{
	public:
		Foo();

		void fooo();
	private:
		int i;
		char c;
		short s;
	protected:
		char b;
		char e;

		char getFoo();
}

foo.cpp
#include "foo.h"

Foo::Foo()
{
	for (int i = 0; ; ) { }
}

void Foo::fooo()
{
while(true)
{
	c = 'f';
}
}

char getFoo()
{;
	return c + 2;
}

]]></description>
			<content:encoded><![CDATA[<p>Will this code compile??? Why?</p>
<p><em>foo.h</em></p>
<pre  class="prettyprint">class Foo
{
	public:
		Foo();

		void fooo();
	private:
		int i;
		char c;
		short s;
	protected:
		char b;
		char e;

		char getFoo();
}
</pre>
<p><em>foo.cpp</em></p>
<pre class="prettyprint">#include "foo.h"

Foo::Foo()
{
	for (int i = 0; ; ) { }
}

void Foo::fooo()
{
while(true)
{
	c = 'f';
}
}

char getFoo()
{;
	return c + 2;
}
</pre>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=PyIo1s"><img src="http://feeds.feedburner.com/~a/coders4fun?i=PyIo1s" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/288603468" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2008/01/09/coders4fun-quiz-3-en/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2008/01/09/coders4fun-quiz-3-en/</feedburner:origLink></item>
		<item>
		<title>How to use poEdit</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/288603469/</link>
		<comments>http://www.coders4fun.com/en/2008/01/04/how-to-poedit-wx/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 16:19:44 +0000</pubDate>
		<dc:creator>inandrea</dc:creator>
		
		<category><![CDATA[C]]></category>

		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://raynor/wordpress/en/2008/01/04/how-to-poedit-wx/</guid>
		<description><![CDATA[In this guide I will explain how to simplify the localization process of a software written in c++ using &#8220;wxWidget (a cross platform toolkit), with poEdit.
poEdit offers to developers a conventient approach to localizazion, and there is no need to modify the source code by hand to modify translations, because they are all stored on [...]]]></description>
			<content:encoded><![CDATA[<p>In this guide I will explain how to simplify the localization process of a software written in c++ using &#8220;<a href="http://www.wxwidgets.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.wxwidgets.org/');">wxWidget</a> (a cross platform toolkit), with <a href="http://www.poedit.net/download.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.poedit.net/download.php');">poEdit</a>.<br />
poEdit offers to developers a conventient approach to localizazion, and there is no need to modify the source code by hand to modify translations, because they are all stored on a catalog file that is easy editable.</p>
<p><a href='http://www.coders4fun.com/wp-content/uploads/2007/10/logo.jpg' title='Logo poEdit'><img src='http://www.coders4fun.com/wp-content/uploads/2007/10/logo.jpg' alt='Logo poEdit' /></a></p>
<p>To prepare the source code to the localization, we must sorround all strings that we want to localize with the macro &#8220;_()&#8221;, for example:</p>
<pre class="prettyprint">
...
wxMessageBox( _("localized string") );
...
wxMessageBox( wxT("not localized string") );
</pre>
<p><span id="more-66"></span><br />
When all strings to translate are sorrounded with the macro, we can start the translation process launching poEdit: when we run the program for the first time, it will ask us general information about the team, the author of the translation, the language and other boredoms.</p>
<p><a href='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot1.JPG' title='poEdit Preferences'><img width="440" height="306" src='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot1.JPG' alt='poEdit Preferences' /></a></p>
<p>When the program has been started go to &#8220;File&#8221;, &#8220;New Catalog&#8221;</p>
<p><a href='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot2.JPG' title='poEdit new project settings'><img width="500" height="215" src='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot2.JPG' alt='poEdit new project settings' /></a></p>
<p>Compile the &#8220;Project info&#8221; tab as in picture, go to the &#8220;Paths&#8221; tab and add the source code path in the &#8220;Base path&#8221; text box and in the paths list below.<br />
Click &#8220;Ok&#8221; and save your &#8220;.po&#8221; file in the project directory.<br />
Now you can see a summary windows that shows all strings that you can to translate:</p>
<p><a href='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot3.JPG' title='poEdit Update Summary'><img src='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot3.JPG' alt='poEdit Update Summary' /></a></p>
<p>If you get an error, don&#8217;t worry! Go on &#8220;Catalog&#8221; -&gt; &#8220;Update from sources&#8221; and all should go right.</p>
<p><a href='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot4.JPG' title='poEdit Main Window'><img width="400" height="291" src='http://www.coders4fun.com/wp-content/uploads/2008/01/screenshot4.JPG' alt='poEdit Main Window' /></a></p>
<p>Now go to &#8220;View&#8221; -&gt; &#8220;Display quotes&#8221; and start the translation! In the left bottom textbox you can insert the the translation of the string, inside the quotes.<br />
When you finish the translation you can save, and you&#8217;ll find in the project directory the files &#8220;default.po&#8221; and &#8220;default.mo&#8221;. The file &#8220;.mo&#8221; is the real localization file, but if you want to change the translation use the &#8220;.po&#8221; file, so don&#8217;t delete it.</p>
<div>
<div>
<div>
<div>
<blockquote>
<p>Part 2 of the article &#8220;Localization of a c++ wx project (using poEdit)&#8221; will be published soon.</p>
</blockquote>
</div>
</div>
</div>
</div>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=jeSSKG"><img src="http://feeds.feedburner.com/~a/coders4fun?i=jeSSKG" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/288603469" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2008/01/04/how-to-poedit-wx/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2008/01/04/how-to-poedit-wx/</feedburner:origLink></item>
		<item>
		<title>Automatically change upload limits in aMule</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/288603470/</link>
		<comments>http://www.coders4fun.com/en/2007/12/29/automatically-change-upload-limits-amule/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 11:52:02 +0000</pubDate>
		<dc:creator>inandrea</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://raynor/wordpress/en/2007/12/29/automatically-change-upload-limits-amule/</guid>
		<description><![CDATA[Every serious home-server should have aMule installed as daemon.
Unfortunately aMule, like all p2p programs, can slow down our connection, even if we aren&#8217;t downloading a thing or if we have few downloads remaining, because it use the upload bandwidth to share the downloaded files. We can lower the upload bandwidhth limit but if we lower [...]]]></description>
			<content:encoded><![CDATA[<p>Every serious home-server should have <a href="http://www.amule.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.amule.org/');">aMule</a> installed as daemon.<br />
Unfortunately aMule, like all p2p programs, can slow down our connection, even if we aren&#8217;t downloading a thing or if we have few downloads remaining, because it use the upload bandwidth to share the downloaded files. We can lower the upload bandwidhth limit but if we lower it too much we will consequently download very slowly.</p>
<p><img src='http://www.coders4fun.com/wp-content/uploads/2007/11/amule.jpg' alt='amule' /></p>
<p>Instead of continually, manually change the upload limit according to our needs, I use a little script that I wrote, that automatically set the bandwidth limits from the number of downloads in the queue. To use this script we must have the amulecmd utility installed (from source code or from distro packages).<br />
<span id="more-65"></span><br />
The script in his defaults settings sets the upload limit to 2KB/s if there aren&#8217;t file in the downlaod queue; if there are three files or less, the upload limit is setted to 10KB/s; in the other cases (more of three files downloaded), the upload is setted to 30KB/s.<br />
The beginning of the script contains well commented parameters to change the script behaviour.</p>
<pre class="prettyprint">
#!/bin/sh

#password to connect to the amule daemon
PASSWORD="abc"
#command to execute to connect to the daemon
AMULE_COMMAND="amulecmd"
#upload limit when there is no file in the download queue
IDLE_BW_UP=2
#min number of files in download queue to set the upload limit
#to the "normal" value
MIN_DW_LIMIT=2
#upload limit when the number of file in download queue is &gt;= 1
#and  MIN_DW_LIMIT
NORMAL_BW_UP=30

UP_LIMIT="set bwlimit up "
DW_LIMIT="set bwlimit down "
COMMAND="$AMULE_COMMAND -P$PASSWORD -c"

if [ -z "$(pgrep amuled)" ]; then
    #echo &#8220;amule closed&#8221;
    exit
fi

setUploadBw()
{
    CURR_BW_UP=`expr substr &#8220;$($COMMAND &#8220;get bwlimits&#8221; | grep &#8220;Up&#8221;)&#8221; 24 2`
    if [ "$CURR_BW_UP" -ne "$1" ]; then
        $COMMAND &#8220;$UP_LIMIT $1&#8243; &gt; /dev/null
        $COMMAND &#8220;$DW_LIMIT 0&#8243; &gt; /dev/null
        echo &#8220;$0: Upload bandwidth limit is now $1 kB/s&#8221;
    fi
}
NDOWN=$($COMMAND &#8220;show dl&#8221; | grep -c &#8220;&gt;&#8221;)

if [ "$NDOWN" -le 0 ];then
    setUploadBw $IDLE_BW_UP
else
    if [ "$NDOWN" -le "$MIN_DW_LIMIT" ]; then
        setUploadBw $MIN_BW_UP
    else
        setUploadBw $NORMAL_BW_UP
    fi
fi
</pre>
<p>To use the script, paste it to a file named &#8220;setamulebandwidth&#8221;, modify the parameters you need, and save it to /usr/bin. After that, set the execution rights to the script:<br />
<code><br />
#chmod a+x /usr/bin/setamulebandwidth<br />
</code></p>
<p>Of course we want to execute thes script automatically at least every 5 minutes (personally, I prefer to run it every minute), and to do that we can use the cron.<br />
Type from your administrative account (add sudo at the start of the command if you are using Ubuntu):<br />
<code><br />
# sudo crontab -e<br />
and add the following line<br />
*/5       *       *       *       *       /usr/bin/setamulebandwidth<br />
</code><br />
Where the */5 means that the script will executed every 5 minutes.<br />
Save the file.</p>
<p>Now your aMule will change the upload limit dinamically from the number of downloads in queue! <img src='http://www.coders4fun.com/en/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=Bub4FJ"><img src="http://feeds.feedburner.com/~a/coders4fun?i=Bub4FJ" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/288603470" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2007/12/29/automatically-change-upload-limits-amule/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2007/12/29/automatically-change-upload-limits-amule/</feedburner:origLink></item>
		<item>
		<title>First public version of USBAutoStart!</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/288603471/</link>
		<comments>http://www.coders4fun.com/en/2007/12/11/usb-autostart-02-released/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 17:14:46 +0000</pubDate>
		<dc:creator>dzamir</dc:creator>
		
		<category><![CDATA[C]]></category>

		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[USBAutoStart]]></category>

		<guid isPermaLink="false">http://raynor/wordpress/en/2007/12/11/usb-autostart-02-released/</guid>
		<description><![CDATA[
Usbautostart is a Windows utility that performs autoplay for usb mass storage device. Windows avoid the autoplay on the removable medias for security reasons, but with this program you can bypass this limit and you can choose to launch a program in the usb pen when you plug it.
The program will also close all applications [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.coders4fun.com/wp-content/uploads/2007/06/usb_coders4fun.jpg' alt='USB AutoStart' /></p>
<p>Usbautostart is a Windows utility that performs autoplay for usb mass storage device. Windows avoid the autoplay on the removable medias for security reasons, but with this program you can bypass this limit and you can choose to launch a program in the usb pen when you plug it.<br />
The program will also close all applications running from the device when you try to &#8220;safety remove&#8221; it.</p>
<p><strong>Screenshots:</strong></p>
<p>Usb peripheral detection (the red icon on the left is <a href="http://www.mozillaitalia.it/mozup/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.mozillaitalia.it/mozup/');">Mozup</a>, the program started from the usb pen):<br />
<img src='http://www.coders4fun.com/wp-content/uploads/2007/12/usbautostart1.JPG' alt='USB AutoStart Inserting device' /></p>
<p>Usb removal:<br />
<img src='http://www.coders4fun.com/wp-content/uploads/2007/12/usbautostart2.JPG' alt='USB AutoStart Removing device' /></p>
<p>The project is hosted on <a href="https://sourceforge.net/projects/usbautostart" onclick="javascript:pageTracker._trackPageview('/outbound/article/https://sourceforge.net/projects/usbautostart');">sourceforge</a>, and it&#8217;s released under GPL license, so it&#8217;s completely free and open source! <img src='http://www.coders4fun.com/en/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<blockquote><p>Download <a href="http://sourceforge.net/project/platformdownload.php?group_id=197021" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://sourceforge.net/project/platformdownload.php?group_id=197021');">Usb Autostart</a></p>
</blockquote>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=i7oCgI"><img src="http://feeds.feedburner.com/~a/coders4fun?i=i7oCgI" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/288603471" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2007/12/11/usb-autostart-02-released/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2007/12/11/usb-autostart-02-released/</feedburner:origLink></item>
		<item>
		<title>Coders4fun Quiz #2</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/288603472/</link>
		<comments>http://www.coders4fun.com/en/2007/11/22/coders4fun-quiz-en-2/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 17:07:18 +0000</pubDate>
		<dc:creator>dzamir</dc:creator>
		
		<category><![CDATA[Quiz]]></category>

		<guid isPermaLink="false">http://raynor/wordpress/en/2007/11/22/coders4fun-quiz-en-2/</guid>
		<description><![CDATA[This quiz is not original and isn&#8217;t about programming but I think it&#8217;s funny, so I publish it! 
There is a pullman with 7 girls.
Every girl has 7 rucksack.
In each rucksack there are 7 big cats.
Every big cat has 7 small cats.
Every cat has 4 legs.

How much legs there are in the pullman?
]]></description>
			<content:encoded><![CDATA[<p>This quiz is not original and isn&#8217;t about programming but I think it&#8217;s funny, so I publish it! <img src='http://www.coders4fun.com/en/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
<em>There is a pullman with 7 girls.<br />
Every girl has 7 rucksack.<br />
In each rucksack there are 7 big cats.<br />
Every big cat has 7 small cats.<br />
Every cat has 4 legs.<br />
</em></p>
<p><strong>How much legs there are in the pullman?</strong></p>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=Yi0ck7"><img src="http://feeds.feedburner.com/~a/coders4fun?i=Yi0ck7" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/288603472" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2007/11/22/coders4fun-quiz-en-2/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2007/11/22/coders4fun-quiz-en-2/</feedburner:origLink></item>
		<item>
		<title>MySQLDump 2.0</title>
		<link>http://feeds.feedburner.com/~r/coders4fun/~3/288603473/</link>
		<comments>http://www.coders4fun.com/en/2007/10/19/mysqldump-2-php-backup-mysql-database/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 17:10:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://raynor/wordpress/en/2007/10/19/mysqldump-2-php-backup-mysql-database/</guid>
		<description><![CDATA[




This is a guest post from Daniele





After a lot of work, I released the new version (2.0) of the MySQLDump class, already introduced by this article.
MySQLDump is a class that allows to do a complete MySQL database backup with php pages.
After the inandrea&#8217;s good work there wasn&#8217;t too much space for improvements, but I think [...]]]></description>
			<content:encoded><![CDATA[<div>
<div>
<div>
<div>
<blockquote>
<p>This is a guest post from <a href="http://www.creativefactory.it" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.creativefactory.it');">Daniele</a></p>
</blockquote>
</div>
</div>
</div>
</div>
<p>After a lot of work, I released the new version (2.0) of the MySQLDump class, already introduced by this <a href="http://www.coders4fun.com/2007/06/23/dump-mysql-php-backup/en/" >article</a>.<br />
MySQLDump is a class that allows to do a complete MySQL database backup with php pages.</p>
<p>After the <a href="http://www.coders4fun.com/author/inandrea/it/" >inandrea&#8217;s</a> good work there wasn&#8217;t too much space for improvements, but I think that these addition can be usefull: now it&#8217;s possible to export structures and/or data not only for the selected database but also for a single table.</p>
<p>The following example will explain how to export the structure and the data for the table <em>mytable</em> in the db  <em>mydb</em> (the interface to the class is slightly changed from the previous version).</p>
<pre class="prettyprint">
//Include the library
@include_once('lib_dump.php');
//Db connection
$connection = @mysql_connect('127.0.0.1','username','password');
//Create the MySQLDump class instance
//1° parameter: db name
//2° parameter: the exported file that will contain the dump
//3° parameter: create zipped file (true = zipped, false = normal)
//4° parameter: data encode (true = hexadecimal, false = plain text)
$dumper = new MySQLDump('mydb','dumpfile.sql',false,false);
//Structure export of the table 'mytable'
$dumper-&gt;getTableStructure('mytable');
//Data export of the table 'mytable'
$dumper-&gt;getTableData('mytable');
</pre>
<p><span id="more-62"></span><br />
In this way we will obtain the complete dump of the tumble <em>mytable</em> in the file <em>dumpfile.sql</em> (with the term <em>dump</em> we refers to a sql instruction that can recreate the table and the data). Of course, if for some reasons we don&#8217;t need both structure and data, we can always create the dump only for the table structure or for the data.<br />
Instead, if we want to do the complete backup of the database, we must use these instructions:</p>
<pre class="prettyprint">
@include_once('lib_dump.php');
$connection = @mysql_connect('127.0.0.1','username','password');
$dumper = new MySQLDump('mydb','dumpfile.sql',false,false);
$dumper-&gt;doDump();
</pre>
<p>Or, to obtain the structure and the data separately:</p>
<pre class="prettyprint">
@include_once('lib_dump.php');
$connection = @mysql_connect('127.0.0.1','username','password');
$dumper = new MySQLDump('mydb','dumpfile.sql',false,false);
$dumper-&gt;getDatabaseStructure();
$dumper-&gt;getDatabaseData();
</pre>
<p>I hope that this class can be usefull to you, and I invite you to visit the specific section of my site (<a href="http://www.creativefactory.it/lab/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.creativefactory.it/lab/');">http://www.creativefactory.it/lab/</a>) where you can find the complete documentation generated with <a href="http://www.phpdoc.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.phpdoc.org/');">phpdoc</a>.</p>
<div>
<div>
<div>
<div>
<blockquote>
<p>Download <a href="http://www.coders4fun.com/en/wp-content/plugins/download-monitor/download.php?id=1"  title="Version 2.0 downloaded 2833 times" >MySQLDump</a>. Downloads: 2833</p>
</div>
</div>
</div>
</div>

<p><a href="http://feeds.feedburner.com/~a/coders4fun?a=A0I2eC"><img src="http://feeds.feedburner.com/~a/coders4fun?i=A0I2eC" border="0"></img></a></p><img src="http://feeds.feedburner.com/~r/coders4fun/~4/288603473" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coders4fun.com/en/2007/10/19/mysqldump-2-php-backup-mysql-database/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.coders4fun.com/en/2007/10/19/mysqldump-2-php-backup-mysql-database/</feedburner:origLink></item>
	</channel>
</rss>
