<?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>Kamibu &#187; Linux</title>
	<atom:link href="http://blog.kamibu.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kamibu.com</link>
	<description></description>
	<lastBuildDate>Sat, 14 Nov 2009 10:51:14 +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>Change default permission modes on Linux servers</title>
		<link>http://blog.kamibu.com/2009/03/28/change-default-permission-modes-on-linux-servers/</link>
		<comments>http://blog.kamibu.com/2009/03/28/change-default-permission-modes-on-linux-servers/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 21:46:01 +0000</pubDate>
		<dc:creator>ch-world</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=81</guid>
		<description><![CDATA[For our Kamibu projects we use Subversion for versioning of our code. As we aren&#8217;t only one person each other user on our server has to be able to modify files created by the svn command. Thus files need to get created with 0660 as their permission modes. The default permission modes on a debian [...]]]></description>
			<content:encoded><![CDATA[<p>For our Kamibu projects we use Subversion for versioning of our code. As we aren&#8217;t only one person each other user on our server has to be able to modify files created by the svn command. Thus files need to get created with 0660 as their permission modes. The default permission modes on a debian system seem to be 0644. To change this behavior you&#8217;ve to edit /etc/profile. Search for the umask line.</p>
<p>On our fresh installed server it looked like this:</p>
<blockquote><p>umask 022</p></blockquote>
<p>This means 777 &#8211; 022 = 755. For directorys this is correct, to get the permission modes of a file you&#8217;ve to subtract 111. So after editing this line and saving the file you should logout and with your next login you will benefit from your new default permission modes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2009/03/28/change-default-permission-modes-on-linux-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RabbitEdit</title>
		<link>http://blog.kamibu.com/2008/10/04/rabbitedit/</link>
		<comments>http://blog.kamibu.com/2008/10/04/rabbitedit/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 19:37:40 +0000</pubDate>
		<dc:creator>Indy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=65</guid>
		<description><![CDATA[RabbitEdit is a nifty tool that allows easier Rabbit development and saves you quite some time and effort. Its purpose is to automatically do particular common things for you, like writing pieces of code, creating parent directories for your new source files, and add the newly created files (and directories) into the SVN repository. It [...]]]></description>
			<content:encoded><![CDATA[<p>RabbitEdit is a nifty tool that allows easier Rabbit development and saves you quite some time and effort.<br />
Its purpose is to automatically do particular common things for you, like writing pieces of code, creating parent directories for your new source files, and add the newly created files (and directories) into the SVN repository.<br />
It can be found in rabbit/etc/rabbitedit/ and its installation is as simple as:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;"># make install </span></pre><br />
You can uninstall it similarly, running:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;"># make uninstall </span></pre><br />
Its configuration file can be found at /etc/rabbitedit/rabbitedit.conf and follows the common configuration rules used by the most programs.<br />
You can see how it works, by issuing:</p>
<p><pre class="php">$ rabbitedit --help</pre><br />
A simple example of its usage, could be the following:</p>
<p><pre class="php">$ rabbitedit --parents --svn libs/customer/settings.php</pre><br />
Let&#8217;s assume you are in the root directory of your rabbit project. By running the above, RabbitEdit creates libs/customer/ if it does not exist (this is indicated by the &#8220;&#8211;parents&#8221; option), adds that directory into the SVN repository (indicated by &#8220;&#8211;svn&#8221;) as well as libs/customer/settings.php, and if settings.php did not exist before, it creates it and writes a standard piece of code in it (having the information that the file is a lib, and is about the settings of customers). If the file existed before, it leaves it as it was. Then, it opens the file with the source code editor of your choice.</p>
<p>RabbitEdit is written in Python, and is designed with the hope it fastens up the development of Rabbit projects and gives developers the chance to avoid drudgery, and focus on really important things, like actually coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/10/04/rabbitedit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8220;echo&#8221; and &#8220;md5sum&#8221;</title>
		<link>http://blog.kamibu.com/2008/10/04/echo-and-md5sum/</link>
		<comments>http://blog.kamibu.com/2008/10/04/echo-and-md5sum/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 18:37:24 +0000</pubDate>
		<dc:creator>Indy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=53</guid>
		<description><![CDATA[A problem I faced when I attempted to manually set a password for my user in Water, was that I could not login. I created the md5 sum of my password, running: $ echo mypassword&#124;md5sum and pasted it into the MySQL field of phpMyAdmin. After many login failures and enough searching about what is to [...]]]></description>
			<content:encoded><![CDATA[<p>A problem I faced when I attempted to manually set a password for my user in Water, was that I could not login. I created the md5 sum of my password, running:</p>
<p><pre class="php">$ <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> mypassword|md5sum</pre></p>
<p>and pasted it into the MySQL field of phpMyAdmin. After many login failures and enough searching about what is to blame, Kostis90gr found out that &#8220;echo&#8221;, is outputting a newline at the end of the string, so the md5 sum produced from the command above, was different than the one produced from PHP&#8217;s md5() function, simply because they were given different input. So, the right thing to do, is to pass &#8220;echo&#8221; the &#8220;-n&#8221; option, like:</p>
<p><pre class="php">$ <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> -n mypassword|md5sum</pre></p>
<p>which prevents &#8220;echo&#8221; from outputting a newline at the end of the string.<br />
I hope this post is helpful, because my unawareness of this &#8220;echo&#8221;&#8216;s little &#8220;particularity&#8221;, caused me quite enough frustration.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/10/04/echo-and-md5sum/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Overloading in PHP must use public methods</title>
		<link>http://blog.kamibu.com/2008/07/25/overloading-in-php-must-use-public-methods/</link>
		<comments>http://blog.kamibu.com/2008/07/25/overloading-in-php-must-use-public-methods/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 17:55:10 +0000</pubDate>
		<dc:creator>dionyziz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=40</guid>
		<description><![CDATA[The magically overloading methods in PHP, such as __get, and __set must be public according to The PHP Manual. Aleksis recently pointed that out to me by making his new methods public, which gave me the initiative to look it up at the manual. I thought this script to convert them might end up being [...]]]></description>
			<content:encoded><![CDATA[<p>The magically overloading methods in PHP, such as __get, and __set must be public according to <a href="http://gr.php.net/manual/en/language.oop5.overloading.php">The PHP Manual</a>.</p>
<p><a href="http://www.kamibu.com/about/abresas">Aleksis</a> recently pointed that out to me by making his new methods public, which gave me the initiative to look it up at the manual.</p>
<p>I thought this script to convert them might end up being useful to others, too:<br />
<pre class="bash"><span style="color: #b1b100;">for</span> i <span style="color: #b1b100;">in</span> `find -iname <span style="color: #ff0000;">&quot;*.php&quot;</span>
               |xargs egrep -i <span style="color: #ff0000;">&quot;(private|protected) function __(get|set)&quot;</span>
               |awk -F: <span style="color: #ff0000;">'{print $1}'</span>`
<span style="color: #b1b100;">do</span> 
sed <span style="color: #ff0000;">'s/<span style="color: #000099; font-weight: bold;">\(</span>private<span style="color: #000099; font-weight: bold;">\|</span>protected<span style="color: #000099; font-weight: bold;">\)</span> function __<span style="color: #000099; font-weight: bold;">\(</span>get<span style="color: #000099; font-weight: bold;">\|</span>set<span style="color: #000099; font-weight: bold;">\)</span>/public function __<span style="color: #000099; font-weight: bold;">\2</span>/'</span> <span style="color: #0000ff;">$i</span> &gt;<span style="color: #0000ff;">$i</span>.processed;
mv <span style="color: #0000ff;">$i</span>.processed <span style="color: #0000ff;">$i</span>
<span style="color: #b1b100;">done</span></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/07/25/overloading-in-php-must-use-public-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change collation on all columns of a database</title>
		<link>http://blog.kamibu.com/2008/05/25/change-collation-on-all-columns-of-a-database/</link>
		<comments>http://blog.kamibu.com/2008/05/25/change-collation-on-all-columns-of-a-database/#comments</comments>
		<pubDate>Sun, 25 May 2008 10:51:08 +0000</pubDate>
		<dc:creator>dionyziz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=36</guid>
		<description><![CDATA[It was recently required for me to change the collation of each and every column of every table in a database from &#8216;latin1&#8242; to &#8216;utf8&#8242;. Although the table collations were correct, the column collations were incorrect. It&#8217;s a cumbersome process to perform manually, and there&#8217;s apparently no real automated way to do it without a [...]]]></description>
			<content:encoded><![CDATA[<p>It was recently required for me to change the collation of each and every column of every table in a database from &#8216;latin1&#8242; to &#8216;utf8&#8242;. Although the table collations were correct, the column collations were incorrect. It&#8217;s a cumbersome process to perform manually, and there&#8217;s apparently <a href="http://lists.mysql.com/mysql/186286">no real automated way to do it without a script</a>. Although collation information is only meta-data, not actual data, I found this problem interesting.</p>
<p>Changing one column collation information is easy enough to do with one MySQL query:</p>
<p><pre class="php">ALTER TABLE `moods` 
CHANGE `mood_label` `mood_label` text CHARACTER SET utf8 COLLATE utf8_unicode_ci;</pre></p>
<p>Changing all the columns is more difficult. Here&#8217;s a small script that I came up with to do it recently:</p>
<p><pre class="php">dionyziz@orion:~$ mysqldump -u root --password=<span style="color: #cc66cc;">1234</span> \ 
--no-data --no-create-db --<a href="http://www.php.net/compact"><span style="color: #000066;">compact</span></a> ccbeta \
|egrep <span style="color: #ff0000;">'CREATE TABLE|latin1'</span> \
|sed <span style="color: #ff0000;">'s/CREATE TABLE `<span style="color: #000099; font-weight: bold;">\(</span>.*<span style="color: #000099; font-weight: bold;">\)</span>` (/;ALTER TABLE `<span style="color: #000099; font-weight: bold;">\1</span>`/'</span> \
|sed <span style="color: #ff0000;">'s/character set latin1/CHARACTER SET utf8 COLLATE utf8_unicode_ci/'</span> \
|sed <span style="color: #ff0000;">'s/  `<span style="color: #000099; font-weight: bold;">\(</span>.*<span style="color: #000099; font-weight: bold;">\)</span>`/ CHANGE `<span style="color: #000099; font-weight: bold;">\1</span>` `<span style="color: #000099; font-weight: bold;">\1</span>`/'</span>&gt;columns
dionyziz@orion:~$ php -r <span style="color: #ff0000;">'file_put_contents( &quot;columns&quot;, 
    preg_replace( &quot;#^;|ALTER TABLE `.*`(<span style="color: #000099; font-weight: bold;">\\</span>s*;|$)#&quot;, &quot;&quot;, 
    preg_replace( &quot;#,(<span style="color: #000099; font-weight: bold;">\\</span>s*);#&quot;, &quot;;<span style="color: #000099; font-weight: bold;">\\</span>1&quot;, 
    file_get_contents( &quot;columns&quot; ) ) ) );'</span>
dionyziz@orion:~$ <a href="http://www.php.net/mysql"><span style="color: #000066;">mysql</span></a> -u root --password=<span style="color: #cc66cc;">1234</span> ccbeta &lt;columns</pre></p>
<p>Let&#8217;s go through it step-by-step.</p>
<p><pre class="php">mysqldump -u root --password=<span style="color: #cc66cc;">1234</span> --no-data --no-create-db --<a href="http://www.php.net/compact"><span style="color: #000066;">compact</span></a> ccbeta</pre></p>
<p>This creates a list of CREATE TABLE statements for all our tables. That&#8217;s good because it&#8217;ll allow us to determine whether the collation of a column is incorrect. Here&#8217;s an example CREATE TABLE statement:</p>
<p><pre class="php">CREATE TABLE `albums` <span style="color: #66cc66;">&#40;</span>
  `album_id` int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> NOT <span style="color: #000000; font-weight: bold;">NULL</span> auto_increment,
  `album_userid` int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> NOT <span style="color: #000000; font-weight: bold;">NULL</span> <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #ff0000;">'0'</span>,
  `album_created` datetime NOT <span style="color: #000000; font-weight: bold;">NULL</span> <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #ff0000;">'0000-00-00 00:00:00'</span>,
  `album_name` text character set latin1 NOT <span style="color: #000000; font-weight: bold;">NULL</span>,
  `album_description` text character set latin1 NOT <span style="color: #000000; font-weight: bold;">NULL</span>,
  PRIMARY <a href="http://www.php.net/key"><span style="color: #000066;">KEY</span></a>  <span style="color: #66cc66;">&#40;</span>`album_id`<span style="color: #66cc66;">&#41;</span>,
  <a href="http://www.php.net/key"><span style="color: #000066;">KEY</span></a> `album_userid` <span style="color: #66cc66;">&#40;</span>`album_userid` <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE=MyISAM AUTO_INCREMENT=<span style="color: #cc66cc;">55</span> <span style="color: #000000; font-weight: bold;">DEFAULT</span> CHARSET=utf8 COLLATE=utf8_unicode_ci;</pre></p>
<p>In this example, the `album_name` and `album_description` columns are wrong and need their collations changed.</p>
<p><pre class="php">egrep <span style="color: #ff0000;">'CREATE TABLE|latin1'</span></pre></p>
<p>This simple line limits our results to only lines that contain &#8220;CREATE TABLE&#8221; or &#8220;latin1&#8243;. That&#8217;s useful since it&#8217;ll only show the table names followed by a list of all incorrectly collated columns, if any. The result would be something like this:</p>
<p><pre class="php">CREATE TABLE `relations` <span style="color: #66cc66;">&#40;</span>
CREATE TABLE `searches` <span style="color: #66cc66;">&#40;</span>
 `search_query` text character set latin1 NOT <span style="color: #000000; font-weight: bold;">NULL</span>,
CREATE TABLE `shoutbox` <span style="color: #66cc66;">&#40;</span>
 `shout_text` text character set latin1 NOT <span style="color: #000000; font-weight: bold;">NULL</span>,
 `shout_delreason` text character set latin1 NOT <span style="color: #000000; font-weight: bold;">NULL</span>,</pre></p>
<p>(with more entries potentially)</p>
<p>Good. Now all we need to do is modify these lines to make them ALTER TABLE lines:</p>
<p><pre class="php">sed <span style="color: #ff0000;">'s/CREATE TABLE `<span style="color: #000099; font-weight: bold;">\(</span>.*<span style="color: #000099; font-weight: bold;">\)</span>` (/;ALTER TABLE `<span style="color: #000099; font-weight: bold;">\1</span>`/'</span></pre></p>
<p>Ah, the magic of regular expressions. This removes the final &#8220;(&#8221; of every CREATE TABLE line, as we don&#8217;t need it and also changes the word &#8220;CREATE&#8221; into &#8220;ALTER&#8221;. It also adds a semicolon in front of the ALTER TABLE statement (to terminate the previous statement).</p>
<p><pre class="php">sed <span style="color: #ff0000;">'s/character set latin1/CHARACTER SET utf8 COLLATE utf8_unicode_ci/'</span></pre></p>
<p>Straightforward enough, this replaces the existing character set instruction from latin1 to utf8, and adds the correct collation as well.</p>
<p><pre class="php">sed <span style="color: #ff0000;">'s/  `<span style="color: #000099; font-weight: bold;">\(</span>.*<span style="color: #000099; font-weight: bold;">\)</span>`/ CHANGE `<span style="color: #000099; font-weight: bold;">\1</span>` `<span style="color: #000099; font-weight: bold;">\1</span>`/'</span></pre></p>
<p>Finally, this adds the word &#8220;CHANGE&#8221; in front of every column line and repeats the column name (as we want to tell MySQL which column to change (first repetition) and to which to change it (second repetition)). The result is:</p>
<p><pre class="php">;ALTER TABLE `relations`
;ALTER TABLE `searches`
 CHANGE `search_query` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT <span style="color: #000000; font-weight: bold;">NULL</span>,
;ALTER TABLE `shoutbox`
 CHANGE `shout_text` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT <span style="color: #000000; font-weight: bold;">NULL</span>,
 CHANGE `shout_delreason` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT <span style="color: #000000; font-weight: bold;">NULL</span>,</pre></p>
<p>Pretty close to what we actually want. You&#8217;ll notice three problems:</p>
<ul>
<li>There are empty ALTER statements</li>
<li>There&#8217;s an extra comma at the end of every column (providing all your tables have a primary key, as they should)</li>
<li>There&#8217;s a redundant semicolon at the beginning</li>
</ul>
<p>These problems cannot easily be fixed by sed because sed performs a line-to-line processing. A sed expert might have been able to provide us with a better solution, but I&#8217;ll prefer to use the PREG feature of PHP. To use PHP, first let&#8217;s save our current result into a file:</p>
<p><pre class="php">&gt;columns</pre></p>
<p>Time to run our PHP code on the target file:</p>
<p><pre class="php">php -r <span style="color: #ff0000;">'file_put_contents( &quot;columns&quot;, 
    preg_replace( &quot;#^;|ALTER TABLE `.*`(<span style="color: #000099; font-weight: bold;">\\</span>s*;|$)#&quot;, &quot;&quot;, 
    preg_replace( &quot;#,(<span style="color: #000099; font-weight: bold;">\\</span>s*);#&quot;, &quot;;<span style="color: #000099; font-weight: bold;">\\</span>1&quot;, 
    file_get_contents( &quot;columns&quot; ) ) ) );'</span></pre></p>
<p>Let&#8217;s analyze it in short.</p>
<p><pre class="php"><a href="http://www.php.net/file_get_contents"><span style="color: #000066;">file_get_contents</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;columns&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>This, simply enough, reads the &#8220;columns&#8221; file into memory. Now we&#8217;ll perform two regular expression replacements:</p>
<p>First, we&#8217;ll match the following regular expression:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;">#,(\s*);# </span></pre></p>
<p>(notice that the # are separators that wrap the regular expression for clarity &#8212; they aren&#8217;t part of the actual regular expression)</p>
<p>Anything matching this will be replaced by ;\1. This means that a comma followed by any whitespace (including a new line) followed by a semicolon will be replaced by only a semicolon (and the same whitespace). This simply removes the redundant comma at the end of every ALTER statement.</p>
<p>Second, we&#8217;ll match the following:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;">#^;|ALTER TABLE `.*`(\\s*;|$)# </span></pre></p>
<p>Anything matching will be removed. You&#8217;ll notice that this regular expression matches basically two things (separated by the first alternation (pipe) character). </p>
<p>The first part is:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;">#^;# </span></pre></p>
<p>It&#8217;ll remove the first line if it only contains a single semicolon (which it does in our example). </p>
<p>The second part is:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;">#ALTER TABLE `.*`(\\s*;|$)# </span></pre></p>
<p>This will look for empty ALTER TABLE statements (an ALTER TABLE statement followed only by whitespace and a semicolon or an end-of-file) and remove them. </p>
<p>Finally, we&#8217;ll write the result back to the file we read from:</p>
<p><pre class="php">file_put_contents<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;columns&quot;</span>, ... <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>Now if we <em>cat </em> that file we&#8217;ll see that it contains all ALTER statements in the form we want them:</p>
<p><pre class="php">ALTER TABLE `searches`
 CHANGE `search_query` `search_query` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT <span style="color: #000000; font-weight: bold;">NULL</span>;
ALTER TABLE `shoutbox`
 CHANGE `shout_text` `shout_text` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT <span style="color: #000000; font-weight: bold;">NULL</span>,
 CHANGE `shout_delreason` `shout_delreason` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT <span style="color: #000000; font-weight: bold;">NULL</span>;</pre></p>
<p>Excellent. Finally, let&#8217;s execute it:</p>
<p><pre class="php"><a href="http://www.php.net/mysql"><span style="color: #000066;">mysql</span></a> -u root --password=<span style="color: #cc66cc;">1234</span> ccbeta &lt;columns</pre></p>
<p>You can also add &#8216;time&#8217; in front of it to measure how long it&#8217;ll take. We can now validate that the collations were changed successfully by, again, performing our initial dump and grepping for &#8216;latin1&#8242; to confirm that there are none.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/05/25/change-collation-on-all-columns-of-a-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Accessing MySQL using a SSH-Tunnel</title>
		<link>http://blog.kamibu.com/2008/05/21/accessing-mysql-using-a-ssh-tunnel/</link>
		<comments>http://blog.kamibu.com/2008/05/21/accessing-mysql-using-a-ssh-tunnel/#comments</comments>
		<pubDate>Wed, 21 May 2008 09:26:48 +0000</pubDate>
		<dc:creator>ch-world</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=35</guid>
		<description><![CDATA[Due to security aspects MySQL server often only listen on localhost and accessing them remotely is not possible. With a simple trick you can access them with your favourite tool aswell. ssh -l login_name -N -L [bind_address:]port:host:hostport remoteServer login_name is your username on the remote machine bind_address is the local interface&#8217;s address where the tunnel [...]]]></description>
			<content:encoded><![CDATA[<p>Due to security aspects MySQL server often only listen on localhost and accessing them remotely is not possible. With a simple trick you can access them with your favourite tool aswell.</p>
<pre lang="bash">ssh -l login_name -N -L [bind_address:]port:host:hostport remoteServer</pre>
<p>login_name is your username on the remote machine<br />
bind_address is the local interface&#8217;s address where the tunnel should bind to<br />
port is the local port the tunnel should bind to<br />
host is the remote host to which you want to connect<br />
hostport is the remote port to which you want to connect<br />
remoteServer is the server using which you want to etablish the tunnel<br />
-N should disable starting the login shell</p>
<p>So for creating a tunnel for MySQL the command looks like this:</p>
<pre lang="bash">ssh -l user-remote -N -L 123456:localhost:3306 remoteServer</pre>
<p>This create a tunnel to MySQL running on remoteServer. You are able to access MySQL on port 123456 on localhost. For example you can use the following command:</p>
<pre lang="bash">mysql --port=123456 -h 127.0.0.1 --user=mysqlUser --password=mysqlPassword database</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/05/21/accessing-mysql-using-a-ssh-tunnel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to change your standard editor</title>
		<link>http://blog.kamibu.com/2008/04/13/how-to-change-your-standard-editor/</link>
		<comments>http://blog.kamibu.com/2008/04/13/how-to-change-your-standard-editor/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 20:26:06 +0000</pubDate>
		<dc:creator>ch-world</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=34</guid>
		<description><![CDATA[Everyone who is using linux knows that if you type editor in a bash shell an editor opens. But where can you change that editor? Change the editor temporarily Just execute the following on your shell: export EDITOR=joe Change the editor forever Edit ~/.bash_profile and add the following: export EDITOR=joe]]></description>
			<content:encoded><![CDATA[<p>Everyone who is using linux knows that if you type <em>editor</em> in a bash shell an editor opens. But where can you change that editor?</p>
<p><strong>Change the editor temporarily</strong></p>
<p>Just execute the following on your shell:</p>
<pre lang="bash">export <span class="highlight">EDITOR</span>=joe</pre>
<p><strong>Change the editor forever</strong></p>
<p>Edit ~/.bash_profile and add the following:</p>
<pre lang="bash">export EDITOR=joe</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/04/13/how-to-change-your-standard-editor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fighting against DDoS</title>
		<link>http://blog.kamibu.com/2008/03/12/fighting-against-ddos/</link>
		<comments>http://blog.kamibu.com/2008/03/12/fighting-against-ddos/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 11:00:37 +0000</pubDate>
		<dc:creator>ch-world</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/2008/03/12/fighting-against-ddos/</guid>
		<description><![CDATA[The last week we had some downtimes due to a distributed denial-of-service attack. I&#8217;m not sure if it was directly related to our Kamibu projects because there is a bug in the current lighttpd version. An attack can cause a bufferoverflow of Lighttpd with a DDoS. So at all someone tried to get our sites [...]]]></description>
			<content:encoded><![CDATA[<p>The last week we had some downtimes due to a distributed denial-of-service attack. I&#8217;m not sure if it was directly related to our Kamibu projects because there is a bug in the current lighttpd version. An attack can cause a bufferoverflow of Lighttpd with a DDoS. So at all someone tried to get our sites down.</p>
<p>Our solution is very easy. We created a little script fetching all connections by using netstat, counting the number of connections per IP and if there are more than x connections from a certain IP it will add the IP to our firewall. Very simple but helpfull. We execute the script periodically to stop a possible DDoS.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/03/12/fighting-against-ddos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KDE 4 Installation Guide for Gentoo</title>
		<link>http://blog.kamibu.com/2008/01/15/kde-4-installation-guide-for-gentoo/</link>
		<comments>http://blog.kamibu.com/2008/01/15/kde-4-installation-guide-for-gentoo/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 23:04:26 +0000</pubDate>
		<dc:creator>abresas</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/2008/01/15/kde-4-installation-guide-for-gentoo/</guid>
		<description><![CDATA[KDE 4 was released a few days ago. However, Gentoo developers have no yet included KDE 4 ebuilds to the portage tree, and thus Gentoo users have to install it by hand. The instructions here can be followed by users of other Linux distributions too, but for example Debian users may use apt-get, which is [...]]]></description>
			<content:encoded><![CDATA[<p>KDE 4 was <a href="http://kde.org/announcements/4.0/">released</a> a few days ago. However, Gentoo developers have no yet included KDE 4 ebuilds to the portage tree, and thus Gentoo users have to install it by hand.</p>
<p>The instructions here can be followed by users of other Linux distributions too, but for example Debian users may use apt-get, which is much less error-prone.</p>
<p>Actually, I am going to describe the way I installed KDE 4 to my own PC, and I cannot guarantee that this is going to work for you too. You have to be sure about what you are doing, as I don&#8217;t want to be blamed if someone&#8217;s computer is harmed in any way!</p>
<p><b> What you &#8216;ll need </b><br />
 * latest version of Qt (emerge -av qt)<br />
 * latest version of cmake (emerge -av cmake)<br />
 * I had KDE 3.5 installed, but I&#8217;m not sure if you actually need it<br />
 * Strigi <a href="strigi.sourceforge.net">strigi.sourceforge.net</a><br />
 * Soprano framework <a href="soprano.sourceforge.net">soprano.sourceforge.net</a><br />
 * QImageBlitz library <a href="http://sourceforge.net/projects/qimageblitz">http://sourceforge.net/projects/qimageblitz</a></p>
<p><b>Start the fun!</b></p>
<p>First of all, create a folder where you will build kde4. e.g.:<br />
<pre class="php"><a href="http://www.php.net/mkdir"><span style="color: #000066;">mkdir</span></a> ~/kde4
cd ~/kde4</pre></p>
<p>Now, download all the needed files from kde.org. You can use a bash script invoking the wget command:<br />
<pre class="php"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
&nbsp;
SERVER=<span style="color: #ff0000;">'http://files.kde.org/stable/4.0.0/src/'</span>
<span style="color: #808080; font-style: italic;">#add any other package you like</span>
FILES=<span style="color: #66cc66;">&#40;</span> kdelibs kdepimlibs kdebase kdebase-runtime kdebase-workspace kdebindings kdesdk kdeutils <span style="color: #66cc66;">&#41;</span> 
NAME_END=<span style="color: #ff0000;">'-4.0.0.tar.bz2'</span>
&nbsp;
<span style="color: #b1b100;">for</span> <a href="http://www.php.net/file"><span style="color: #000066;">file</span></a> in $<span style="color: #66cc66;">&#123;</span>FILES<span style="color: #66cc66;">&#91;</span>@<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span> 
<span style="color: #b1b100;">do</span>
    wget <span style="color: #0000ff;">$SERVER</span><span style="color: #0000ff;">$file</span><span style="color: #0000ff;">$NAME_END</span> &amp;&gt; /dev/<span style="color: #000000; font-weight: bold;">null</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Done downloading $file&quot;</span>;
done
&nbsp;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Done.&quot;</span></pre></p>
<p>write this to a file and execute it:<br />
<pre class="php">vi download.sh <span style="color: #808080; font-style: italic;"># (paste the code here)</span>
<a href="http://www.php.net/chmod"><span style="color: #000066;">chmod</span></a> u+x download.sh
./download.sh</pre></p>
<p>&#8230;or you could download them from <a href="http://www.kde.org/info/4.0.php">http://www.kde.org/info/4.0.php</a>&#8230;</p>
<p>I&#8217;ve included only the packages that I believe to be necessary. For a complete list enter the <a href="http://www.kde.org/info/4.0.php">kde download site</a>.</p>
<p><b>Building the packages!</b></p>
<p>Now, for every package you &#8216;ve downloaded, you &#8216;ll have to do the following: (e.g. for kdelibs)</p>
<p>1. Decompress the .tar.bz2 file<br />
<pre class="php">tar -xvjf kdelibs<span style="color: #cc66cc;">-4.0</span><span style="color: #cc66cc;">.0</span>.tar.bz2</pre></p>
<p>2. Make a new directory where you &#8221;ll build the package<br />
<pre class="php"><a href="http://www.php.net/mkdir"><span style="color: #000066;">mkdir</span></a> kdelibs-build</pre></p>
<p>3. Enter the directory and create the MakeFile for the package (via the cmake command):<br />
<pre class="php">cd kdelibs-build
cmake ../kdelibs<span style="color: #cc66cc;">-4.0</span><span style="color: #cc66cc;">.0</span></pre></p>
<p>4. Build and install the package<br />
<pre class="php">sudo make
sudo make install
cd ../</pre></p>
<p>You could actually create a nice little script to do this for the package of your choice: pkginstall.sh<br />
<pre class="php"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
&nbsp;
PACKAGE=$<span style="color: #cc66cc;">1</span>;
&nbsp;
tar -xvjf <span style="color: #0000ff;">$PACKAGE</span><span style="color: #cc66cc;">-4.0</span><span style="color: #cc66cc;">.0</span>.tar.bz2
<a href="http://www.php.net/mkdir"><span style="color: #000066;">mkdir</span></a> <span style="color: #0000ff;">$PACKAGE</span>-build
cd <span style="color: #0000ff;">$PACKAGE</span>-build
cmake ../<span style="color: #0000ff;">$PACKAGE</span><span style="color: #cc66cc;">-4.0</span><span style="color: #cc66cc;">.0</span>
sudo make
sudo make install
cd ../</pre></p>
<p>And now for e.g. kdeutils:<br />
<pre class="php">./pkginstall.sh kdeutils</pre><br />
but I think it would be better to write every command on its own, as you may encounter various errors.</p>
<p>The packages are recommended to be installed in this order:<br />
* kdelibs<br />
* kdepimlibs<br />
* kdebase<br />
* kdebase-runtime<br />
* kdebase-workspace<br />
* kdebindings<br />
* kdesdk<br />
* kdeutils </p>
<p>and any other package after these.</p>
<p><b>Try it out!</b></p>
<p>By now, you should have build KDE 4.<br />
To try it, execute this script: kde4.sh:<br />
<pre class="php"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
X -ac :<span style="color: #cc66cc;">1</span> &amp; export DISPLAY=:<span style="color: #cc66cc;">1</span>
<a href="http://www.php.net/exec"><span style="color: #000066;">exec</span></a> startkde</pre></p>
<p>The first line creates a new X display &#8211; e.g. I have X on tty7, and a new X display starts on tty8<br />
and the second starts the KDE.</p>
<p>If everything is ok, you are ready to use KDE 4!</p>
<p><b>Troubleshooting</b></p>
<p>First of all, the previous script for testing KDE 4, didn&#8217;t work on my PC. KDE 4 loaded OK, but just after it loaded, KDE 3 started on top of it! I had to write my own &#8220;startkde&#8221;, and thankfully it was easier than I thought: kde4.sh:<br />
<pre class="php"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
X -ac :<span style="color: #cc66cc;">1</span> &amp; export DISPLAY=:<span style="color: #cc66cc;">1</span>
plasma
<a href="http://www.php.net/exec"><span style="color: #000066;">exec</span></a> kwin
dolphin</pre></p>
<p>Instead of calling startkde, which doesn&#8217;t work as it should, we manually start plasma (the KDE desktop), kwin (the window manager for KDE) and the dolphin file manager.</p>
<p>And now, KDE 4 started, but it was very KDE 3-ish. I had to go to Computer -> System Settings on the main menu, and set all options on &#8220;Appearance&#8221; from &#8220;Plastique&#8221; to &#8220;Oxygen&#8221;, the default for KDE 4 (e.g. theme).</p>
<p>During building KDE 4 I got errors like: Package &#8220;X&#8221; missing, so I had to install that package. Don&#8217;t hesitate, and just do it.<br />
You&#8217;ll probably don&#8217;t face such a problem if you follow my instructions at &#8220;What you &#8216;ll need&#8221;.</p>
<p>Also, I got some errors during compiling (kdebase-4.0.0 I think), and I had to change some files. Specifically:<br />
I got an error in two files, that QWidget::SetAccessibleName was not defined, so I had to comment out one line from them. That didn&#8217;t produce any problems, but I don&#8217;t think that it is the best solution.</p>
<p>I hope you won&#8217;t have any other problems. If you have any, just post a comment!</p>
<p><b>In The End</b></p>
<p>Here we come to the end of this guide, I hope you had fun!</p>
<p>Happy KDE 4 for everyone! <img src='http://blog.kamibu.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><b>UPDATE:</b> Added description of what each line of the bash scripts does.<br />
<b>UPDATE 2:</b> KDE 4 ebuilds have been added to the portage tree, but they are masked on profile.mask and under ~x86 because they are unstable (and they are absolutely right).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/01/15/kde-4-installation-guide-for-gentoo/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>BASH coolness by dionyziz + kostis90gr</title>
		<link>http://blog.kamibu.com/2007/12/16/bash-coolness-by-dionyziz-kostis90gr/</link>
		<comments>http://blog.kamibu.com/2007/12/16/bash-coolness-by-dionyziz-kostis90gr/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 21:05:12 +0000</pubDate>
		<dc:creator>kostis90gr</dc:creator>
				<category><![CDATA[Excalibur]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/2007/12/16/bash-coolness-by-dionyziz-kostis90gr/</guid>
		<description><![CDATA[As dionyziz said below,Zino is our new name. To do that conversion, though, some hacks were needed.Mostly stuff like that: for i in $&#40; find -iname &#34;*.js&#34; ! -path &#34;*svn*&#34; &#41;; do sed -e 's/static.chit-chat.gr/static.zino.gr/g' $i &#62; $i-temp; mv -f $i-temp $i; done]]></description>
			<content:encoded><![CDATA[<p>As dionyziz said below,Zino is our new name. To do that conversion, though, some hacks were needed.Mostly stuff like that:</p>
<p><pre class="php"><span style="color: #b1b100;">for</span> i in $<span style="color: #66cc66;">&#40;</span> find -iname <span style="color: #ff0000;">&quot;*.js&quot;</span> ! -path <span style="color: #ff0000;">&quot;*svn*&quot;</span> <span style="color: #66cc66;">&#41;</span>; <span style="color: #b1b100;">do</span>
    sed -e <span style="color: #ff0000;">'s/static.chit-chat.gr/static.zino.gr/g'</span> <span style="color: #0000ff;">$i</span> &gt; <span style="color: #0000ff;">$i</span>-temp;
    mv -f <span style="color: #0000ff;">$i</span>-temp <span style="color: #0000ff;">$i</span>;
done</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2007/12/16/bash-coolness-by-dionyziz-kostis90gr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

