<?xml version='1.0' encoding='utf-8'?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:ns1="http://purl.org/rss/1.0/modules/syndication/" xmlns:ns2="com-wordpress:feed-additions:1" xmlns:ns4="http://purl.org/rss/1.0/modules/content/" xmlns:ns5="http://wellformedweb.org/CommentAPI/" xmlns:ns6="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>python – Thameera's Blog</title>
	<ns0:link href="https://blog.thameera.com/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.thameera.com</link>
	<description />
	<lastBuildDate>Sun, 12 May 2013 16:16:37 +0000</lastBuildDate>
	<language>en-US</language>
	<ns1:updatePeriod>
	hourly	</ns1:updatePeriod>
	<ns1:updateFrequency>
	1	</ns1:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.12</generator>
<ns2:site>139676693</ns2:site>	<item>
		<title>Feeds in your inbox</title>
		<link>https://blog.thameera.com/feeds-in-your-inbox-rss2email/</link>
					<comments>https://blog.thameera.com/feeds-in-your-inbox-rss2email/#comments</comments>
		
		<dc:creator>thameera</dc:creator>
		<pubDate>Sun, 12 May 2013 16:16:37 +0000</pubDate>
				<category>Uncategorized</category>
		<category>email</category>
		<category>google reader</category>
		<category>ifttt</category>
		<category>newsblur</category>
		<category>python</category>
		<category>rss</category>
		<guid isPermaLink="false">http://blog.thameera.com/?p=1121</guid>

					<description>Google Reader will be dead by the 1st of July. Everyone has moved or at least is considering moving to new feed aggregators. There is a heap of options out there (out of which I recommend that you try out Newsblur). But none of them has been able to boast of a good public API…&lt;p&gt;&lt;a class="more-link" href="https://blog.thameera.com/feeds-in-your-inbox-rss2email/" title="Continue reading ‘Feeds in your inbox’"&gt;Continue reading &lt;span class="meta-nav"&gt;→&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</description>
										<ns4:encoded>&lt;p&gt;Google Reader &lt;a href="http://googleblog.blogspot.com/2013/03/a-second-spring-of-cleaning.html"&gt;will be dead&lt;/a&gt; by the 1st of July. Everyone has moved or at least is considering moving to new feed aggregators. There is &lt;a href="http://replacereader.com"&gt;a heap of options&lt;/a&gt; out there (out of which I recommend that you try out &lt;a href="http://newsblur.com"&gt;Newsblur&lt;/a&gt;). But none of them has been able to boast of a good public API as our good old Google Reader did.&lt;/p&gt;
