<?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>Advanced Software Engineering &#187; Programming</title>
	<atom:link href="http://www.gabrielgonzalezgarcia.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gabrielgonzalezgarcia.com</link>
	<description>or something like that</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:19:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SVN &amp; TRAC Backup</title>
		<link>http://www.gabrielgonzalezgarcia.com/2012/01/28/svn-trac-backu/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2012/01/28/svn-trac-backu/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 21:18:50 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[UNIX world]]></category>

		<guid isPermaLink="false">http://www.gabrielgonzalezgarcia.com/?p=555</guid>
		<description><![CDATA[After a few server crashes I had to write this very same script each time so I better keep it up here and maybe someone find it useful 1 2 3 4 5 6 7 8 9 10 11 12 13 #!/bin/sh &#160; PREFIX=/var/develbackup SVNFOO=/home/svnuser/repos/foo TRACFOO=/home/svnuser/trac-env/foo &#160; DATE=$&#40; date +%Y%m%d &#41; BACKUPDIR=backup-${DATE} &#160; mkdir ${PREFIX}/${BACKUPDIR} [...]]]></description>
			<content:encoded><![CDATA[<p>After a few server crashes I had to write this very same script each time so I better keep it up here and maybe someone find it useful</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">PREFIX</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>develbackup
<span style="color: #007800;">SVNFOO</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>svnuser<span style="color: #000000; font-weight: bold;">/</span>repos<span style="color: #000000; font-weight: bold;">/</span>foo
<span style="color: #007800;">TRACFOO</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>svnuser<span style="color: #000000; font-weight: bold;">/</span>trac-env<span style="color: #000000; font-weight: bold;">/</span>foo
&nbsp;
<span style="color: #007800;">DATE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d <span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">BACKUPDIR</span>=backup-<span style="color: #800000;">${DATE}</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${PREFIX}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${BACKUPDIR}</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">svnadmin</span> dump <span style="color: #800000;">${SVNFOO}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${PREFIX}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${BACKUPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>svn-foo.dump.gz
trac-admin <span style="color: #800000;">${TRACFOO}</span> hotcopy <span style="color: #800000;">${PREFIX}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${BACKUPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>trac-foo</pre></td></tr></table></div>

<p>And the crontab line is as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">30</span> <span style="color: #000000;">22</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>svnuser<span style="color: #000000; font-weight: bold;">/</span>develbackup.sh</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2012/01/28/svn-trac-backu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding CAN Protocols I</title>
		<link>http://www.gabrielgonzalezgarcia.com/2011/06/21/understanding-can-protocols-i/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2011/06/21/understanding-can-protocols-i/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 17:17:31 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Embedded Systems]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CAN]]></category>
		<category><![CDATA[CANBus]]></category>
		<category><![CDATA[CANOpen]]></category>
		<category><![CDATA[embedded systems]]></category>

		<guid isPermaLink="false">http://www.gabrielgonzalezgarcia.com/?p=450</guid>
		<description><![CDATA[&#160; This is the first article in a serie about CANBus and higher-level protocols, which are extensibily used in Industrial environtmens along with Embedded Systems. CANBus standard describes only the layer 1 and 2, from an OSI point of view, dealing with physical and datalink activities. On the other hand, CANOpen is a protocol which [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>This is the first article in a serie about <strong>CANBus </strong>and higher-level protocols, which are extensibily used in Industrial environtmens along with Embedded Systems.</p>
<p><strong>CANBus </strong>standard describes only the layer 1 and 2, from an OSI point of view, dealing with physical and datalink activities. On the other hand, <strong>CANOpen </strong>is a protocol which lies in the OSI layer 7.</p>
<p>There is no need for intermediate layers in these kind of busses since all of them belong to the same network segment; neither the notion of session is available in CAN networks.</p>
<p>&nbsp;</p>
<div id="attachment_452" class="wp-caption aligncenter" style="width: 550px"><img class="size-full wp-image-452" title="CANBus" src="http://www.gabrielgonzalezgarcia.com/wp-content/uploads/2011/06/CANBus.png" alt="CANBus" width="540" height="230" /><p class="wp-caption-text">CANBus</p></div>
<p>As can be seen in the image above, <strong>CANBus </strong>uses two wires for the communication bus and transceiver only need hook these two lines (and the ground). In some representations, as the above, you may see the bus both sides ended, this is usually done by a 120 Ohms resistor which is only mandatory when the bus exceeds a normal length.</p>
<p>For now, the fields, in a <strong>CANBus Frame</strong>, we are going to care about are identifier, which is 11 bit wide in the base version, and the data field holding as much as 8 bytes in each frame, the rest of the fields deal with synchronization of frames and error checking, you can find them in <a title="CAN Data Frame" href="http://en.wikipedia.org/wiki/Controller_Area_Network#Data_frame" target="_blank">Wikipedia CAN Entry.</a></p>
<p>&nbsp;</p>
<p><strong>CANOpen</strong></p>
<p><strong>CANOpen</strong> is a protocol built on top of <strong>CAN</strong>, but can run in different link layers, which implements an object centric message system. The main entity in <strong>CANOpen </strong>is the <strong><em>Object Dictionary</em></strong>, which is a description of all the objects supported by an specific device, it doesn&#8217;t matter the format it is delivered in as long as both side of the communication are aware of it. The protocol is profile based defining each of them different objects that must be implemented by the device</p>
<p>Each Object has its own 16bit wide index and another 8bit wide address for referecing subdata fields.  As can be seen in the next table there range of these address which are mapped to specific functions described in different profiles e.g. CiA 301 (communication profile area):</p>
<p>&nbsp;<br />
<center><br />
<table width="337" height="248">
<tbody>
<tr>
<th>Index</th>
<th>Object</th>
</tr>
<tr>
<td>0000</td>
<td>Not Used</td>
</tr>
<tr>
<td>0001 &#8211; 001F</td>
<td>Static Data Types (Boolean, Integer16, etc)</td>
</tr>
<tr>
<td>0020 &#8211; 003F</td>
<td>Complex Data Types</td>
</tr>
<tr>
<td>0040 &#8211; 005F</td>
<td>Manufacturer Specific Complex Data Types</td>
</tr>
<tr>
<td>0060 &#8211; 007F</td>
<td>Device Profile Specific Static Data Types</td>
</tr>
<tr>
<td>0080 &#8211; 009F</td>
<td>Device Profile Specific Complex Data Types</td>
</tr>
<tr>
<td>00A0 &#8211; 0FFF</td>
<td>reserved</td>
</tr>
<tr>
<td>1000- 1FFF</td>
<td>Communication Profile Area</td>
</tr>
<tr>
<td>2000 &#8211; 5FFF</td>
<td>Manufacturer Specific Profile Area</td>
</tr>
<tr>
<td>6000 &#8211; 9FFF</td>
<td>Standardised Device Profile Area</td>
</tr>
<tr>
<td>A000 &#8211; FFFF</td>
<td>reserved</td>
</tr>
</tbody>
</table>
<p></center><br />
In order to simplify communication in CANOpen redefines the CAN identification scheme as follow and renaming it as COB-ID:</p>
<p><center><img class="size-full wp-image-465 aligncenter" title="COB-ID" src="http://www.gabrielgonzalezgarcia.com/wp-content/uploads/2011/06/COB-ID.png" alt="COB-ID" width="415" height="106" /></center></p>
<p>So with this new specification we have 4 bits to specify the function the message is requesting to perform and 7 bits spare for device&#8217;s ID which span from 1 to 127, being 0 forbidden.</p>
<p>Function Codes can be either pre-defined by the standard or custom, modified after the devices powers-up.</p>
<p>The tables below shows the configuration for the pre-defined connection set; the first for broadcast messages and the second one for peer-to-peer object messages:<br />
<center><br />
<table>
<tbody>
<tr>
<th>Object</th>
<th>Function Code</th>
<th>COB-ID</th>
<th>Communication Parameters at OD idx</th>
</tr>
<tr>
<td>NMT Module Control</td>
<td>0000</td>
<td>000h</td>
<td>-</td>
</tr>
<tr>
<td>SYNC</td>
<td>0001</td>
<td>080h</td>
<td>1005h, 1006h, 1007h</td>
</tr>
<tr>
<td>TIME STAMP</td>
<td>0010</td>
<td>100h</td>
<td>1012h, 1013h</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th>Object</th>
<th>Function Code</th>
<th>COB-ID</th>
<th>Communication Parameters at OD idx</th>
</tr>
<tr>
<td>EMERGENCY</td>
<td>0001</td>
<td>081h &#8211; 0FFh</td>
<td>1024h, 1015h</td>
</tr>
<tr>
<td>PD0 1 (transmit)</td>
<td>0011</td>
<td>181h &#8211; 1FFh</td>
<td>1800h</td>
</tr>
<tr>
<td>PD0 1 (receive)</td>
<td>0100</td>
<td>201h &#8211; 27Fh</td>
<td>1400h</td>
</tr>
<tr>
<td>PD0 2 (transmit)</td>
<td>0101</td>
<td>281h &#8211; 2FFh</td>
<td>1801h</td>
</tr>
<tr>
<td>PD0 2 (receive)</td>
<td>0110</td>
<td>301h &#8211; 37Fh</td>
<td>1401h</td>
</tr>
<tr>
<td>PD0 3 (transmit)</td>
<td>0111</td>
<td>381h &#8211; 3FFh</td>
<td>1802h</td>
</tr>
<tr>
<td>PD0 3 (receive)</td>
<td>1000</td>
<td>401h &#8211; 47Fh</td>
<td>1402h</td>
</tr>
<tr>
<td>PD0 4 (transmit)</td>
<td>1001</td>
<td>481h &#8211; 4FFh</td>
<td>1803h</td>
</tr>
<tr>
<td>PD0 4 (receive)</td>
<td>1010</td>
<td>501h &#8211; 57Fh</td>
<td>1403h</td>
</tr>
<tr>
<td>SDO (transmit/server)</td>
<td>1011</td>
<td>581h &#8211; 5FFh</td>
<td>1200h</td>
</tr>
<tr>
<td>PD0 4 (receive/client)</td>
<td>1100</td>
<td>601h &#8211; 67Fh</td>
<td>1200h</td>
</tr>
<tr>
<td>NMT Error Control</td>
<td>1110</td>
<td>701h &#8211; 77Fh</td>
<td>1016h, 1017h</td>
</tr>
</tbody>
</table>
<p></center><br />
<strong>Type of CANOpen Message</strong></p>
<p>&nbsp;</p>
<p><em>Administrative Messages:</em></p>
<ul>
<li>This messages fall in the category of Master &#8211; Slave communication such as those dealing with initialization or  network configuration. As an example <strong>NMT </strong>is used to initialize, start/stop nodes, etc</li>
</ul>
<p><em>Service Data messages (SDO):</em></p>
<ul>
<li>This messages provide access to device&#8217;s objects using the Object Dictionary index and subindex and allows data transfer of any length.</li>
<li>Each message needs to be confirmed and each request / reply transports 8 bytes rendering this kind of service not suitable for RT data transfer.</li>
</ul>
<p><em>Process Data Object (PDO):</em></p>
<ul>
<li>Used to transfer RT data from one producer to several consumers and each message is limited up to 8 Bytes.</li>
<li>Each PDO is described by two objects, one for setting the COB-ID, transmission type, inhibit time and timer period and the other to map list of objects from the Object Dictionary mapped into the PDO.</li>
<li>The objects mapped to a PDO are configured using SDO messages.</li>
<li>There are to modes: SYNC (triggered by a SYNC object, ASYNC (triggered by a device event)</li>
<li>Inhibite time: Minimun time betweet 2 PDOs</li>
<li>Event Timer: Transmission Trigger</li>
</ul>
<p><em>Predefined Messages:</em></p>
<ul>
<li>SYNC: Used to synchronized operations across the network, when device receive a SYNC message the perform the expected action.</li>
<li>Time &#8211; Stamp: Common time frame reference</li>
<li>Emergency: Triggered by an error in a device</li>
<li>Node/Life Guarding: Monitor state of Devices, detects network errors, etc</li>
<li>Boot-up: By sending an NMT message the slave change from state Initialising to Preoperational</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2011/06/21/understanding-can-protocols-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Man In Remote</title>
		<link>http://www.gabrielgonzalezgarcia.com/2011/04/18/man-in-remote/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2011/04/18/man-in-remote/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 09:53:19 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Computer Security]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gabrielgonzalezgarcia.com/?p=436</guid>
		<description><![CDATA[&#160; Man In Remote Setup After presenting this talk first at RootedCon and a month later at Hackito Ergo Sum the time for releasing the code behind it has arrived. To understand the source code, you only need to have a look at the deployment diagram where the attacker is drawn in red and the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">&nbsp;</p>
<div class="mceTemp mceIEcenter" style="text-align: left;">
<dl id="attachment_437" class="wp-caption   aligncenter" style="width: 530px;">
<dt class="wp-caption-dt"><a href="http://www.gabrielgonzalezgarcia.com/wp-content/uploads/2011/04/MiR-Setup.png"><img class="size-full wp-image-437 " title="Man In Remote Setup" src="http://www.gabrielgonzalezgarcia.com/wp-content/uploads/2011/04/MiR-Setup.png" alt="Man In Remote Setup" width="520" height="272" /></a></dt>
<dd class="wp-caption-dd">Man In Remote Setup</dd>
</dl>
</div>
<p style="text-align: left;">After presenting this talk first at <a title="RootedCON" href="http://www.rootedcon.es" target="_blank">RootedCon</a> and a month later at <a title="Hackito Ergo Sum" href="http://www.hackitoergosum.org" target="_blank">Hackito Ergo Sum</a> the time for releasing the code behind it has arrived.</p>
<p style="text-align: left;">To understand the source code, you only need to have a look at the deployment diagram where the attacker is drawn in red and the victim in green.<span id="more-436"></span>They have been designed as two independent components which exchange method invocations using a simple Marshalling/UnMarshalling scheme.</p>
<p style="text-align: left;">Although the proof is conceptually multiplatform I have only implemented the windows part so the source code is a Microsoft Visual Studio Solution with two projects, Attacker and Victim.</p>
<p style="text-align: left;"><strong>Attacker</strong></p>
<ul>
<li>It is a dll implementing the PKCS#11 API ready to be added as a Security Device in Firefox as follows: Tools-&gt;Options-&gt;Encryption Tab-&gt;Security Devices-&gt;Load</li>
<li>Instead of accessing any local device each method marshalls the parameters and sends them to the remote peer then  waiting for the response to arrive.</li>
<li>A file at C:\pkcs11-ip.cfg must contain the IP address where the library will be sending requests.</li>
</ul>
<p><strong>Victim</strong></p>
<ul>
<li>Binds a socket and waits for PKCS#11 requests to arrive</li>
<li>After a new request has been read, the official PKCS#11 library is used to perform the selected operation and retrieve its output sending it back to the Attacker.</li>
</ul>
<p style="text-align: left;">I have uploaded the <a title="Man In Remote" href="https://github.com/ggonzalez/Man-In-Remote" target="_blank">source code to github</a>, it is provided with known issues so do not blame for them, this is just a PoC.</p>
<p style="text-align: left;">Here you can find the presentation in <a title="Man In Remote" href="http://www.slideshare.net/rootedcon/gabriel-gonzalez-maninremote-pkcs11-for-fun-and-nonprofit-rootedcon-2011" target="_blank">Spanish</a> and here in <a title="Man In Remote" href="http://www.gabrielgonzalezgarcia.com/wp-content/uploads/2011/04/Man_In_Remote_-_HES2011.pdf" target="_blank">English</a>, they are pretty much the same.</p>
<p style="text-align: left;">Any question, bug, improvement, whatever please leave a comment below!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2011/04/18/man-in-remote/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Traversing Form&#039;s inputs in Jquery</title>
		<link>http://www.gabrielgonzalezgarcia.com/2010/12/09/traversing-form-input-jquery/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2010/12/09/traversing-form-input-jquery/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 09:00:05 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.advansen.com/?p=156</guid>
		<description><![CDATA[Well, I also do some 2.0 stuff since I have been working in a web project for quite a long time, which I hope to release soon. One problem I found was accessing all the inputs in a form, knowing the ID, even those under divs tag inside the form. Something like the following: &#60;form [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I also do some 2.0 stuff since I have been working in a web project for quite a long time, which I hope to release soon.<br />
<br />
One problem I found was accessing all the inputs in a form, knowing the ID, even those under divs tag inside the form.<br />
<br />
Something like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form id=&quot;myform&quot;&gt;
  &lt;input /&gt;
  &lt;div&gt;
    &lt;input /&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;input /&gt;
  &lt;/div&gt;
&lt;/form&gt;</pre></div></div>

<p>After trying different combinations and asking around I found the right expression to traverse all the inputs was the next one:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myform input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">//do whatever you need</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2010/12/09/traversing-form-input-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python: Simple Socket Server</title>
		<link>http://www.gabrielgonzalezgarcia.com/2010/09/27/python-simple-socket-server/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2010/09/27/python-simple-socket-server/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 19:29:44 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[UNIX world]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.advansen.com/?p=148</guid>
		<description><![CDATA[The simplest socket server, don&#8217;t know why but I always forget how bind is used in python. import socket &#160; sock = socket.socket&#40;socket.AF_INET, socket.SOCK_STREAM&#41; sock.bind&#40;&#40;&#34;127.0.0.1&#34;, 1024 + 666&#41;&#41; sock.listen&#40;5&#41; &#160; &#160; client, details = sock.accept&#40;&#41; while 1: data = client.recv&#40;1024&#41; print &#34;data : %s&#34; % repr&#40;data&#41;]]></description>
			<content:encoded><![CDATA[<p>The simplest socket server, don&#8217;t know why but I always forget how bind is used in python.</p>

<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;
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_STREAM</span><span style="color: black;">&#41;</span>
sock.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;127.0.0.1&quot;</span>, <span style="color: #ff4500;">1024</span> + <span style="color: #ff4500;">666</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
sock.<span style="color: black;">listen</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
client, details = sock.<span style="color: black;">accept</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:
    data = client.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1024</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;data : %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">repr</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2010/09/27/python-simple-socket-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python: POST XML over HTTP</title>
		<link>http://www.gabrielgonzalezgarcia.com/2010/07/22/python-post-xml-over-http/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2010/07/22/python-post-xml-over-http/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 13:46:26 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.advansen.com/?p=138</guid>
		<description><![CDATA[Short post to remind myself how to do HTTP requests using python, really easy stuff that I quickly forget. Straight forward example using httplib and urllib from python. In the example I just perform some kind of login request retrieve the session id and then other request sending XML data using POST. Code! Feel free [...]]]></description>
			<content:encoded><![CDATA[<p>Short post to remind myself how to do HTTP requests using python, really easy stuff that I quickly forget.</p>
<p>Straight forward example using httplib and urllib from python. In the example I just perform some kind of login request retrieve the session id and then other request sending XML data using POST.</p>
<p>Code! Feel free to send improvements</p>

<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;">httplib</span>, <span style="color: #dc143c;">urllib</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
&nbsp;
params = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlencode</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">'q'</span>: <span style="color: #483d8b;">'login'</span>, <span style="color: #483d8b;">'email'</span>: <span style="color: #483d8b;">'juasjuas@lol.com'</span>, <span style="color: #483d8b;">'pwd'</span>: <span style="color: #483d8b;">'lala'</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
&nbsp;
conn = <span style="color: #dc143c;">httplib</span>.<span style="color: black;">HTTPConnection</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;my.lolizator.com:80&quot;</span><span style="color: black;">&#41;</span>
conn.<span style="color: black;">request</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;GET&quot;</span>, <span style="color: #483d8b;">&quot;/cmd.php?&quot;</span>+params<span style="color: black;">&#41;</span>
response = conn.<span style="color: black;">getresponse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> response.<span style="color: black;">status</span>, response.<span style="color: black;">reason</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#data = response.read()</span>
<span style="color: #808080; font-style: italic;">#print data</span>
&nbsp;
cookies = response.<span style="color: black;">getheader</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;set-cookie&quot;</span><span style="color: black;">&#41;</span>
m = <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.*PHPSESSID=([a-zA-Z0-9]+);.*'</span>, cookies<span style="color: black;">&#41;</span>
session = m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;session %s&quot;</span> <span style="color: #66cc66;">%</span> session
XML=<span style="color: #483d8b;">'&lt;tag1 name=&quot;testgroup&quot;&gt;&lt;tag2 id=&quot;12&quot; type=&quot;3&quot;&gt;&lt;tag3 id=&quot;1&quot;&gt;aaa&lt;/tag3&gt;&lt;/tag2&gt;&lt;/tag1&gt;'</span>
params = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlencode</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">'q'</span>: <span style="color: #483d8b;">'set'</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
headers = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;Cookie&quot;</span>: <span style="color: #483d8b;">&quot;PHPSESSID=&quot;</span> + session, <span style="color: #483d8b;">&quot;Content-type&quot;</span>: <span style="color: #483d8b;">&quot;text/xml&quot;</span>,
            <span style="color: #483d8b;">&quot;Content-Length&quot;</span>: <span style="color: #483d8b;">&quot;%d&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>XML<span style="color: black;">&#41;</span><span style="color: black;">&#125;</span>
conn.<span style="color: black;">request</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;POST&quot;</span>, <span style="color: #483d8b;">&quot;/cmd.php?&quot;</span>+params, <span style="color: #483d8b;">&quot;&quot;</span>, headers<span style="color: black;">&#41;</span>
conn.<span style="color: black;">send</span><span style="color: black;">&#40;</span>XML<span style="color: black;">&#41;</span>
response = conn.<span style="color: black;">getresponse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> response.<span style="color: black;">status</span>, response.<span style="color: black;">reason</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> response.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
conn.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2010/07/22/python-post-xml-over-http/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter Internal Fragmentation: Python + Twitter</title>
		<link>http://www.gabrielgonzalezgarcia.com/2010/01/25/twitter-internal-fragmentation-python-twitter/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2010/01/25/twitter-internal-fragmentation-python-twitter/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 09:32:55 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[open source tools]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.advansen.com/?p=129</guid>
		<description><![CDATA[As a toy project to play a little bit more with Python and accessing Twitter, I came out with the idea of calculating the Internal Fragmentation of user&#8217;s tweet. To interface with Twitter services I used the Twitter extension located at http://code.google.com/p/python-twitter/, which has a pretty straightforward API. The script shown below gives you back [...]]]></description>
			<content:encoded><![CDATA[<p>As a toy project to play a little bit more with <strong>Python </strong>and accessing <strong>Twitter</strong>, I came out with the idea of calculating the <a href="http://en.wikipedia.org/wiki/Fragmentation_(computer)">Internal Fragmentation</a> of user&#8217;s tweet.</p>
<p>To interface with Twitter services I used the <a href="http://code.google.com/p/python-twitter/">Twitter extension</a> located at <a href="http://code.google.com/p/python-twitter/">http://code.google.com/p/python-twitter/</a>, which has a pretty straightforward API.</p>
<p>The script shown below gives you back what average percentage of your last 20 tweets have been wasted.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span>  twitter
<span style="color: #ff7700;font-weight:bold;">import</span>  <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">2</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span>   <span style="color: #483d8b;">&quot;Provide a Twitter Username as Argument&quot;</span>
        exit<span style="color: black;">&#40;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
api = twitter.<span style="color: black;">Api</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
st = api.<span style="color: black;">GetUserTimeline</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">sum</span> = <span style="color: #ff4500;">0.0</span>
<span style="color: #ff7700;font-weight:bold;">for</span> s <span style="color: #ff7700;font-weight:bold;">in</span> st:
        <span style="color: #008000;">sum</span> += <span style="color: black;">&#40;</span><span style="color: #ff4500;">140.0</span> - <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>s.<span style="color: black;">text</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;utf-8&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>/<span style="color: #ff4500;">140.0</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s internal fragmentation is %.2f%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, <span style="color: #008000;">round</span><span style="color: black;">&#40;</span><span style="color: #008000;">sum</span> / <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>st<span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">100</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;%&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>And now some results:<br />
<code><br />
$ python twinternal.py GabrielGonzalez<br />
GabrielGonzalez internal fragmentation is 39.89%<br />
$ python twinternal.py 48bits<br />
48bits internal fragmentation is 36.79%<br />
$ python twinternal.py reversemode<br />
reversemode internal fragmentation is 38.72%<br />
$ python twinternal.py aramosf<br />
aramosf internal fragmentation is 32.41%<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2010/01/25/twitter-internal-fragmentation-python-twitter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating an Installer Using NSIS (I)</title>
		<link>http://www.gabrielgonzalezgarcia.com/2009/09/01/creating-an-installer-using-nsis-i/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2009/09/01/creating-an-installer-using-nsis-i/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 09:00:26 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[NSIS]]></category>
		<category><![CDATA[open source tools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.advansen.com/?p=85</guid>
		<description><![CDATA[Last week I faced a new problem, I had to program a installer for Windows in order to deploy some software we have produced at work. After a quick googling I found NSIS an installer generator, open source and with a simple scripting language. NSIS comes with a compiler which parses the sentences writting in [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I faced a new problem, I had to program a <strong><em>installer for Windows</em></strong> in order to deploy some software we have produced at work. After a quick googling I found <a href="http://nsis.sourceforge.net/Main_Page"><strong><em>NSIS</em></strong></a><strong><em> </em></strong>an installer generator, <strong><em>open source</em></strong> and with a simple scripting language.</p>
<p><em><strong>NSIS </strong></em>comes with a compiler which parses the sentences writting in its own language and produces a pretty decent installer. It also has a <a href="http://nsis.sourceforge.net/NSIS_2">look-and-feeling similar to latets Windows versions</a>, so it was the perfect choice!</p>
<p>The scripting language is really simple, we can generate a simple installer with only the next few lines:</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">outFile &#8220;installer.exe&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">installDir $DESKTOP</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">section</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>userInfo::getAccountType</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>pop $0</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>strCmp $0 &#8220;Admin&#8221; +3</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>messageBox MB_OK &#8220;not admin: $0&#8243;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>return</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>messageBox MB_OK &#8220;is admin&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>setOutPath $INSTDIR</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>file test.txt</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>writeUninstaller $INSTDIR\uninstaller.exe</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>createShortCut &#8220;$SMPROGRAMS\new oxtias.lnk&#8221; &#8220;$INSTDIR\uninstaller.exe&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">sectionEnd</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">section &#8220;Uninstall&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>delete $INSTDIR\uninstaller.exe</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>delete $INSTDIR\test.txt</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>delete &#8220;$SMPROGRAMS\new oxtias.lnk&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">sectionEnd</div>
<blockquote><p>OutFile &#8220;simpleAdvansenInstaller.exe&#8221;</p>
<p>InstallDir $DESKTOP</p>
<p>Section</p>
<p><span style="white-space:pre"> </span>SetOutPath $INSTDIR</p>
<p><span style="white-space:pre"> </span>WriteUninstaller $INSTDIR\uninstaller.exe</p>
<p><span style="white-space:pre"> </span>CreateShortCut &#8220;$SMPROGRAMS\simpleAdvansen.lnk&#8221; &#8220;$INSTDIR\uninstaller.exe&#8221;</p>
<p>SectionEnd</p>
<p>Section &#8220;Uninstall&#8221;</p>
<p><span style="white-space:pre"> </span>Delete $INSTDIR\uninstaller.exe</p>
<p><span style="white-space:pre"> </span>Delete $INSTDIR\test.txt</p>
<p><span style="white-space:pre"> </span>Delete &#8220;$SMPROGRAMS\simpleAdvansen.lnk&#8221;</p>
<p>SectionEnd</p></blockquote>
<p>After compiling the script with the tool NSIS package&#8217;s comes with, two executables are generated:</p>
<blockquote><p>simpleAdvansenInstaller.exe</p></blockquote>
<p>Which will copy the uninstaller.exe to the Installation Dir set up to the Desktop and will add an entry in the Programs Menu for the uninstaller.</p>
<blockquote><p>uninstaller.exe</p></blockquote>
<p>Will delete itself and remove the entry in the Programs Menu.</p>
<p>NOTE: NotePad++ highlights the syntax of <em><strong>NSIS </strong></em>as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2009/09/01/creating-an-installer-using-nsis-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Glueing applications with Python</title>
		<link>http://www.gabrielgonzalezgarcia.com/2009/08/27/glueing-applications-with-python/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2009/08/27/glueing-applications-with-python/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 12:54:44 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.advansen.com/?p=82</guid>
		<description><![CDATA[The problem I faced was the following: Two processes I have to communicate with in order to validate data using stdin/stdout No source code of this programs Windows Platform Since I am a UNIX guy I haven&#8217;t ever done anything advanced in Windows so I didn&#8217;t have the time to learn how to achive this [...]]]></description>
			<content:encoded><![CDATA[<p>The problem I faced was the following:</p>
<ul>
<li>Two processes I have to communicate with in order to validate data using stdin/stdout</li>
<li>No source code of this programs</li>
<li>Windows Platform</li>
</ul>
<p>Since I am a UNIX guy I haven&#8217;t ever done anything advanced in Windows so I didn&#8217;t have the time to learn how to achive this in Windows as I would have done in any other Unix. Obviously I downloaded Mingw and I tried to used the proper POSIX functions but it didn&#8217;t work.</p>
<p>Now is when Python comes into play. It is an <em>&#8220;easy to learn&#8221;</em> (at sometime I will be discussing this topic) scripting language with a pretty well support in Windows platform, at some point this support seemed better than perl&#8217;s one so I chose Python.</p>
<p>After googling for 2 minutes about basic Python syntax and looking for function descriptions I came up with the solution, which was really straightforward and worked super-duper.</p>
<blockquote><p>import subprocess</p>
<p>program = subprocess.Popen(['C:\path\to\program.exe, arg1, argn'], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE);</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 105px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>ret = check_ad.communicate(username + &#8221; &#8221; + group[0])</div>
<p>ret = program.communicate(&#8220;writing to stdin&#8221;);</p>
<p>print ret</p>
<p><em>Read from stdout</em></p></blockquote>
<p>Really easy and simple code that can save someones life when working under pressure and do not have time to read a dozen of C/C++ examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2009/08/27/glueing-applications-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Classifying Bugs!</title>
		<link>http://www.gabrielgonzalezgarcia.com/2006/10/15/classifying-bugs/</link>
		<comments>http://www.gabrielgonzalezgarcia.com/2006/10/15/classifying-bugs/#comments</comments>
		<pubDate>Sun, 15 Oct 2006 15:26:50 +0000</pubDate>
		<dc:creator>Gabriel Gonzalez</dc:creator>
				<category><![CDATA[Computer Security]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.advansen.com/2006/10/15/classifying-bugs/</guid>
		<description><![CDATA[I have just published a new paper under the &#8220;Good Coding Practices&#8221; section, which I think can be useful for someone else. In this article I classify the bugs depending where in the life cycle of development they can be produced. This would be helpful to reduce the bugs which can be produced in the [...]]]></description>
			<content:encoded><![CDATA[<p>I have just published a new paper under the &#8220;<a href="http://www.advansen.com/projects/good-coding-practices/">Good Coding Practices</a>&#8221; section, which I think can be useful for someone else.</p>
<p>In this article I classify the bugs depending where in the life cycle of development they can be produced. This would be helpful to reduce the bugs which can be produced in the softwae development and will help if any bug appears since we know, just with its behaviour, where in the life cycle was produce. Therefore we will be able to react sooner and fix it in less time.</p>
<p>This is the base of comming papers about building secure software systems from a software engineering point of view.</p>
<p>Besied the <a href="http://www.advansen.com/staff/gabriel/papers/Classifying_Your_Bugs.pdf">PDF</a>  and <a href="http://www.advansen.com/staff/gabriel/papers/Classifying_Your_Bugs.html">HTML</a> versions I always provide this time I have the <a href="http://docs.google.com/View?docid=dgrmqhpp_4fpmjpv">Google</a> version as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gabrielgonzalezgarcia.com/2006/10/15/classifying-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

