<?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; Twitter</title>
	<atom:link href="http://www.gabrielgonzalezgarcia.com/tag/twitter/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>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>
	</channel>
</rss>