&lt;p&gt;I used to have &lt;a href="http://noisythameera.wordpress.com/2012/10/20/rss-to-email-the-right-way/"&gt;this IFTTT recipe&lt;/a&gt; that would send the articles of the most important feeds I follow to my inbox. Now that Reader is dying and no other options out there seem to offer IFTTT channels, the best solution seemed to be rss2email.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.allthingsrss.com/rss2email/"&gt;rss2email&lt;/a&gt; (how appropriately named!) is a tool used to send new feed items to your email inbox. It has been first written in Python by &lt;a href="http://en.wikipedia.org/wiki/Aaron_Swartz"&gt;Aaron Swartz&lt;/a&gt; (who happened to commit suicide a few months back). The source can be found in &lt;a href="https://github.com/turbodog/rss2email"&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;It would be much convenient if you have your own server (or a shared host). Even a desktop that runs on Linux or Mac OS X would do, but make sure it stays powered on most of the time and has a constant internet connection. This is because rss2email should be invoked periodically to check feeds using a cron job. To send email, you need to have a mail server installed and configured. If you’re using a web host, this might have already been done for you. Also make sure you have Python installed.&lt;/p&gt;
&lt;h2&gt;Setting up rss2email&lt;/h2&gt;
&lt;h3&gt;1. Download&lt;/h3&gt;
&lt;p&gt;Download rss2email with wget and extract.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;wget http://www.allthingsrss.com/rss2email/rss2email-2.70.tar.gz&lt;br/&gt;
tar xf rss2email-2.70.tar.gz&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3&gt;2. Configure&lt;/h3&gt;
&lt;p&gt;This is the most important step. The newly extracted directory contains a file called config.py which contains all the necessary configs. Most are self-descriptive. Make sure you configure the mail server settings correct. Here’s my setup:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;SMTP_SEND = 1&lt;br/&gt;
SMTP_SERVER = “mail.thameera.com:&lt;em&gt;[port]&lt;/em&gt;”&lt;br/&gt;
AUTHREQUIRED = 1&lt;br/&gt;
SMTP_USER = ‘&lt;em&gt;[emailid]&lt;/em&gt;@thameera.com’&lt;br/&gt;
SMTP_PASS = ‘&lt;em&gt;[password]&lt;/em&gt;‘&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;You can set the email address that would be in the ‘&lt;em&gt;From&lt;/em&gt;‘ field of emails in the &lt;code&gt;DEFAULT_FROM&lt;/code&gt; config.&lt;/p&gt;
&lt;h3&gt;3. Set your ‘To:’ address&lt;/h3&gt;
&lt;p&gt;See the r2e script in your extracted directory? That’s what you need to invoke for the tasks we do from now on. First, set the address of where the mail should be delivered to using the following command:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;./r2e new&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3&gt;4. Add feeds&lt;/h3&gt;
&lt;p&gt;Time to add those feeds. You can add them one by one using &lt;code&gt;./r2e add&lt;/code&gt;. For example, to add the feed of this blog:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;./r2e add http://blog.thameera.com/feed&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now if you run the following command it would grab all the feeds and send them to your email:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;./r2e run&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;However, it would send all the items available in the feeds in the first run. This could even be hundreds. Since most of you wouldn’t want this to happen, make sure you run it with &lt;code&gt;--no-send&lt;/code&gt; first.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;./r2e run –no-send&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The next time you run r2e, it would mail only the new feed items.&lt;/p&gt;
&lt;h3&gt;5. Set the cron job&lt;/h3&gt;
&lt;p&gt;You’re almost done. The last step would be to set up a cron job that would invoke r2e periodically. If you don’t know how to set up cron jobs, be a lamb and look for a tutorial online. The cron job should cd to the r2e directory and run the command &lt;code&gt;./r2e run&lt;/code&gt;. You can set the time interval as you wish. A small interval means you get the articles mailed quickly, but would cause more server load and cost bandwidth. I’ve set mine to 15 minutes.&lt;/p&gt;
&lt;p&gt;That’s it. No more Google Reader. You can sit back and relax while rss2email makes sure you never miss an important feed item. If you’re feeling adventurous, you can also go ahead and edit the python scripts to change the email format and tweak to make it more awesome.&lt;/p&gt;
</ns4:encoded>
					
					<ns5:commentRss>https://blog.thameera.com/feeds-in-your-inbox-rss2email/feed/</ns5:commentRss>
			<ns6:comments>3</ns6:comments>
		
		
		<ns2:post-id>1121</ns2:post-id>	</item>
		<item>
		<title>Action.io, django and poya days</title>
		<link>https://blog.thameera.com/action-io-django-and-poya-days/</link>
					<comments>https://blog.thameera.com/action-io-django-and-poya-days/#comments</comments>
		
		<dc:creator>thameera</dc:creator>
		<pubDate>Sat, 02 Mar 2013 09:07:30 +0000</pubDate>
				<category>Uncategorized</category>
		<category>actionio</category>
		<category>django</category>
		<category>gae</category>
		<category>github</category>
		<category>poya</category>
		<category>python</category>
		<guid isPermaLink="false">http://thameera.wordpress.com/?p=1050</guid>

					<description>Last week I got an early access invite to the private beta of Action.io. Coincidentally, I wanted to learn some Django. Hence Next Poya When? was born and it only took a few hours to start coding from scratch to deploying successfully in the Google App Engine. Action.io is a place to start your projects…&lt;p&gt;&lt;a class="more-link" href="https://blog.thameera.com/action-io-django-and-poya-days/" title="Continue reading ‘Action.io, django and poya days’"&gt;Continue reading &lt;span class="meta-nav"&gt;→&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</description>
										<ns4:encoded>&lt;p&gt;Last week I got an early access invite to the private beta of &lt;a href="http://action.io/"&gt;Action.io&lt;/a&gt;. Coincidentally, I wanted to learn some Django. Hence &lt;a href="http://www.nextpoyawhen.com"&gt;Next Poya When?&lt;/a&gt; was born and it only took a few hours to start coding from scratch to deploying successfully in the Google App Engine.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://action.io/"&gt;Action.io&lt;/a&gt; is a place to start your projects without worrying about all the mundane setup tasks. Once you sign up, you can create &lt;em&gt;boxes&lt;/em&gt;. There are cardboard boxes, plastic boxes, and.., oh wait, wrong kind of boxes. The boxes in action.io are comparable to VPSs. You can choose from Ruby on Rails, Django, Node.js and Go boxes to start with. If you get a Django box it’s already pre-installed with python, django and all other utilities required for a typical Django project. All the boxes come with a Web IDE, Emacs and everyone’s favorite Vim as editors. There is PostgreSQL and MongoDB integration as well.&lt;/p&gt;
