<?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>MadSoft</title>
	<atom:link href="http://www.madsoft.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.madsoft.org</link>
	<description></description>
	<lastBuildDate>Sat, 12 Dec 2009 20:47:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Integrating TinyMCE with Django</title>
		<link>http://www.madsoft.org/2009/12/09/integrating-tinymce-with-django/</link>
		<comments>http://www.madsoft.org/2009/12/09/integrating-tinymce-with-django/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 08:41:47 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tinymce]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/?p=89</guid>
		<description><![CDATA[Many people often want What You See Is What You Get (WYSIWYG) editors when creating content from within their web applications. This can be either in the Django admin control panel or for the end user. One of the most flexible and useful of the WYSIWYG editors currently available is TinyMCE due to its extensive [...]]]></description>
			<content:encoded><![CDATA[<p>Many people often want What You See Is What You Get (WYSIWYG) editors when creating content from within their web applications. This can be either in the Django admin control panel or for the end user. One of the most flexible and useful of the WYSIWYG editors currently available is TinyMCE due to its extensive plugin library and robust feature set. Integration with Django is relatively simple given that you extend the functionality of built in classes.</p>
<p>The first thing we will need to do is create a custom widget from forms.Textarea found in the django.forms module. We accomplish this by inheriting the Textarea class and overriding the constructor and render methods. Defining the relative path (on your web server) to the TInyMCE javascript source is also required here. So be aware that you will need to change that path to suite your environment. You may also want to change the content_css variable to include your sites&#8217; main CSS file. The following is the source code for widgets.py which should be place in your projects root directory.</p>
<p><span id="more-89"></span></p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django <span style="color: #ff7700;font-weight:bold;">import</span> forms
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">conf</span> <span style="color: #ff7700;font-weight:bold;">import</span> settings
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">utils</span>.<span style="color: black;">safestring</span> <span style="color: #ff7700;font-weight:bold;">import</span> mark_safe
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> AdvancedEditor<span style="color: black;">&#40;</span>forms.<span style="color: black;">Textarea</span><span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">class</span> Media:
		js = <span style="color: black;">&#40;</span><span style="color: #483d8b;">'/images/tiny_mce/tiny_mce.js'</span>,<span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, language=<span style="color: #008000;">None</span>, attrs=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
		<span style="color: #008000;">self</span>.<span style="color: black;">language</span> = language <span style="color: #ff7700;font-weight:bold;">or</span> settings.<span style="color: black;">LANGUAGE_CODE</span><span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
		<span style="color: #008000;">self</span>.<span style="color: black;">attrs</span> = <span style="color: black;">&#123;</span><span style="color: #483d8b;">'class'</span>: <span style="color: #483d8b;">'advancededitor'</span><span style="color: black;">&#125;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> attrs: <span style="color: #008000;">self</span>.<span style="color: black;">attrs</span>.<span style="color: black;">update</span><span style="color: black;">&#40;</span>attrs<span style="color: black;">&#41;</span>
		<span style="color: #008000;">super</span><span style="color: black;">&#40;</span>AdvancedEditor, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span>attrs<span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> render<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, name, value, attrs=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
		rendered = <span style="color: #008000;">super</span><span style="color: black;">&#40;</span>AdvancedEditor, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: black;">render</span><span style="color: black;">&#40;</span>name, value, attrs<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">return</span> rendered + mark_safe<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">''</span><span style="color: #483d8b;">'
		&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
		tinyMCE.init({
			mode: &quot;textareas&quot;,
			theme: &quot;advanced&quot;,
			plugins: &quot;advhr,table,emotions,media,insertdatetime,directionality&quot;,
			theme_advanced_toolbar_align: &quot;left&quot;,
			theme_advanced_toolbar_location: &quot;top&quot;,
			theme_advanced_buttons1:&quot;bold,italic,underline,strikethrough,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,formatselect,fontselect,fontsizeselect&quot;,
			theme_advanced_buttons2:&quot;bullist,numlist,outdent,indent,ltr,rtl,separator,link,unlink,anchor,image,separator,table,insertdate,inserttime,advhr,emotions,media,charmap,separator,undo,redo&quot;,
			theme_advanced_buttons3: &quot;&quot;,
			content_css: &quot;images/style.css&quot;,
			height: &quot;350px&quot;,
			width: &quot;653px&quot;
		});
		&amp;lt;/script&amp;gt;'</span><span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Now we need to create our form which enables us to use the new widget. Just as an example, we will make a form for use in the Django admin control panel: to show how to use the widget in model admin classes. We simply create  a standard ModelForm class as normal, except that the field you wish to use as your WYWISWYG editor must be a CharField. In my example, I create a simple form for use in the Django admin control panel to allow users to write news articles with advanced editing capabilities. You can do this for any class within any of your forms.py files in either the projects&#8217; main directory or within an application directory. The code is as follows:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django <span style="color: #ff7700;font-weight:bold;">import</span> forms
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">db</span>.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> get_model
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span>.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> User
<span style="color: #ff7700;font-weight:bold;">from</span> sodclan.<span style="color: black;">widgets</span> <span style="color: #ff7700;font-weight:bold;">import</span> AdvancedEditor
<span style="color: #ff7700;font-weight:bold;">from</span> sodclan.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> Article
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> ArticleModelAdminForm<span style="color: black;">&#40;</span>forms.<span style="color: black;">ModelForm</span><span style="color: black;">&#41;</span>:
	title = forms.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">50</span><span style="color: black;">&#41;</span>
	author = forms.<span style="color: black;">ModelChoiceField</span><span style="color: black;">&#40;</span>queryset=User.<span style="color: black;">objects</span>.<span style="color: #008000;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
	content = forms.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>widget=AdvancedEditor<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">class</span> Meta:
		model = Article</pre></div></div>

</blockquote>
<p>As you can see, we imported the AdvancedEditor class we created earlier including the Article class which represents the model we wish to associate the form with. Notice the widget for the content field has been set to AdvancedEditor(). Now we can modify our ModelAdmin class to utilize our form and thus allow us to use TinyMCE within the Django admin control panel. In my admin.py file, the code is as follows:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span> <span style="color: #ff7700;font-weight:bold;">import</span> admin
<span style="color: #ff7700;font-weight:bold;">from</span> sodclan.<span style="color: black;">forms</span> <span style="color: #ff7700;font-weight:bold;">import</span> ArticleModelAdminForm
<span style="color: #ff7700;font-weight:bold;">from</span> sodclan.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> ArticleAdmin<span style="color: black;">&#40;</span>admin.<span style="color: black;">ModelAdmin</span><span style="color: black;">&#41;</span>:
	list_display = <span style="color: black;">&#40;</span><span style="color: #483d8b;">'title'</span>, <span style="color: #483d8b;">'author'</span>, <span style="color: #483d8b;">'date'</span>,<span style="color: black;">&#41;</span>
	search_fields = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'title'</span>,<span style="color: black;">&#93;</span>
	date_hierarchy = <span style="color: #483d8b;">'date'</span>
	form = ArticleModelAdminForm
&nbsp;
admin.<span style="color: #dc143c;">site</span>.<span style="color: black;">register</span><span style="color: black;">&#40;</span>Article, ArticleAdmin<span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Here we import the model admin form we created in the last code segment. The only difference here from a normal ModelAdmin class is that we define the form field. We set this field to our form class, in this case: ArticleModelAdminForm. When finally run, the result will look something like this:</p>
<p><a href="http://www.madsoft.org/wp-content/uploads/2009/12/tinymce_django.png"><img class="alignnone size-medium wp-image-99" style="border: 0pt none;" title="Django TinyMCE" src="http://www.madsoft.org/wp-content/uploads/2009/12/tinymce_django-300x187.png" alt="Django TinyMCE" width="300" height="187" /></a></p>
<p>Remember that we used an example using the Django admin control panel just to show how to do it. But you can take this concept and apply it anywhere in your Django web application where you can utilize forms. Which allows you to make very rich, usable web applications very easily. Hope this helps, comment with any questions or remarks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2009/12/09/integrating-tinymce-with-django/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Using the Rcon protocol with Python</title>
		<link>http://www.madsoft.org/2009/11/26/using-the-rcon-protocol-with-python/</link>
		<comments>http://www.madsoft.org/2009/11/26/using-the-rcon-protocol-with-python/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 07:32:12 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[protocol]]></category>
		<category><![CDATA[rcon]]></category>
		<category><![CDATA[sockets]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/?p=82</guid>
		<description><![CDATA[Within the PC gaming community, it is quite useful to be able to control or monitor your servers programmatically. The almost universal standard being Rcon or &#8220;Remote Connection.&#8221; The protocol is overall very simple, it only requires a standard UDP socket and that you send a packet header with the login credentials per each request you [...]]]></description>
			<content:encoded><![CDATA[<p>Within the PC gaming community, it is quite useful to be able to control or monitor your servers programmatically. The almost universal standard being Rcon or &#8220;Remote Connection.&#8221; The protocol is overall very simple, it only requires a standard UDP socket and that you send a packet header with the login credentials per each request you make.</p>
<p>We will start by importing the python socket module and creating a UDP connection to the server.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">socket</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
   sock = <span style="color: #dc143c;">socket</span>.<span style="color: #dc143c;">socket</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">socket</span>.<span style="color: black;">AF_INET</span>, <span style="color: #dc143c;">socket</span>.<span style="color: black;">SOCK_DGRAM</span><span style="color: black;">&#41;</span>
&nbsp;
   <span style="color: #808080; font-style: italic;"># Connect to CoD4 server at 8.9.17.24:28960</span>
   <span style="color: #808080; font-style: italic;"># Will also work for most other games in a similar fasion</span>
   sock.<span style="color: black;">connect</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;8.9.17.24&quot;</span>, <span style="color: #ff4500;">28960</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p><span id="more-82"></span><br />
Now that we have established a connection with the game server, we may now start sending it rcon commands. Just remember that the protocol requires that you have a packet header of <code>0xFF0xFF0xFF0xFFrcon password</code> where the password is replaced with your rcon password. You can then follow the packet header by the command you wish to run on the server. In this example we are simply going to print the server status.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">	sock.<span style="color: black;">send</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FFrcon xxxxxxxxxx status&quot;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> sock.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">65565</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Which will display a result similar to this:</p>
<blockquote><p>����print<br />
map: mp_broadcast<br />
num score ping guid name lastmsg address qport rate<br />
&#8212; &#8212;&#8211; &#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8211; &#8212;&#8211;<br />
0 262 137 666a7a82ac0897a213a3a220a1f59893 [0.o]BlameTruth^7 50 80.73.221.70:-8128 31736 25000<br />
1 42 160 42e130756a877c36f71b4f25a96e07cd luluno^7 50 84.195.170.81:-2965 -30455 25000<br />
2 52 36 829a446fd0b0d79f52d8adab5bbbe343 Zack^7 50 173.24.37.249:28960 22992 25000<br />
3 642 31 d3aa0bf47f9c1734b2f7b21089ccafb9 Outlaw^7 0 76.228.193.186:28960 -11398 25000<br />
4 142 110 c53129735bd532ada06d00289e7d609b Hasenpflug^7 50 24.7.31.6:28960 -5755 25000<br />
5 392 96 f44087b315b41f77be8176664e4241f5 [KoS]Karma^7 50 76.14.127.157:28960 5397 25000<br />
6 40 52 4dc7f80bea865494032e4dd782adac8d I Sketchy I^7 0 173.30.206.39:28960 -393 25000<br />
7 0 152 f6aa1b9d5a9865b80e756f43674807e9 fRoz1n1^7 50 99.29.116.44:28960 -17501 25000<br />
8 180 256 79ebdaf076b3301a7c2b95e109ca87d0 REBORN YEH^7 0 58.170.56.2:28960 23402 25000</p></blockquote>
<p>Finally all you have to do is close the connection with sock.close() and the entirety of the code will look something like this:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">socket</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
	sock = <span style="color: #dc143c;">socket</span>.<span style="color: #dc143c;">socket</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">socket</span>.<span style="color: black;">AF_INET</span>, <span style="color: #dc143c;">socket</span>.<span style="color: black;">SOCK_DGRAM</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;"># Connect to CoD4 server at 8.9.17.24:28960</span>
	<span style="color: #808080; font-style: italic;"># Will also work for most other games in a similar fasion</span>
	sock.<span style="color: black;">connect</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;8.9.17.24&quot;</span>, <span style="color: #ff4500;">28960</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
	sock.<span style="color: black;">send</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FFrcon xxxxxxxxxx status&quot;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> sock.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">65565</span><span style="color: black;">&#41;</span>
	sock.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>As noted, the Rcon protocol is extremely simple and its up to you to think of how you can use Rcon bots to improve the quality and functionality of your game servers. Just remember that you do not have to sock.recv() data from the server every time to send data and remember that the server may send data in chunks in which case you may not receive everything you need in one transmission. But overall its as simple as shown in this tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2009/11/26/using-the-rcon-protocol-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring the PlayStation 3 Controller on Linux</title>
		<link>http://www.madsoft.org/2008/12/16/configuring-the-playstation-3-controller-on-linux/</link>
		<comments>http://www.madsoft.org/2008/12/16/configuring-the-playstation-3-controller-on-linux/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 03:24:24 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[configure]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[playstation]]></category>
		<category><![CDATA[ps3]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/?p=65</guid>
		<description><![CDATA[A couple of months ago I stumbled upon a slew of information related to using the PS3 controller as a joystick on Linux. I immediately took my PS3 controller and started experimenting with the documentation out there for doing this sort of thing. Unfortunately however, not everything mentioned in this documentation worked correctly. For instance, [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of months ago I stumbled upon a slew of information related to using the PS3 controller as a joystick on Linux. I immediately took my PS3 controller and started experimenting with the documentation out there for doing this sort of thing. Unfortunately however, not everything mentioned in this documentation worked correctly. For instance, I was not able to use a joystick on the controller to control the mouse without a separate piece of middleware. This was because the application I used (the only decent one I was able to find) to signal key presses for every button press on the controller, is unmaintained and had a blocker bug with mouse emulation.</p>
<p>You will need two components in order to make this work: the first being QJoyPad to bind controller buttons to keys, and JoyMouse to use one of the joysticks on the controller to control the mouse. Also remember that I am only using the USB cable to use the controller rather than using it via Bluetooth. I will post directions for using Bluetooth and the accelerometers in the controller at a later date, if I am able to get a hold of a Bluetooth adapter. Nevertheless, the tools are the same.</p>
<p><span id="more-65"></span>Because QJoyPad is currently unmaintained, and the packages available from their site are out of date; we will need to compile from source. The first thing we need to do is install dependencies:</p>
<blockquote>

<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: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libqt3-mt-dev libxtst-dev</pre></div></div>

</blockquote>
<p>Then download the tarball <a href="http://downloads.sourceforge.net/qjoypad/qjoypad-3.4.1.tgz" target="_blank">from here</a>, extract it, and compile as usual.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>qjoypad-3.4.1<span style="color: #000000; font-weight: bold;">/</span>src
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

</blockquote>
<p>Before we can get started with QJoyPad; we need to first plug in the controller and make sure that it&#8217;s being recognized by Linux. First make sure that your PlayStation 3 is completely turned off (via the switch in the back). Then plug the one end of the USB cable into the computer, but leave it unplugged from the controller. Hit the PS button to activate the controller and the red LED&#8217;s on the top will start to blink. Now plug the USB cable into the controller and verify that it has been recognized.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">maddog39<span style="color: #000000; font-weight: bold;">@</span>desktop:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> js
js0</pre></div></div>

</blockquote>
<p>Though take note to the device name of the controller (/dev/input/js0 in my case) as we will need to use this later. Now we can start to configure the buttons on the controller and assign them to keyboard keystrokes. When you launch QJoyPad (via the qjoypad command as no Applications menu item is provided), click on it&#8217;s tray icon and the button editor will appear.</p>
<p><a href="http://www.madsoft.org/wp-content/uploads/2008/12/qjoypad_main.png"><img class="alignnone size-medium wp-image-72" title="qjoypad_main" src="http://www.madsoft.org/wp-content/uploads/2008/12/qjoypad_main-127x300.png" alt="" width="127" height="300" /></a></p>
<p>The first thing you will want to do is create a new layout. Simply click Add at the top of the window and enter a label for your layout. You can see which controller buttons correspond to buttons in QJoyPad by pressing or holding the button you want to modify as it will appear highlighted in blue when its activated. To assign a keypress to any button or axis, click the button or axis you want to modify and a dialog will appear, then click [NO KEY] and hit the key you want to assign.</p>
<p>In order to be able to use either of the PS3 controller&#8217;s joysticks as mice, we need to install JoyMouse which can be downloaded <a href="http://sourceforge.net/project/showfiles.php?group_id=102618" target="_blank">here</a>. Its a really simple program and as far as I know it doesnt have any dependencies so you should be good with a standard build. Extract the tarball to your desktop and open a terminal in the JoyMouse directory.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>joymouse-<span style="color: #000000;">0.5</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

</blockquote>
<p>Once JoyMouse is installed, we need to modify our xorg.conf to add a new pointer device.</p>
<blockquote>

<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: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>X11<span style="color: #000000; font-weight: bold;">/</span>xorg.conf</pre></div></div>

</blockquote>
<p>Now go to the end of the file and you will want to insert the following lines.</p>
<blockquote>
<pre>Section "InputDevice"
        Identifier   "Joystick"
        Driver       "mouse"
        Option      "Protocol"     "ExplorerPS/2"
        Option      "Device"     "/dev/joymouse"
        Option      "SendCoreEvents"     "true"
        Option      "ZAxisMapping"    "4 5 6 7"
EndSection</pre>
</blockquote>
<p>Then go back up to the &#8220;ServerLayout&#8221; section of the file and in that section under your mouse input device, insert the following line.</p>
<blockquote>
<pre>InputDevice "Joystick"</pre>
</blockquote>
<p>When your finished, Ctrl+O, Enter, then Ctrl+X to save and exit. Now heres the thing; in order for this to work we need to create a pipe using the mkfifo command, but it needs to always be there for JoyMouse to work. The problem is that these pipes are not retained over reboots: meaning that you have to recreate them everytime you want to use JoyMouse. I have also read that if the pip does not exist, it may cause Xorg to fail to start. I have yet to find a good solution to this problem, but for now manual will have to do.</p>
<blockquote>

<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: #c20cb9; font-weight: bold;">mkfifo</span> <span style="color: #660033;">-m</span> 0777 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>joymouse</pre></div></div>

</blockquote>
<p>Running the JoyMouse program is fairly simple, just keep in mind that when you assign axes, they are always in order. So for example, if you wanted to use the right joystick as your mouse you would use the following.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">joymouse <span style="color: #660033;">-M</span> - <span style="color: #660033;">-M</span> - <span style="color: #660033;">-M</span> x <span style="color: #660033;">-M</span> y</pre></div></div>

</blockquote>
<p>We ignored (using a dash) the first two axes as those are left/right and up/down for the left joystick and assigned X and Y to the left/right and up/down on the right joystick respectively. However, if you wanted to use the left joystick as the mouse, the command would read like this.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">joymouse <span style="color: #660033;">-M</span> x <span style="color: #660033;">-M</span> y</pre></div></div>

</blockquote>
<p>If you would like, you could add this joymouse command to your GNOME (or whatever desktop environment you prefer) startup programs. In GNOME this would be: System &gt; Preferences &gt; Sessions &gt; Startup Programs. But as mentioned earlier, remember that you need the /dev/joymouse pipe to exist first. After that, your done. Test out the controller with several different games and or applications and tweak the settings to your liking.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/12/16/configuring-the-playstation-3-controller-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SETI@Home Optimizers on Linux</title>
		<link>http://www.madsoft.org/2008/09/28/setihome-optimizers-on-linux/</link>
		<comments>http://www.madsoft.org/2008/09/28/setihome-optimizers-on-linux/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 07:13:01 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[boinc]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[optimized]]></category>
		<category><![CDATA[seti]]></category>
		<category><![CDATA[setiathome]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/?p=45</guid>
		<description><![CDATA[As I am a big proponent of the SETI@Home project as well as a Linux user, discovering that optimized SETI applications existed and how to use them was important. It took quite some time to figure this all out by myself since there are hardly any (from what I could find) resources on SETI@Home optimized [...]]]></description>
			<content:encoded><![CDATA[<p>As I am a big proponent of the SETI@Home project as well as a Linux user, discovering that optimized SETI applications existed and how to use them was important. It took quite some time to figure this all out by myself since there are hardly any (from what I could find) resources on SETI@Home optimized clients on Linux. Eventually I ran into <a href="http://lunatics.kwsn.net/" target="_blank">this</a> site which offers SSE3 and SSSE3 optimized clients for Linux in addition to SSE, SSE2, and SSE3 clients for FreeBSD.</p>
<p>For those of you who don&#8217;t know what SETI@Home optimizers are, they are essentially specialized versions of the standard version of the SETI@Home client which take advantage of extended floating-point instruction sets available to certain x86 (Intel, AMD, or the like) processors. Using these instruction sets allows optimized clients to complete work many times faster than it could before with the standard client. For example, prior to using an SSSE3 optimized client on my Intel Core 2 Quad Q6600 my recent average credit (RAC) on SETI was in the 500 range including one other active machine and now my RAC has spiked over 2,500 not including the other active machine.</p>
<p><span id="more-45"></span>Before we get started, you should make sure that all other active work units you have running are completed before replacing the standard client with an optimized one. Then you may choose which optimize client you will run. Keep in mind that currently, only Intel Core 2 based CPUs and a single VIA CPU are capable of running SSSE3 instructions. For more details on this you should refer to the <a href="http://en.wikipedia.org/wiki/SSSE3" target="_blank">SSSE3 wikipedia page</a>. Otherwise, you will likely be able to run an SSE3 optimized client, unless your CPU is more than several years old, also <a href="http://en.wikipedia.org/wiki/SSE3" target="_blank">refer to wikipedia</a> for more information on this. If you&#8217;ve got an even older CPU, there are also clients for MMX, SSE, and SSE2.</p>
<p>Optionally you may check which instruction sets are supported by your CPU using the following command:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>maddog39<span style="color: #000000; font-weight: bold;">@</span>desktop ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>cpuinfo <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> flags <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span>
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm</pre></div></div>

</blockquote>
<p>First thing we want to do is download the client for your respective CPU and kernel version (most likely SSE3 or SSSE3 and kernel 2.6) from <a href="http://lunatics.kwsn.net/discussion-forum/linux-port-of-alex-kans-v8-0.msg8200.html;topicseen#msg8200" target="_blank">this</a> page and extract the tarball. If your using an older CPU requiring an older instruction set, see <a href="http://lunatics.kwsn.net/index.php?module=Downloads;catd=1" target="_blank">this</a> page instead.</p>
<p>Before we actually drop in the optimized client, its probably best to suspend the SETI@Home project in BOINC for safe measure.</p>
<p><a href="http://www.madsoft.org/wp-content/uploads/2008/09/boinc_seti_suspend.png"><img class="alignnone size-full wp-image-54" title="Suspend SETI@Home" src="http://www.madsoft.org/wp-content/uploads/2008/09/boinc_seti_suspend.png" alt="" width="500" height="193" /></a></p>
<p>Now we get to physically install our new SETI@Home optimizer. In the folder you extracted from the tarball, you should find a binary (executable) and an app_info.xml file, either in the folder&#8217;s top directory or in a subsequent sub-folder.</p>
<p><a href="http://www.madsoft.org/wp-content/uploads/2008/09/seti_optimizer_extracted.png"><img class="alignnone size-full wp-image-55" title="Extraced Optimizer Files" src="http://www.madsoft.org/wp-content/uploads/2008/09/seti_optimizer_extracted.png" alt="" width="500" height="342" /></a></p>
<p>You want to copy these files and launch nautilus (or your file manager of choice) as root and point it to the /var/lib/boinc folder. Hit Alt+F2 to bring up a run dialog and enter the command:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gksudo nautilus <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>boinc<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>setiathome.berkeley.edu</pre></div></div>

</blockquote>
<p><a href="http://www.madsoft.org/wp-content/uploads/2008/09/run_nautilus_root_boinc_fixed.png"><img class="alignnone size-full wp-image-60" title="Run Nautilus as Root" src="http://www.madsoft.org/wp-content/uploads/2008/09/run_nautilus_root_boinc_fixed.png" alt="" width="461" height="179" /></a></p>
<p>Paste the optimizer files into the directory and when comes up. Finally, you will need to restart the BOINC daemon. On my distribution, Arch Linux its:</p>
<blockquote>

<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: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>boinc restart</pre></div></div>

</blockquote>
<p>Although if you are using Ubuntu, Debian, or a derivative its:</p>
<blockquote>

<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: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>boinc restart</pre></div></div>

</blockquote>
<p>Then, to start using your new SETI optimized client, you simply launch BOINC manager and resume the SETI@Home project. It should start downloading new workunits immediatley and your in business. I hope you found this article useful and keep in mind that I tried to keep it as easy as possible for the newer Linux users out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/09/28/setihome-optimizers-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QOverclock 0.1</title>
		<link>http://www.madsoft.org/2008/08/13/qoverclock-01/</link>
		<comments>http://www.madsoft.org/2008/08/13/qoverclock-01/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 04:32:25 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Programs]]></category>
		<category><![CDATA[overclocking]]></category>
		<category><![CDATA[qoverclock]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/?p=35</guid>
		<description><![CDATA[I actually wrote this little application quite a few weeks ago, I was just contemplating whether it was worth posting or not. I had just finished building my new PC and was starting to do a lot of overclocking and tweaking. Frustrated by the fact that there weren&#8217;t any Linux or open source alternatives to [...]]]></description>
			<content:encoded><![CDATA[<p>I actually wrote this little application quite a few weeks ago, I was just contemplating whether it was worth posting or not. I had just finished building my new PC and was starting to do a lot of overclocking and tweaking. Frustrated by the fact that there weren&#8217;t any Linux or open source alternatives to overclocking calculators, I quickly wrote one up using Qt 4. It simply calculates the resulting clock speed of your CPU given the FSB and the multiplier. Who knows, maybe somebody will find it useful. I was thinking about adding some tray icon functionality to monitor system temps. as well. Although, I am going to sit on that idea for a little while.</p>
<p><a href="http://www.madsoft.org/wp-content/uploads/2008/08/qoverclock.png"><img class="size-full wp-image-36 alignnone" title="QOverclock 0.1" src="http://www.madsoft.org/wp-content/uploads/2008/08/qoverclock.png" alt="" width="163" height="56" /></a></p>
<p><span style="text-decoration: underline;"><a title="QOverclock 0.1" href="http://dl.madsoft.org/qoverclock-0.1.tar.gz" target="_blank">Download QOverclock 0.1</a></span></p>
<p><span style="text-decoration: underline;"><a title="QOverclock 0.1 (Win32 Binary)" href="http://dl.madsoft.org/qoverclock-0.1-win32.zip" target="_blank">Download QOverclock 0.1 (Win32 Binary)</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/08/13/qoverclock-01/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Small Banshee 1.0 Status Plugin for Pidgin</title>
		<link>http://www.madsoft.org/2008/06/23/small-bashee-10-status-plugin-for-pidgin/</link>
		<comments>http://www.madsoft.org/2008/06/23/small-bashee-10-status-plugin-for-pidgin/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 00:27:48 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[banshee]]></category>
		<category><![CDATA[pidgin]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[status]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/?p=31</guid>
		<description><![CDATA[This took a bit longer to get out than I had originally expected but here it is. As a precursor to my previous post, I wanted to make a new &#8220;plugin&#8221; for pidgin that would update my music status from Banshee because as of the development versions of 1.0, they had an entirely new API [...]]]></description>
			<content:encoded><![CDATA[<p>This took a bit longer to get out than I had originally expected but here it is. As a precursor to my previous post, I wanted to make a new &#8220;plugin&#8221; for pidgin that would update my music status from Banshee because as of the development versions of 1.0, they had an entirely new API in place and other similar plugins hadn&#8217;t (and still aren&#8217;t as far as I know) been updated to work with the new API. So that&#8217;s exactly what I did and its a very simple ~30 line python script that I am putting out to the world in case anyone else wants similar functionality.</p>
<p>Basically you just stick the file in your home directory (or at your option in /usr/bin or /usr/local/bin) and add it to your auto-started applications in GNOME or KDE or put it in your xinitrc or whatever you want. For GNOME users I happen to know that you can do this from System &gt; Preferences &gt; Sessions &gt; Startup Programs &gt; Add. For windows users this script will never run because Banshee is *nix only as well as DBus (as far as I know). Enjoy!</p>
<p><a href="http://www.madsoft.org/wp-content/uploads/2008/06/pidgin_banshee_status.py">Download pidgin_banshee_status.py</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/06/23/small-bashee-10-status-plugin-for-pidgin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interfacing Banshee 1.0 with DBus and Python</title>
		<link>http://www.madsoft.org/2008/06/10/interfacing-banshee-10-with-dbus-and-python/</link>
		<comments>http://www.madsoft.org/2008/06/10/interfacing-banshee-10-with-dbus-and-python/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 03:35:28 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[banshee]]></category>
		<category><![CDATA[dbus]]></category>
		<category><![CDATA[interface]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/?p=30</guid>
		<description><![CDATA[Ever since the DBUS API change (more like overhaul) during the development of Banshee 1.0 and developers haven&#8217;t yet started supporting it in their plugins so I decided that I would play around with it. From what I have seen, it seems that the perception is that DBus is hard and complicated but its actually [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since the DBUS API change (more like overhaul) during the development of Banshee 1.0 and developers haven&#8217;t yet started supporting it in their plugins so I decided that I would play around with it. From what I have seen, it seems that the perception is that DBus is hard and complicated but its actually really easy and makes things very simple. Essentially you use a DBus debugger (because in most cases, documentation for an applications&#8217; DBus API is not available) like D-Feet to look up which interfaces, methods, properties, and signals are available to you. Then use them to do what you want.</p>
<p><span id="more-30"></span></p>
<p><a href="http://www.madsoft.org/wp-content/uploads/2008/06/dfeet_dbus_debugger.png"><img class="alignnone size-medium wp-image-32" title="dfeet_dbus_debugger" src="http://www.madsoft.org/wp-content/uploads/2008/06/dfeet_dbus_debugger-300x180.png" alt="Bansshe DBus API in D-Feet" width="300" height="180" /></a></p>
<p>Now all we have to do is make a connection to Banshee via DBus and start calling methods. For this we will just use an interactive python interpreter which can be accessed by simply typing &#8220;python&#8221; at any command line prompt. Firstly, we will import the DBuslibrary.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> dbus</pre></div></div>

</blockquote>
<p>Next, we will make a connection to the session bus.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">bus = dbus.<span style="color: black;">SessionBus</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Then we will get Banshee&#8217;s PlayerEngine object which will let us control the player itself (Play, Pause, Next, Previous, Current Track, etc).</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">banshee = bus.<span style="color: black;">get_object</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;org.bansheeproject.Banshee&quot;</span>, <span style="color: #483d8b;">&quot;/org/bansheeproject/Banshee/PlayerEngine&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>The first argument we pass, &#8220;org.bansheeproject.Banshee&#8221;, is the interface we want to connect to and &#8220;/org/bansheeproject/Banshee/PlayerEngine&#8221; is the path to the object that we want to use. Now we can start doing stuff with Banshee. You can pretty much take any of the methods listed in D-Feet and run them. For example:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">banshee.<span style="color: black;">Open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;file:///home/maddog39/Music/Eisbrecher - Antikörper.mp3&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>And to play the song&#8230;</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">banshee.<span style="color: black;">Play</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Once you have had enough&#8230;.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">banshee.<span style="color: black;">Pause</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Although note that you dont have to using the Open() method to use the Play() and Pause() methods, but Open() lets you open an arbitrary media file otherwise those other methods use the currently playing track. Now, to access properties you generally just take the name of the property and prepend &#8216;Get&#8217; to it and make it a method. So for example:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">banshee.<span style="color: black;">GetCanPause</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Returns:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">dbus.Boolean(False)</pre></div></div>

</blockquote>
<p>Or if we wanted to display all the information about the currently playing track we might do&#8230;</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">for</span> key <span style="color: #ff7700;font-weight:bold;">in</span> currentTrack.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> key + <span style="color: #483d8b;">&quot;: &quot;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>currentTrack<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Which gives us:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">album: Issues
rating: 0
name: Falling Away From Me
artist: Korn
URI: file:///home/maddog39/Music/Korn%20-%20Beating%20Me%20Down.mp3
length: 271.211
disc: 0
track-count: 16
year: 1999
track-number: 2</pre></div></div>

</blockquote>
<p>Another cool thing you can do with DBus is receive signals. What this allows us to do is run code when a given signal is triggered or received. We do this by connecting a python method with a signal on our bus. So if we wanted to do something every time Banshee changes its state (playing, paused, loading, loaded, etc) this is what would happen. We would first have to setup a main loop as it is required for a signals to function.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> gobject
<span style="color: #ff7700;font-weight:bold;">from</span> dbus.<span style="color: black;">mainloop</span>.<span style="color: black;">glib</span> <span style="color: #ff7700;font-weight:bold;">import</span> DBusGMainLoop
dbus.<span style="color: black;">mainloop</span>.<span style="color: black;">glib</span>.<span style="color: black;">DBusGMainLoop</span><span style="color: black;">&#40;</span>set_as_default=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Then we would create a callback method which would be run every time the signal is triggered.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> stateChanged<span style="color: black;">&#40;</span>state<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;State Changed: %s&quot;</span> <span style="color: #66cc66;">%</span> state</pre></div></div>

</blockquote>
<p>Now we can add our signal receiver to our method.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">bus.<span style="color: black;">add_signal_receiver</span><span style="color: black;">&#40;</span>stateChanged,
dbus_interface=<span style="color: #483d8b;">&quot;org.bansheeproject.Banshee.PlayerEngine&quot;</span>,
                        signal_name=<span style="color: #483d8b;">&quot;StateChanged&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Finally, at the end of a script that uses signals we would want to run our main loop.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">gobject.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Well thats pretty much it! Just keep in mind that this was not intended to be a tutorial but merely a guideline on how to do interact and do things with Banshee over DBus. So feel free to sit down and write some of your own scripts based on what you have learned here and I hope this helps. I have already written my own program to integrate Banshee into another application which I will talk about in another article. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/06/10/interfacing-banshee-10-with-dbus-and-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily create IRC bots in Python with PyBotlib</title>
		<link>http://www.madsoft.org/2008/05/09/easily-create-irc-bots-in-python-with-pybotlib/</link>
		<comments>http://www.madsoft.org/2008/05/09/easily-create-irc-bots-in-python-with-pybotlib/#comments</comments>
		<pubDate>Fri, 09 May 2008 19:19:02 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[botlib]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[irc]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/2008/05/09/easily-create-irc-bots-in-python-with-pybotlib/</guid>
		<description><![CDATA[Back when I wrote ProxyBot, I was frustrated by the fact that there was a lack of maintained and documented third party libraries for the IRC client protocol. So I essentially wrote my own implementation of the IRC client protocol for use with the bots that I write. Well I wrote the library to take [...]]]></description>
			<content:encoded><![CDATA[<p>Back when I wrote ProxyBot, I was frustrated by the fact that there was a lack of maintained and documented third party libraries for the IRC client protocol. So I essentially wrote my own implementation of the IRC client protocol for use with the bots that I write. Well I wrote the library to take advantage of OOP (Object Oriented Programming for those who don&#8217;t know) which in turn made it really quick and easy for me to throw together a bot.</p>
<p>So this is a simple little tutorial on how to write a basic &#8220;Hello World&#8221; bot using PyBotlib. The library itself is only a single file so I have not bothered to repackage it or write setup scripts as you will only need import that single file within your application. You may get the latest source code for the library at any time <a title="botlib.py" href="http://ircproxybot.googlecode.com/svn/trunk/botlib.py" target="_blank">here</a> (google code/SVN) or <a title="PyBotlib 1.0" href="http://www.madsoft.org/wp-content/uploads/2008/05/botlib.py" target="_blank">here</a> (blog). So here we go&#8230;</p>
<p><span id="more-28"></span><br />
Lets start by defining our bot class and its constructor.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> botlib
&nbsp;
<span style="color: #808080; font-style: italic;"># Create a new class for our bot, extending the Bot class from botlib</span>
<span style="color: #ff7700;font-weight:bold;">class</span> HelloWorldBot<span style="color: black;">&#40;</span>botlib.<span style="color: black;">Bot</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, server, channel, nick, password=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
        botlib.<span style="color: black;">Bot</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, server, <span style="color: #ff4500;">6667</span>, channel, nick<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Send nickserv password if available</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> password <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span>:
            <span style="color: #008000;">self</span>.<span style="color: black;">protocol</span>.<span style="color: black;">privmsg</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nickserv&quot;</span>, <span style="color: #483d8b;">&quot;identify&quot;</span> <span style="color: #66cc66;">%</span> password<span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Next we are going to want to override the __actions__ function of the Bot class which will handle all of our bots actions. This acts as essentially a main loop and is called infinitely until the bot is shutdown. In here we put code for our commands, responders, whatever other interaction with the IRC channel that we need.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #ff7700;font-weight:bold;">def</span> __actions__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        botlib.<span style="color: black;">Bot</span>.__actions__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Create a Hello World responder/command</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> botlib.<span style="color: black;">check_found</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">data</span>, <span style="color: #483d8b;">&quot;!hello&quot;</span><span style="color: black;">&#41;</span>:
            <span style="color: #808080; font-style: italic;"># Get the senders username</span>
            username = <span style="color: #008000;">self</span>.<span style="color: black;">get_username</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># Send user a message in response</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">protocol</span>.<span style="color: black;">privmsg</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">channel</span>, <span style="color: #483d8b;">&quot;Hello %s!&quot;</span> <span style="color: #66cc66;">%</span> username<span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>So here, we have created a simple command called !hello which runs the code underneath its if statement when an instance of that command is found in the chat. Then we call the get_username() function of the Bot class (remember that we inherited from the Bot class) to get the user name of the person who initiated the command. After that, we simply send a message back to the channel using the equivalent function for IRC&#8217;s PRIVMSG command. Now all we to do is instantiate and run our new bot.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"> <span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    <span style="color: #808080; font-style: italic;"># Create new instance of our bot and run it</span>
    HelloWorldBot<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;irc.wyldryde.org&quot;</span>, <span style="color: #483d8b;">&quot;#maddog39&quot;</span>, <span style="color: #483d8b;">&quot;HelloWorldBot&quot;</span><span style="color: black;">&#41;</span>.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Keep in mind that when you are instantiating Bot object, that because PyBotlib is entirely threaded, you can make as many instances of your bot as you would like. I do have a BotManager class in PyBotlib intended for managing sets of multiple bots on the same process however I have never actually tested it so your results may vary. Here is the script in its entirety.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> botlib
&nbsp;
<span style="color: #808080; font-style: italic;"># Create a new class for our bot, extending the Bot class from botlib</span>
<span style="color: #ff7700;font-weight:bold;">class</span> HelloWorldBot<span style="color: black;">&#40;</span>botlib.<span style="color: black;">Bot</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, server, channel, nick, password=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
        botlib.<span style="color: black;">Bot</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, server, <span style="color: #ff4500;">6667</span>, channel, nick<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Send nickserv password if availible</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> password <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span>:
            <span style="color: #008000;">self</span>.<span style="color: black;">protocol</span>.<span style="color: black;">privmsg</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nickserv&quot;</span>, <span style="color: #483d8b;">&quot;identify&quot;</span> <span style="color: #66cc66;">%</span> password<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> __actions__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        botlib.<span style="color: black;">Bot</span>.__actions__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Create a Hello World responder/command</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> botlib.<span style="color: black;">check_found</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">data</span>, <span style="color: #483d8b;">&quot;!hello&quot;</span><span style="color: black;">&#41;</span>:
            <span style="color: #808080; font-style: italic;"># Get the senders username</span>
            username = <span style="color: #008000;">self</span>.<span style="color: black;">get_username</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># Send user a message in response</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">protocol</span>.<span style="color: black;">privmsg</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">channel</span>, <span style="color: #483d8b;">&quot;Hello %s!&quot;</span> <span style="color: #66cc66;">%</span> username<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    <span style="color: #808080; font-style: italic;"># Create new instance of our bot and run it</span>
    HelloWorldBot<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;irc.wyldryde.org&quot;</span>, <span style="color: #483d8b;">&quot;#maddog39&quot;</span>, <span style="color: #483d8b;">&quot;HelloWorldBot&quot;</span><span style="color: black;">&#41;</span>.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p>Finally, to run your new bot, simply issue the command:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python helloworldbot.py</pre></div></div>

</blockquote>
<p>At the terminal prompt or command prompt (windows). Also note that you must make sure that your botlib.py file is in the same directory as your bot. Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/05/09/easily-create-irc-bots-in-python-with-pybotlib/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reusing 3rd Party Libraries in Web Development</title>
		<link>http://www.madsoft.org/2008/04/14/reusing-3rd-pary-libraries-in-web-development/</link>
		<comments>http://www.madsoft.org/2008/04/14/reusing-3rd-pary-libraries-in-web-development/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 23:24:13 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/2008/04/14/reusing-3rd-pary-libraries-in-web-development/</guid>
		<description><![CDATA[Ever since I have been getting back into the swing of Web Development, working on one of my projects, I really took notice to something. Whenever you see a PHP application out there that is free to download and you start looking through how they did things. You start to see that generally many web [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since I have been getting back into the swing of Web Development, working on one of my projects, I really took notice to something. Whenever you see a PHP application out there that is free to download and you start looking through how they did things. You start to see that generally many web application developers (particularly PHP developers) will tend to rewrite many back end libraries for things such as the templating engine or database abstraction layer (DBAL) when there are so many libraries which do exactly the same thing and in many cases, much more. So my question is, why are we as developers wasting so much of our time rewriting things which are already there for us instead of using them to reach our intended goal? I recently asked myself this question while working on one of my projects.</p>
<p>I realized that I had wasted several months of my time developing what I called a &#8220;framework&#8221; for PHP when it was really not very full featured and actually made things extremely hard for myself in the large scheme of things. After doing some homework, I had found really rich libraries that allowed me to do things beyond my wildest dreams before. Projects such as <a href="http://www.smarty.net/" target="_blank">Smarty</a>, <a href="http://www.jquery.com/" target="_blank">jQuery</a>, and <a href="http://tinymce.moxiecode.com/" target="_blank">TinyMCE</a> just to name a few. What really gets me though is that many free (as in beer or potentially as in free speech) projects constantly fall behind because they take  forever to their own things such as rich text editors and ajax frameworks while their users are wondering why they don&#8217;t have the features they are looking for.</p>
<p>So  this is a call to all web developers out there. You really need to start reassessing  the libraries you write and think of how you could possibly use others&#8217; great Open Source projects to assist you in the development of your application. Stop reinventing the wheel and start innovating, that&#8217;s what we are all about, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/04/14/reusing-3rd-pary-libraries-in-web-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ProxyBot 0.7 Stable Released</title>
		<link>http://www.madsoft.org/2008/03/12/proxybot-07-stable-released/</link>
		<comments>http://www.madsoft.org/2008/03/12/proxybot-07-stable-released/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 21:31:27 +0000</pubDate>
		<dc:creator>Alec Hussey</dc:creator>
				<category><![CDATA[Programs]]></category>
		<category><![CDATA[proxybot]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[stable]]></category>

		<guid isPermaLink="false">http://www.madsoft.org/2008/03/12/proxybot-07-stable-released/</guid>
		<description><![CDATA[So there were some things that were in need of tweaking in the last version, so I have now released version 0.7. Due to popular demand I have implemented support for MySQL in addition to Postgres. I tried getting SQLite to work but it isn&#8217;t thread safe and would require a new instance in every [...]]]></description>
			<content:encoded><![CDATA[<p>So there were some things that were in need of tweaking in the last version, so I have now released version 0.7. Due to popular demand I have implemented support for MySQL in addition to Postgres. I tried getting SQLite to work but it isn&#8217;t thread safe and would require a new instance in every thread which makes things messy and does not work with the current database abstraction layer. So until I can pass SQLite instances across threads, that feature will not work. I put some more details in the readme which is included with the source distribution. I am always open to feedback so feel free.</p>
<p><a href="http://code.google.com/p/ircproxybot/downloads/list" target="_blank">Download ProxyBot</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.madsoft.org/2008/03/12/proxybot-07-stable-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
