<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" version="2.0">

<channel>
	<title>Lior Gradstein's Blog</title>
	
	<link>http://www.gradstein.info</link>
	<description />
	<lastBuildDate>Thu, 26 Mar 2009 11:30:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/LiorGradsteinsBlog" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Asterisk: DADHI module not working when using Xen</title>
		<link>http://www.gradstein.info/software/asterisk/asterisk-dadhi-module-not-working-when-using-xen/</link>
		<comments>http://www.gradstein.info/software/asterisk/asterisk-dadhi-module-not-working-when-using-xen/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 11:30:54 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[asterisk]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[voip]]></category>
		<category><![CDATA[digium]]></category>
		<category><![CDATA[hardware card]]></category>
		<category><![CDATA[rtc]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=224</guid>
		<description><![CDATA[If you want to use any Asterisk module that needs a timer, like MeetMe, you have to use a module named dahdi (previously named zaptel). DAHDI has one module for each Digium supported card (B410P), and a dummy module (named dahdi_dummy) if you don&#8217;t have a hardware card, like me.
The problem appears when you have [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to use any <a href="http://www.asterisk.org/" class="liexternal">Asterisk</a> module that needs a <a href="http://www.gradstein.info/tag/timer/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with timer">timer</a>, like MeetMe, you have to use a module named dahdi (previously named zaptel). DAHDI has one module for each <a href="http://www.gradstein.info/tag/digium/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with digium">Digium</a> supported card (B410P), and a dummy module (named dahdi_dummy) if you don&#8217;t have a hardware card, like me.</p>
<p>The problem appears when you have your Asterisk in a Xen environment. Xen does not allow the use of the <a href="http://www.gradstein.info/tag/rtc/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with rtc">RTC</a>, so when using Dahdi/meetme, you get the following in you logs:</p>
<blockquote><p>res_timing_dahdi.c: Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection.</p></blockquote>
<p>So get the sources, and let&#8217;s patch it!</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">svn co &nbsp;http://svn.<span style="color: black;"><a href="http://www.gradstein.info/tag/digium/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with digium">digium</a></span>.<span style="color: black;">com</span>/svn/dahdi/linux-complete/trunk DAHDI</div>
<p>In dahdi_dummy.c, you&#8217;ll have to comment the two defines USE_RTC, as in a Xen, you can&#8217;t use it:</p>
<p><source lang="diff"><br />
# diff -u dahdi_dummy.c.ori dahdi_dummy.c<br />
&#8212; dahdi_dummy.c.ori	2009-03-23 09:50:36.000000000 +0000<br />
+++ dahdi_dummy.c	2009-03-23 08:55:38.000000000 +0000<br />
@@ -59,11 +59,11 @@<br />
 #if defined(CONFIG_HIGH_RES_TIMERS) &#038;&#038; LINUX_VERSION_CODE >= VERSION_CODE(2,6,22)<br />
 #define USE_HIGHRESTIMER<br />
 #else<br />
-#define USE_RTC<br />
+//#define USE_RTC<br />
 #endif<br />
 #else<br />
 #if 0<br />
-#define USE_RTC<br />
+//#define USE_RTC<br />
 #endif<br />
 #endif<br />
 #endif<br />
</source></p>
<p>Then compile the module, as usual, with :</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">/etc/init.<span style="color: black;">d</span>/dahdi stop<br />
make all<br />
make install<br />
make config</div>
<p>Verify that your module has been correctly installed:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">ls -<span style="color: #dc143c;">al</span> ./<span style="color: #ff4500;">2.6</span><span style="color: #ff4500;">.24</span><span style="color: #ff4500;">-19</span>-xen/dahdi/dahdi_dummy.<span style="color: black;">ko</span></div>
<p>Comment out all the defined modules in the /etc/dahdi/modules file.</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">/etc/init.<span style="color: black;">d</span>/dahdi start<br />
<span style="color: #808080; font-style: italic;">#&amp;gt; dmesg</span><br />
<span style="color: #ff4500;">1007539.576458</span><span style="color: black;">&#93;</span> dahdi: Telephony Interface Registered on major <span style="color: #ff4500;">196</span><br />
<span style="color: black;">&#91;</span><span style="color: #ff4500;">1007539.576468</span><span style="color: black;">&#93;</span> dahdi: Version: SVN-trunk-r6201M<br />
<span style="color: black;">&#91;</span><span style="color: #ff4500;">1007540.642839</span><span style="color: black;">&#93;</span> dahdi: Registered tone zone <span style="color: #ff4500;">2</span> <span style="color: black;">&#40;</span><a href="http://www.gradstein.info/tag/france/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with france">France</a><span style="color: black;">&#41;</span></div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/python/how-to-dial-a-number-using-asterisk-and-python/" title="How to dial a number using Asterisk and Python (December 17, 2008)">How to dial a number using Asterisk and Python</a> (0)</li>
	<li><a href="http://www.gradstein.info/software/asterisk/asterisk-cirpack-problem-with-free-and-freephonienet/" title="Asterisk cirpack problem with Free and freephonie.net (February 12, 2009)">Asterisk cirpack problem with Free and freephonie.net</a> (0)</li>
</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?a=RtalISg0ycw:lmM-60vFTvQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?a=RtalISg0ycw:lmM-60vFTvQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?i=RtalISg0ycw:lmM-60vFTvQ:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/RtalISg0ycw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/software/asterisk/asterisk-dadhi-module-not-working-when-using-xen/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Django: How to find the url/path you’re into, in a template loaded by a generic view</title>
		<link>http://www.gradstein.info/python/django-how-to-find-the-urlpath-youre-into-in-a-template-loaded-by-a-generic-view/</link>
		<comments>http://www.gradstein.info/python/django-how-to-find-the-urlpath-youre-into-in-a-template-loaded-by-a-generic-view/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 22:11:39 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=197</guid>
		<description><![CDATA[In a Django project, I have a template that is used by two urls, which is quite common (generic views, using &#8216;create_object&#8217; and &#8216;update_object&#8217;). The problem is that I had to add a supplementary menu just when the template is loaded from the &#8216;update&#8217; generic view, and not from the &#8216;create&#8217; generic view.
Making the difference [...]]]></description>
			<content:encoded><![CDATA[<p>In a Django project, I have a template that is used by two urls, which is quite common (generic views, using &#8216;create_object&#8217; and &#8216;update_object&#8217;). The problem is that I had to add a supplementary menu just when the template is loaded from the &#8216;update&#8217; generic view, and not from the &#8216;create&#8217; generic view.</p>
<p>Making the difference between the two urls calls at the template level is a problem because it&#8217;s managed by generic views, so the same template is used.</p>
<p>Anyways, there are several possibilities:</p>
<p>In urls.py, use the <a href="http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-create-update-create-object" class="liexternal">&#8216;template_name&#8217; variable</a>, where you can speficy a specific template for this <a href="http://www.gradstein.info/tag/url/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with url">url</a>(). That is instead of using the default &lt;model&gt;_form.html.<br />
What I don&#8217;t like in this situation, is that I will have two nearly similar templates, just for an added menu. Not cool. Another problem is that I use <a href="http://code.djangoproject.com/wiki/GenerateGenericURLs" class="liexternal">a loop to create all my urls</a>. So if I add a special template, I&#8217;ll add it to <strong>ALL my models</strong> :-(.</p>
<p>Another solution, is to find a way to use a variable in the template that would be different wether the template has been loaded by update_object or create_object.</p>
<p>In our urlpatterns in urls.py, we can use the &#8216;<strong>extra_context</strong>&#8216; variable (takes a <a href="http://docs.djangoproject.com/en/dev/ref/generic-views/?from=olddocs#django-views-generic-create-update-create-object" class="liexternal">dictionnary as parameter</a>). It is correctly managed, even when using generic views. So, you&#8217;ll have :</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><a href="http://www.gradstein.info/tag/url/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with url">url</a><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&#8216;foo/ajouter/$&#8217;</span>, <span style="color: #483d8b;">&#8216;django.views.generic.create_update.create_object&#8217;</span>, &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span>form_class=modelForm,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; extra_context=<span style="color: black;">&#123;</span><span style="color: #483d8b;">&#8216;usage&#8217;</span>:<span style="color: #483d8b;">&#8216;create&#8217;</span><span style="color: black;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name=<span style="color: #483d8b;">&#8216;foo_create&#8217;</span>,<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></p>
<p><a href="http://www.gradstein.info/tag/url/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with url">url</a><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&#8216;foo/%s/(?P&lt;object_id&gt;<span style="color: #000099; font-weight: bold;">\d</span>+)/modifier/$&#8217;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&#8216;django.views.generic.create_update.update_object&#8217;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span>form_class=modelForm,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; extra_context=<span style="color: black;">&#123;</span><span style="color: #483d8b;">&#8216;usage&#8217;</span>:<span style="color: #483d8b;">&#8216;modify&#8217;</span><span style="color: black;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name=<span style="color: #483d8b;">&#8216;foo_update&#8217;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div>
<p>We can also use, in urls.py, the <a href="http://docs.djangoproject.com/en/dev/ref/generic-views/?from=olddocs#django-views-generic-create-update-create-object" class="liexternal">&#8216;context_processors&#8217; variable</a>. For more information about the context processors, have <a href="http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/" class="liexternal">a look at this tutorial</a>. The goal is to add &#8216;django.core.context_processors.request&#8217;, like this:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">core</span>.<span style="color: black;">context_processors</span> <span style="color: #ff7700;font-weight:bold;">import</span> request</div>
<p>and in the <a href="http://www.gradstein.info/tag/url/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with url">url</a>(), add context_processors:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><a href="http://www.gradstein.info/tag/url/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with url">url</a><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&#8216;foo/ajouter/$&#8217;</span>, <span style="color: #483d8b;">&#8216;django.views.generic.create_update.create_object&#8217;</span>, &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span>form_class=modelForm,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context_processors=<span style="color: black;">&#91;</span>request,<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name=<span style="color: #483d8b;">&#8216;foo_create&#8217;</span>,<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div>
<p>The last possiblity is a more global solution. It&#8217;s like the context_processors usage above, but added into every templates automatically.<br />
To do this, you&#8217;ll have to edit the list of Template Processors in your settings.py file. That list is run each time a template is loaded, and allows one to add any variable to the template automatically. By default (on Django 1.0.x) this list is commented out, so it has by <a href="http://docs.djangoproject.com/en/dev/ref/settings/#setting-TEMPLATE_CONTEXT_PROCESSORS" class="liexternal">default the list</a>:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;django.core.context_processors.auth&quot;</span>,<br />
<span style="color: #483d8b;">&quot;django.core.context_processors.debug&quot;</span>,<br />
<span style="color: #483d8b;">&quot;django.core.context_processors.i18n&quot;</span>,<br />
<span style="color: #483d8b;">&quot;django.core.context_processors.media&quot;</span><span style="color: black;">&#41;</span></div>
<p>You&#8217;ll have to uncomment it, and add &#8216;django.core.context_processors.request&#8217;. By doing this, you get the variable &#8216;request.path&#8217; available in your template.</p>
<p>Finally, you&#8217;ll be able to test your variable with {% ifequal %} and display your conditional elements.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li>No related posts.</li>
	</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?a=AQmI1uwmT1o:34sMJybBgrE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?a=AQmI1uwmT1o:34sMJybBgrE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?i=AQmI1uwmT1o:34sMJybBgrE:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/AQmI1uwmT1o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/django-how-to-find-the-urlpath-youre-into-in-a-template-loaded-by-a-generic-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>calcubetimer moved to Google Code</title>
		<link>http://www.gradstein.info/rubik/calcubetimer-moved-to-google-code/</link>
		<comments>http://www.gradstein.info/rubik/calcubetimer-moved-to-google-code/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 16:51:08 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[rubik]]></category>
		<category><![CDATA[cube]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=190</guid>
		<description><![CDATA[Calcubetimer&#8217;s website doesn&#8217;t seem to work anymore :-( Fortunately, gnehzr has moved the code to Google Code.

	Related posts
	
	No related posts.
	

]]></description>
			<content:encoded><![CDATA[<p><a href="http://gnehzr.net/cct/" class="liexternal">Calcubetimer&#8217;s website</a> doesn&#8217;t seem to work anymore :-( Fortunately, gnehzr has moved the code to <a href="http://code.google.com/p/calcubetimer/" class="liexternal">Google Code</a>.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li>No related posts.</li>
	</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?a=azM3382nPQM:JRxjmZRPP78:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?a=azM3382nPQM:JRxjmZRPP78:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/LiorGradsteinsBlog?i=azM3382nPQM:JRxjmZRPP78:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/azM3382nPQM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/rubik/calcubetimer-moved-to-google-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Asterisk cirpack problem with Free and freephonie.net</title>
		<link>http://www.gradstein.info/software/asterisk/asterisk-cirpack-problem-with-free-and-freephonienet/</link>
		<comments>http://www.gradstein.info/software/asterisk/asterisk-cirpack-problem-with-free-and-freephonienet/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 09:34:51 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[asterisk]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[voip]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[cirpack]]></category>
		<category><![CDATA[correction]]></category>
		<category><![CDATA[france]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[free isp provider]]></category>
		<category><![CDATA[freephonie.net]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[provider]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=179</guid>
		<description><![CDATA[If you configured your Asterisk/FreeSWITCH server to talk to your freephonie.net (french Free ISP provider), you&#8217;ll see in the logs the following warning message:
&#91;Feb 12 09:29:06&#93; WARNING&#91;9228&#93;: chan_sip.c:6624 determine_firstline_parts: Bad request protocol Packet
This is not really a problem, but an annoyance, as it fills up your logs. This is a known problem for more than [...]]]></description>
			<content:encoded><![CDATA[<p>If you configured your Asterisk/FreeSWITCH server to talk to your <a href="http://www.gradstein.info/tag/freephonienet/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with freephonie.net">freephonie.net</a> (french <a href="http://www.gradstein.info/tag/free/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with free">Free</a> ISP provider), you&#8217;ll see in the logs the following warning message:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: black;">&#91;</span>Feb <span style="color: #ff4500;">12</span> <span style="color: #ff4500;">09</span>:<span style="color: #ff4500;">29</span>:<span style="color: #ff4500;">06</span><span style="color: black;">&#93;</span> WARNING<span style="color: black;">&#91;</span><span style="color: #ff4500;">9228</span><span style="color: black;">&#93;</span>: chan_sip.<span style="color: black;">c</span>:<span style="color: #ff4500;">6624</span> determine_firstline_parts: Bad request protocol Packet</div>
<p>This is not really a problem, but an annoyance, as it fills up your logs. This is a <a href="http://bugs.digium.com/view.php?id=7261&#038;nbn=6" class="liexternal">known problem</a> for more than years, but has never been corrected (neither by Asterisk nor by <a href="http://www.gradstein.info/tag/cirpack/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with cirpack">Cirpack</a> devs). The usual correction was to add the following line to your startup scripts (/etc/rc.local on Debian for example):</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><a href="http://www.gradstein.info/tag/iptables/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with iptables">iptables</a> -A INPUT -p udp -m udp &#8211;dport <span style="color: #ff4500;">5060</span> -m <span style="color: #dc143c;">string</span> &#8211;<span style="color: #dc143c;">string</span> <span style="color: #483d8b;">&quot;<a href="http://www.gradstein.info/tag/cirpack/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with cirpack">Cirpack</a> KeepAlive Packet&quot;</span> -j DROP</div>
<p>But the syntax has changed in <a href="http://www.gradstein.info/tag/iptables/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with iptables">iptables</a>, and you&#8217;ll get the error:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><a href="http://www.gradstein.info/tag/iptables/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with iptables">iptables</a> v1<span style="color: #ff4500;">.3</span><span style="color: #ff4500;">.6</span>: STRING match: You must specify `&#8211;algo<span style="color: #483d8b;">&#8216;</span></div>
<p>so, just add one of the 2 available algorithms (bm and kmp):</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><a href="http://www.gradstein.info/tag/iptables/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with iptables">iptables</a> -A INPUT -p udp -m udp &#8211;dport <span style="color: #ff4500;">5060</span> -m <span style="color: #dc143c;">string</span> &#8211;<span style="color: #dc143c;">string</span> <span style="color: #483d8b;">&quot;<a href="http://www.gradstein.info/tag/cirpack/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with cirpack">Cirpack</a> KeepAlive Packet&quot;</span> &#8211;algo bm -j DROP</div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/python/how-to-dial-a-number-using-asterisk-and-python/" title="How to dial a number using Asterisk and Python (December 17, 2008)">How to dial a number using Asterisk and Python</a> (0)</li>
	<li><a href="http://www.gradstein.info/software/asterisk/asterisk-dadhi-module-not-working-when-using-xen/" title="Asterisk: DADHI module not working when using Xen (March 26, 2009)">Asterisk: DADHI module not working when using Xen</a> (5)</li>
</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=OAp2q9WX"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=QuwmG6zn"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?i=QuwmG6zn" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/j2iF2iz33-Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/software/asterisk/asterisk-cirpack-problem-with-free-and-freephonienet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy chess games for kids (mate in one)</title>
		<link>http://www.gradstein.info/kid/easy-chess-games-for-kids-mate-in-one/</link>
		<comments>http://www.gradstein.info/kid/easy-chess-games-for-kids-mate-in-one/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 00:45:12 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[chess]]></category>
		<category><![CDATA[kid]]></category>
		<category><![CDATA[child]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[diagrams]]></category>
		<category><![CDATA[generate]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[kids]]></category>
		<category><![CDATA[mate]]></category>
		<category><![CDATA[mate in one]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pgn]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=151</guid>
		<description><![CDATA[In my journey to teach chess to Ido, an easy (I thought) job was to generate diagrams where he has to find mate in a fixed number of turns. Starting with mate in one.
It appeared that making diagrams is an easy task, as there are many programs (Linux and Windows) that permit this.
On Linux, the [...]]]></description>
			<content:encoded><![CDATA[<p>In my journey to teach chess to Ido, an easy (I thought) job was to generate <a href="http://www.gradstein.info/tag/diagrams/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with diagrams">diagrams</a> where he has to find <a href="http://www.gradstein.info/tag/mate/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with mate">mate</a> in a fixed number of turns. Starting with <a href="http://www.gradstein.info/tag/mate/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with mate">mate</a> in one.<br />
It appeared that making <a href="http://www.gradstein.info/tag/diagrams/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with diagrams">diagrams</a> is an easy task, as there are many programs (Linux and Windows) that permit this.<br />
On Linux, the best I could find is <a href="http://scid.sourceforge.net/" class="liexternal">scid</a>. That&#8217;s cool as I use it to maintain my databases of games. Even cooler, is that scid development has just restarted (stopped around 2004!), with the help of <a href="http://prolinux.free.fr/scid/" class="liexternal">Pascal Georges</a>. Using scid (I&#8217;m using the 3.7devel2009 version) I can export games to HTML or even to LaTeX files.</p>
<p>At first I thought I&#8217;d create the endings myself, for example, using <a href="http://www.apronus.com/chess/diagram.php" class="liexternal">online diagrams generators</a> or using <a href="http://en.wikipedia.org/wiki/Template:Chess_diagram" rel="nofollow" class="liwikipedia">Wikipedia/MediaWiki&#8217;s templates</a>, but it was not so easy, so I thought about making a program to generate them.<br />
Generating one from scratch would take me time I really don&#8217;t have, and there are just <a href="http://www.willmcgugan.com" class="liexternal">two</a> <a href="http://www.alcyone.com/pyos/church/" class="liexternal">python</a> modules that give high-level functions to chess.<br />
So I started looking for projects similar to mine, that include games with <a href="http://www.gradstein.info/tag/mate/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with mate">mate</a> in one. I found a small database of <a href="http://www.gradstein.info/tag/mate/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with mate">mate</a> in one on my favorite <a href="http://www.chess.com/" class="liexternal">chess website</a>, in the <a href="http://www.chess.com/download/view/1171-mates-in-1" class="liexternal">download section</a>: a Chessbase datafile with 1171 <a href="http://www.gradstein.info/tag/mate/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with mate">mate</a> in one studies! So cool.</p>
<p>Well, It was really a pain to convert that Chessbase (.cbv) file, as the only program able to convert to <a href="http://www.gradstein.info/tag/pgn/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with pgn">PGN</a> is <a href="http://www.chessbase.com/download/cblight2007/index.asp" class="liexternal">running on Windows</a>　(at least it&#8217;s <a href="http://www.gradstein.info/tag/free/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with free">free</a>). You just have to follow the <a href="http://www.avlerchess.com/chess-misc/Converting_chessbase_to_PGN_for_Scid_180896.html" class="liexternal">instructions from this thread</a>.<br />
After getting a <a href="/static/mate_in_one.pgn.gz" class="lizip">nice PGN file</a>, just open it with scid, go to &#8220;Tools&#8221;, then select &#8220;Write the filter&#8221;, and choose LaTeX. You&#8217;ll get a <a href="/static/mate_in_one.tex.gz" class="lizip">TeX file</a>. Use you favorite TeX generator (Live TeX seems to be the one today), like this for example, to generate directly a <a href="http://www.gradstein.info/tag/pdf/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with pdf">PDF</a> file:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">cat mat_temp.<span style="color: black;">tex</span> |grep -v <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>$&quot;</span> &gt; mate_in_one.<span style="color: black;">tex</span><br />
latex &#8211;output-format=<a href="http://www.gradstein.info/tag/pdf/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with pdf">pdf</a> mate_in_one.<span style="color: black;">tex</span></div>
<p><em>(Yes I had to cleanup a bit the file before generating the .<a href="http://www.gradstein.info/tag/pdf/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with pdf">pdf</a>)</em></p>
<p>The result is <a href="/static/mate_in_one.pdf" class="lipdf">here</a>, 196 pages of tests (6 one each page) if you don&#8217;t want to fight with the missing TeX modules (you&#8217;ll need chess12.sty) and get a nice result.</p>
<p>I&#8217;m sure many people search for this kind of file, so I&#8217;m pretty happy to help other parents/coaches.</p>
<div id="attachment_172" class="wp-caption aligncenter" style="width: 298px"><img src="http://www.gradstein.info/wp-content/uploads/2009/02/a.jpg" alt="White mate in one" title="Mate in one" width="288" height="288" class="size-full wp-image-172" /><p class="wp-caption-text">White <a href="http://www.gradstein.info/tag/mate/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with mate">mate</a> in one</p></div>
<p>Edit: I added a <a href="/static/mate_in_one_without_solution.pdf" class="lipdf">PDF version without the solution included</a>.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/kid/idos-chess-journey-how-to-teach-chess-to-a-3-year-old-kid/" title="Ido&#8217;s chess Journey: How to teach chess to a 3 year old kid (January 28, 2009)">Ido&#8217;s chess Journey: How to teach chess to a 3 year old kid</a> (1)</li>
</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=xys5AGdP"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=7NhAwjEm"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?i=7NhAwjEm" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/SbfQPr08xfw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/kid/easy-chess-games-for-kids-mate-in-one/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ido’s chess Journey: How to teach chess to a 3 year old kid</title>
		<link>http://www.gradstein.info/kid/idos-chess-journey-how-to-teach-chess-to-a-3-year-old-kid/</link>
		<comments>http://www.gradstein.info/kid/idos-chess-journey-how-to-teach-chess-to-a-3-year-old-kid/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 01:20:24 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[chess]]></category>
		<category><![CDATA[kid]]></category>
		<category><![CDATA[école]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[kindergarten]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[petite section]]></category>
		<category><![CDATA[school]]></category>
		<category><![CDATA[teaching]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=115</guid>
		<description><![CDATA[How to teach chess to a 3 year old kid? That&#8217;s a good question. I wanted to teach Ido chess for a long time, but each time I tried, he lost focus after 2 minutes, even just for teaching him just rook movements.
I decided I needed to plan it a little more, make it much [...]]]></description>
			<content:encoded><![CDATA[<p>How to teach <a href="http://www.gradstein.info/tag/chess/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with chess">chess</a> to a 3 year old <a href="http://www.gradstein.info/tag/kid/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with kid">kid</a>? That&#8217;s a good question. I wanted to teach Ido <a href="http://www.gradstein.info/tag/chess/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with chess">chess</a> for a long time, but each time I tried, he lost focus after 2 minutes, even just for teaching him just rook movements.<br />
I decided I needed to plan it a little more, make it much more fun, and &#8220;embed&#8221; it in mini-games. It seems to work much better now, but that&#8217;s maybe because he matured a lot.</p>
<p>Here are some ideas (some not yet implemented):</p>
<ul>
<li>Using a <a href="http://annathered.wordpress.com/2009/01/25/how-to-make-japanese-style-hamburg/" class="liexternal">DIY plastified</a> <a href="http://www.gradstein.info/tag/chess/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with chess">chess</a> board, allows me to show/play different positions really fast, anywhere.</li>
<li>Colorize squares where a piece is allowed to go :<br />
<p class="flickrTag_container"><a href="http://farm4.static.flickr.com/3381/3227796869_f287f321c3.jpg" class="flickr" title="Ido colored in the squares where the bishop is allowed to go &lt;a href=&quot;http://www.flickr.com/photos/17782122@N00/3227796869/&quot;&gt;view&amp;nbsp;on&amp;nbsp;flickr&amp;raquo;&lt;/a&gt;" rel="lightbox"><img src="http://farm4.static.flickr.com/3381/3227796869_f287f321c3_m.jpg" alt="Array" class="flickr small photo" /></a></p>
</li>
<li><a href="http://www.chesskids.com/ckbook/ppawnrace.htm" class="liexternal">Pawn race games</a> (no en-passant rule yet).</li>
<li>Really small games (must not go over 5 minutes) with reduced <a href="http://www.gradstein.info/tag/chess/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with chess">chess</a> set (for example Queen and 3 pawns vs Knight, bishop and 3 pawns).</li>
<li>Checkmate in one, using <a href="http://alain.blaisot.free.fr/DiagTransfer/English/home.htm" class="liexternal">DiagTransfer</a> program to draw series of <a href="http://www.gradstein.info/tag/chess/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with chess">chess</a> diagrams. This program works only on Windows, but it works fine with Wine.<br />
<p class="flickrTag_container"><a href="http://farm4.static.flickr.com/3354/3228648000_7266b64e20.jpg" class="flickr" title="Ido found the mate in 1, for white &lt;a href=&quot;http://www.flickr.com/photos/17782122@N00/3228648000/&quot;&gt;view&amp;nbsp;on&amp;nbsp;flickr&amp;raquo;&lt;/a&gt;" rel="lightbox"><img src="http://farm4.static.flickr.com/3354/3228648000_7266b64e20_m.jpg" alt="Array" class="flickr small photo" /></a></p></p>
<p>For quick single diagrams, I found <a href="http://www.apronus.com/chess/wbeditor.php" class="liexternal">wbeditor</a>, an online javascript diagram generator.</li>
</ul>
<p>There&#8217;s a <a href="http://blog.capakaspa.info/index.php?2006/12/10/30-apprentissage-des-echecs-aux-enfants" class="liexternal">thread</a> (french) about experience from different teachers, giving really good advices.<br />
Most notably, <a href="http://pagesperso-orange.fr/veronique.houck/" class="liexternal">Véronique Houck</a> who has 15 years of experience of teaching <a href="http://www.gradstein.info/tag/chess/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with chess">chess</a> to kindergarten/maternelle children. She wrote two books (in french). One is named <a href="http://www.amazon.fr/Bibou-monde-%C3%A9checs-V%C3%A9ronique-Houck/dp/2878333934" class="liexternal">Bibou &#038; le monde des échecs</a>, and the other one <a href="http://www.echecs.com/actualites/actualites-le-jeu-d-echecs-au-cycle-2-1126.html" class="liexternal">Le jeu d&#8217;échecs au cycle2</a>. It&#8217;s not so easy to find, but using Google, you can find <a href="http://www.amazon.fr/jeu-d%C3%A9checs-cycle-2/dp/2866344081/ref=sr_1_6?ie=UTF8&#038;s=books&#038;qid=1233105118&#038;sr=8-6" class="liexternal">shows</a> <a href="http://www.decitre.fr/livres/Le-jeu-d-echecs-au-cycle-2.aspx/9782866344085" class="liexternal">many</a> <a href="http://www.priceminister.com/offer/buy/59851203/Houck-Veronique-Le-Jeu-D-echecs-Au-Cycle-2-Livre.html" class="liexternal">links</a>.</p>
<p>I&#8217;ve not yet read them. I&#8217;ll make a review when I get them.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/kid/easy-chess-games-for-kids-mate-in-one/" title="Easy chess games for kids (mate in one) (February 2, 2009)">Easy chess games for kids (mate in one)</a> (3)</li>
</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=PHBKZyNA"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=ftIfj9g9"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?i=ftIfj9g9" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/bmHhNtMJmJA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/kid/idos-chess-journey-how-to-teach-chess-to-a-3-year-old-kid/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python snippet to get Mediawiki/Wikipedia Recent Changes externally</title>
		<link>http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/</link>
		<comments>http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 23:37:35 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[rc]]></category>
		<category><![CDATA[recent changes]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wikipedia]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=94</guid>
		<description><![CDATA[Mediawiki allows one to send Recent Changes (RC) to a UDP port.
The ip address is defined by the variable wgRC2UDPAddress, and the port by the variable wgRC2UDPPort. It&#8217;s a really good idea that it&#8217;s a UDP transfer, since there is no need for any ACK, so Mediawiki doesn&#8217;t block if there is nothing listening on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mediawiki.org/" class="liexternal">Mediawiki</a> allows one to <a href="http://wikitech.wikimedia.org/view/IRCD" class="liexternal">send Recent Changes</a> (RC) to a UDP port.<br />
The ip address is defined by the variable wgRC2UDPAddress, and the port by the variable wgRC2UDPPort. It&#8217;s a really good idea that it&#8217;s a UDP transfer, since there is no need for any ACK, so <a href="http://www.gradstein.info/tag/mediawiki/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with mediawiki">Mediawiki</a> doesn&#8217;t block if there is nothing listening on that port.</p>
<p>These parameters must be set in the LocalSettings.php file, like this, for example.</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">$wgRC2UDPAddress = <span style="color: #483d8b;">&#8216;127.0.0.1&#8242;</span>;<br />
$wgRC2UDPPort = <span style="color: #ff4500;">9390</span>;</div>
<p>I wrote a really simple python program (more a proof of concept) that receives the data, cleans it, and then prints it to stdout :</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br />
<span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># vim:syntax=python:sw=4:ts=4:expandtab</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">SocketServer</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span></p>
<p>HOST,PORT = <span style="color: #483d8b;">&#8221;</span>, <span style="color: #ff4500;">9390</span></p>
<p><span style="color: #ff7700;font-weight:bold;">class</span> MyUDPHandler<span style="color: black;">&#40;</span><span style="color: #dc143c;">SocketServer</span>.<span style="color: black;">BaseRequestHandler</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">def</span> handle<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&#8216;<span style="color: #000099; font-weight: bold;">\x</span>03<span style="color: #000099; font-weight: bold;">\d</span>{0,2}&#8217;</span>, <span style="color: #483d8b;">&#8221;</span>, <span style="color: #008000;">self</span>.<span style="color: black;">request</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></p>
<p><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&#8216;__main__&#8217;</span>:<br />
&nbsp; &nbsp;server = <span style="color: #dc143c;">SocketServer</span>.<span style="color: black;">UDPServer</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>HOST, PORT<span style="color: black;">&#41;</span>, MyUDPHandler<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp;server.<span style="color: black;">serve_forever</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div>
<p>I plan to make it into a complete project that will send the data/notifications using Jabber(XMPP).</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/" title="How to skip the useless &#8220;you are now logged in&#8221; page in Mediawiki (January 18, 2009)">How to skip the useless &#8220;you are now logged in&#8221; page in Mediawiki</a> (0)</li>
	<li><a href="http://www.gradstein.info/hardware/how-to-automatically-run-a-script-after-inserting-a-usb-device-on-ubuntu/" title="How to automatically run a script after inserting a USB device on Ubuntu? (April 13, 2008)">How to automatically run a script after inserting a USB device on Ubuntu?</a> (1)</li>
</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=rphRNBoV"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=OpVRCrxK"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?i=OpVRCrxK" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/y54pSNeMO-M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to skip the useless “you are now logged in” page in Mediawiki</title>
		<link>http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/</link>
		<comments>http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 23:47:38 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=57</guid>
		<description><![CDATA[You installed Mediawiki some time ago, and now something bothers you: aren&#8217;t you tired of having an intermediate page named &#8220;Login successful&#8221; saying &#8220;You are now logged in to&#8221; before being allowed to go to the page you wanted to go? I am.
I found there&#8217;s a hook that is called just when a user successfully [...]]]></description>
			<content:encoded><![CDATA[<p>You installed Mediawiki some time ago, and now something bothers you: aren&#8217;t you tired of having an intermediate page named &#8220;Login successful&#8221; saying &#8220;You are now logged in to&#8221; before being allowed to go to the page you wanted to go? I am.<br />
I found there&#8217;s a hook that is called just when a user successfully logs on (<a href="http://www.mediawiki.org/wiki/Manual:Hooks/UserLoginComplete" class="liexternal">UserLoginComplete</a>), and even an extension named <a href="http://www.mediawiki.org/wiki/Extension:RedirectOnLogin" class="liexternal">RedirectOnLogin</a> that does the redirection for you, BUT to a fixed one. It seems the hook doesn&#8217;t give you the page you previously were before the login request.</p>
<p>So to correct this, I just found a dirty hack. That means you&#8217;ll have to patch the source, meaning also that you&#8217;ll loose some flexibility when upgrading Mediawiki :-(<br />
Anyway, if you still want to do this, here is the magic stuff:</p>
<p>Edit the file mediawiki/includes/specials/SpecialUserlogin.php and look for the function successfulLogin().<br />
At the end of it, just add (it&#8217;s just one line):</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">header<span style="color: black;">&#40;</span><span style="color: #483d8b;">&#8216;Location: ./index.php?title=&#8217;</span> . $this-&gt;mReturnTo<span style="color: black;">&#41;</span>;</div>
<p>That&#8217;s it. You&#8217;ll get redirected to the previously accessed page automatically! Really cool.</p>
<p><em>This has been successfully used on a Mediawiki 1.13.</em></p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/" title="Python snippet to get Mediawiki/Wikipedia Recent Changes externally (January 28, 2009)">Python snippet to get Mediawiki/Wikipedia Recent Changes externally</a> (0)</li>
</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=KYPLoNUX"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=FMwdGvSI"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?i=FMwdGvSI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/bLQipeI1HnE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to dial a number using Asterisk and Python</title>
		<link>http://www.gradstein.info/python/how-to-dial-a-number-using-asterisk-and-python/</link>
		<comments>http://www.gradstein.info/python/how-to-dial-a-number-using-asterisk-and-python/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 09:39:17 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[asterisk]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[voip]]></category>
		<category><![CDATA[clickto dial]]></category>
		<category><![CDATA[dial]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=33</guid>
		<description><![CDATA[I didn&#8217;t find any example in Python on how to Dial a number from an Asterisk server and link it to another channel. So here&#8217;s a quick code to do it. You just need to have a manager defined in your /etc/asterisk/manager.conf defined.
import socket
HOST=&#34;192.168.1.116&#34;
PORT=5038
p = &#34;&#34;&#34;Action: login
Events: off
Username: %(username)s
Secret: %(password)s
Action: originate
Channel: SIP/%(local_user)s
WaitTime: 60
CallerId: 600
Exten: %(phone_to_dial)s
Context: [...]]]></description>
			<content:encoded><![CDATA[<p>I didn&#8217;t find any example in <a href="http://www.gradstein.info/tag/python/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with python">Python</a> on how to Dial a number from an Asterisk server and link it to another channel. So here&#8217;s a quick code to do it. You just need to have a manager defined in your /etc/asterisk/manager.conf defined.</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">socket</span></p>
<p>HOST=<span style="color: #483d8b;">&quot;192.168.1.116&quot;</span><br />
PORT=<span style="color: #ff4500;">5038</span></p>
<p>p = <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;Action: login<br />
Events: off<br />
Username: %(username)s<br />
Secret: %(password)s</p>
<p>Action: originate<br />
Channel: SIP/%(local_user)s<br />
WaitTime: 60<br />
CallerId: 600<br />
Exten: %(phone_to_dial)s<br />
Context: default<br />
Priority: 1</p>
<p>Action: Logoff<br />
&quot;</span><span style="color: #483d8b;">&quot;&quot;</span><br />
<span style="color: #ff7700;font-weight:bold;">def</span> click_to_call<span style="color: black;">&#40;</span>phone_to_dial, username, password, local_user<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; pattern = p % <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&#8216;phone_to_dial&#8217;</span>: phone_to_dial,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&#8216;username&#8217;</span>: username,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&#8216;password&#8217;</span>: password,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&#8216;local_user&#8217;</span>: local_user<span style="color: black;">&#125;</span></p>
<p>&nbsp; &nbsp; s = <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_STREAM</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; s.<span style="color: black;">connect</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>HOST, PORT<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></p>
<p>&nbsp; &nbsp; data = s.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1024</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> l <span style="color: #ff7700;font-weight:bold;">in</span> pattern.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&#8216;n&#8217;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Sending&gt;&quot;</span>, l<br />
&nbsp; &nbsp; &nbsp; &nbsp; s.<span style="color: black;">send</span><span style="color: black;">&#40;</span>l+<span style="color: #483d8b;">&#8216;rn&#8217;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> l == <span style="color: #483d8b;">&quot;&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = s.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1024</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> data<br />
&nbsp; &nbsp; data = s.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1024</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; s.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></p>
<p><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&#8216;__main__&#8217;</span>:<br />
&nbsp; &nbsp; click_to_call<span style="color: black;">&#40;</span>phone_to_dial=<span style="color: #483d8b;">&#8216;123456789&#8242;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; username=<span style="color: #483d8b;">&#8216;manager_login&#8217;</span>, password=<span style="color: #483d8b;">&#8216;yourpass&#8217;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local_user=<span style="color: #483d8b;">&#8216;600&#8242;</span><span style="color: black;">&#41;</span></div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/software/asterisk/asterisk-cirpack-problem-with-free-and-freephonienet/" title="Asterisk cirpack problem with Free and freephonie.net (February 12, 2009)">Asterisk cirpack problem with Free and freephonie.net</a> (0)</li>
	<li><a href="http://www.gradstein.info/software/asterisk/asterisk-dadhi-module-not-working-when-using-xen/" title="Asterisk: DADHI module not working when using Xen (March 26, 2009)">Asterisk: DADHI module not working when using Xen</a> (5)</li>
</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=CdItC8zI"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=eatAwMqy"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?i=eatAwMqy" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/yqpLEoip1So" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/how-to-dial-a-number-using-asterisk-and-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synchronization methods of a file with Puppet</title>
		<link>http://www.gradstein.info/ruby/synchronization-methods-of-a-file-with-puppet/</link>
		<comments>http://www.gradstein.info/ruby/synchronization-methods-of-a-file-with-puppet/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 12:39:32 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[puppet]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[reductivelabs]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=37</guid>
		<description><![CDATA[Usually, to synchronize a file with remote hosts, using puppet, one would use the following pattern:
file &#123; &#34;/etc/init.d/pvfs2-server&#34;:
&#160; &#160; &#160; owner =&#62; root, group =&#62; root, 
&#160; &#160; &#160; mode =&#62; 755, 
&#160; &#160; &#160; source =&#62; &#34;puppet:///files/pvfs2-server&#34; &#160; &#160;
&#125;
(using &#8220;source&#8221; to copy data as-is, and using &#8220;template(&#8221;filename&#8221;) to use a template structure as data).
Or, [...]]]></description>
			<content:encoded><![CDATA[<p>Usually, to synchronize a file with remote hosts, using <a href="http://reductivelabs.com/trac/puppet/" class="liexternal">puppet</a>, one would use the following pattern:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;/etc/init.d/pvfs2-server&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; owner =&gt; root, group =&gt; root, <br />
&nbsp; &nbsp; &nbsp; mode =&gt; <span style="color: #ff4500;">755</span>, <br />
&nbsp; &nbsp; &nbsp; source =&gt; <span style="color: #483d8b;">&quot;puppet:///files/pvfs2-server&quot;</span> &nbsp; &nbsp;<br />
<span style="color: black;">&#125;</span></div>
<p>(using &#8220;source&#8221; to copy data as-is, and using &#8220;template(&#8221;filename&#8221;) to use a template structure as data).</p>
<p>Or, if one wishes to directly set the content of the target file:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;/etc/init.d/pvfs2-server&quot;</span>:<br />
&nbsp; &nbsp;owner =&gt; root, group =&gt; root, <br />
&nbsp; &nbsp;mode =&gt; <span style="color: #ff4500;">755</span>, <br />
&nbsp; &nbsp;source =&gt; <span style="color: #483d8b;">&quot;puppet:///files/pvfs2-server&quot;</span> &nbsp; &nbsp;<br />
<span style="color: black;">&#125;</span></div>
<p>Please note that on the first line, for example &#8216;file { &#8220;/etc/mpd.conf&#8221;:&#8217;), the &#8220;/etc/mpd.conf&#8221; is a merge of two functionalities/concepts: Usually, the syntax is clear and simple:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span> mon_fichier_mpd_conf:<br />
&nbsp; &nbsp; &nbsp;path =&gt; <span style="color: #483d8b;">&quot;/etc/mpd.conf&quot;</span>,<br />
&nbsp; &nbsp; &nbsp;<span style="color: black;">&#91;</span>&#8230;<span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span></div>
<p>The first line is about the resource description. Its goal is to be able to reference to it a little later from another resources (Notify[], etc.). By putting directly the file path and name (I think it&#8217;s identified as a filename and not as a description because there are quotes, or maybe it&#8217;s because it begins with a slash?) you mege the &#8220;path&#8221; attribute with its description.<br />
On the other end, we&#8217;ll not be able to reference to it later, if you need to.</p>
<p>You may also need to synchronize a file that is not present in the repository (puppet:///files/*). That usually happens, for example, when that file is regenerated by an external program or an external action (like /etc/passwd).</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;/etc/passwd&quot;</span>:<br />
&nbsp; &nbsp; &nbsp;owner =&gt; root, group =&gt; root, mode =&gt; <span style="color: #ff4500;">644</span>,<br />
&nbsp; &nbsp; &nbsp;content =&gt; <span style="color: #008000;">file</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/etc/passwd&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: black;">&#125;</span></div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li>No related posts.</li>
	</ul>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=FEGNLjqS"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?a=MdIL2rXh"><img src="http://feeds.feedburner.com/~f/LiorGradsteinsBlog?i=MdIL2rXh" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/LiorGradsteinsBlog/~4/6X4VWl0nLbs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/ruby/synchronization-methods-of-a-file-with-puppet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