&lt;figure aria-describedby="caption-attachment-1051" class="wp-caption aligncenter" id="attachment_1051" style="width: 700px"&gt;&lt;a href="https://blog.thameera.com/wp-content/uploads/2013/03/action-io.png"&gt;&lt;img alt="Action.io interface" class="size-large wp-image-1051" decoding="async" fetchpriority="high" height="331" src="https://blog.thameera.com/wp-content/uploads/2013/03/action-io.png" width="700"/&gt;&lt;/a&gt;&lt;figcaption class="wp-caption-text" id="caption-attachment-1051"&gt;Action.io interface (click to enlarge)&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;To set up, all I needed to do was copying my .bashrc and .vimrc files, install some Vim plugins with &lt;a href="https://github.com/tpope/vim-pathogen"&gt;Pathogen&lt;/a&gt; and add the SSH key of my box to Github. All this takes less than 10 minutes. (But don’t tell that to your Project Manager, give him 2 hours effort and he wouldn’t know!)&lt;/p&gt;
&lt;p&gt;Now create a project and start coding right away!&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;django-admin.py startproject poya&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Once you build stuff to some extent and want to test how it’s doing, the site can be previewed easily. For example, start the server with&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;python manage.py runserver 0.0.0.0:3000&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;and click on Preview -&amp;gt; Port 3000. You can choose from a range of ports from 1024 to 9999.&lt;/p&gt;
&lt;figure aria-describedby="caption-attachment-1054" class="wp-caption aligncenter" id="attachment_1054" style="width: 284px"&gt;&lt;a href="https://blog.thameera.com/wp-content/uploads/2013/03/action-io-preview.png"&gt;&lt;img alt="Previewing the site" class="size-full wp-image-1054" decoding="async" height="206" src="https://blog.thameera.com/wp-content/uploads/2013/03/action-io-preview.png" width="284"/&gt;&lt;/a&gt;&lt;figcaption class="wp-caption-text" id="caption-attachment-1054"&gt;Previewing the site&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Once done, deploying was a piece of cake. Action.io has Heroku and Google App Engine integration. Deploying the site in GAE took only a single command:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;appcfg.py --oauth2 --noauth_local_webserver update nextpoyawhen&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Then I pointed my domain to GAE and, voila, we have &lt;a href="http://www.nextpoyawhen.com"&gt;nextpoyawhen.com&lt;/a&gt; moving like jagger!&lt;/p&gt;
&lt;p&gt;It’s really amazing how fast you can get everything done with action.io. If I did all this in my laptop it’d have taken ages. It goes without saying how mundane and time-consuming it is to install all libraries, dependencies and get the environment set up in your machine. More often than not, we get tired of the project even before we really start it. We spend 80% of time setting the things up, and much less time coding.&lt;/p&gt;
&lt;p&gt;Also, since action.io lives in the web, it’s accessible from anywhere. If someone reports you a bug when you’re at office or travelling, you can just log into your box from the browser, do a hotfix and deploy within minutes. No effort spent for syncing files. You get your favorite environment setup anywhere in the world.&lt;/p&gt;
&lt;p&gt;Action.io doesn’t work offline though, at least yet. It doesn’t require a fast connection, but if yours gets disconnected often, be wary. I hope they would implement the offline capability soon.&lt;/p&gt;
&lt;p&gt;As for Django, I’m impressed by the framework. It’s quite easy to catch up with, and it’s Python. You can host Django sites in most web hosting providers (unlike node.js), including Google App Engine and Heroku both of which have free plans to serve small sites. I’m studying with &lt;a href="http://www.djangobook.com/"&gt;The Django Book&lt;/a&gt;, recommended by &lt;a href="http://raditha.com/"&gt;Raditha&lt;/a&gt;. Of course, nextpoyawhen could’ve been done with some client-side javascript, but that’d have defeated the purpose. I wanted to do something with django and try out action.io, so it’s like catching two stones with one angry bird, or whatever that is. The source code is hosted in &lt;a href="https://github.com/thameera/poya"&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, the next time you are tired of working all week and want to know when the next Poya holiday is on, you know where to look. &lt;img alt="🙂" class="wp-smiley" src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f642.png" style="height: 1em; max-height: 1em;"/&gt;&lt;/p&gt;
</ns4:encoded>
					
					<ns5:commentRss>https://blog.thameera.com/action-io-django-and-poya-days/feed/</ns5:commentRss>
			<ns6:comments>3</ns6:comments>
		
		
		<ns2:post-id>1050</ns2:post-id>	</item>
		<item>
		<title>Adding captions to images with Python</title>
		<link>https://blog.thameera.com/adding-captions-to-images-with-python/</link>
					<comments>https://blog.thameera.com/adding-captions-to-images-with-python/#comments</comments>
		
		<dc:creator>thameera</dc:creator>
		<pubDate>Tue, 28 Jun 2011 14:49:30 +0000</pubDate>
				<category>Uncategorized</category>
		<category>python</category>
		<guid isPermaLink="false">http://thameera.wordpress.com/?p=414</guid>

					<description>So I wanted to add captions to a set of images and wrote some lines of Python. Python has some cool image libraries so the job was real easy. Have never used Python before except to write some kindergarten-level programs, so this may not be the best way to code the thing. But it does…&lt;p&gt;&lt;a class="more-link" href="https://blog.thameera.com/adding-captions-to-images-with-python/" title="Continue reading ‘Adding captions to images with Python’"&gt;Continue reading &lt;span class="meta-nav"&gt;→&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</description>
										<ns4:encoded>&lt;p&gt;So I wanted to add captions to a set of images and wrote some lines of Python. Python has some cool image libraries so the job was real easy. Have never used Python before except to write some kindergarten-level programs, so this may not be the best way to code the thing. But it does the job.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;	import Image, ImageDraw, ImageFont, os

	pathz="/home/thameera/ws/img_caption/pics"
	if os.path.exists(pathz) and os.path.isdir(pathz):
		for name in os.listdir(pathz):
			print name
			fullname=pathz+'/'+name
			im = Image.open(fullname)
			namez=name[:-4]
			d = ImageDraw.Draw(im)
			f = ImageFont.truetype("Arial.ttf", 16)
			d.text((4,0), namez, font=f)
			im.save(fullname)

	else:
		print "Directory not found"
 &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It scans the given images directory and adds the file name sans extension as a caption, as shown below:&lt;/p&gt;
&lt;table border="0" cellpadding="5"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align="center"&gt;&lt;img alt="" class="alignleft size-full wp-image-418" decoding="async" height="180" src="https://blog.thameera.com/wp-content/uploads/2011/06/will-i-am_1.jpg" title="will.i.am_1" width="240"/&gt;&lt;br/&gt;
&lt;strong&gt;Original:will.i.am_1.jpg&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;   &lt;img alt="" class="alignleft size-full wp-image-419" decoding="async" height="180" loading="lazy" src="https://blog.thameera.com/wp-content/uploads/2011/06/will-i-am_11.jpg" title="will.i.am_1" width="240"/&gt;&lt;br/&gt;
&lt;strong&gt;After adding the caption&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</ns4:encoded>
					
					<ns5:commentRss>https://blog.thameera.com/adding-captions-to-images-with-python/feed/</ns5:commentRss>
			<ns6:comments>5</ns6:comments>
		
		
		<ns2:post-id>414</ns2:post-id>	</item>
	</channel>
</rss>