<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>tech &#8211; sandipb.net</title>
	<atom:link href="https://blog.sandipb.net/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sandipb.net</link>
	<description>&#62; yours truly.</description>
	<lastBuildDate>Mon, 16 Jan 2017 04:53:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.sandipb.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s2.wp.com/i/buttonw-com.png</url>
		<title>tech &#8211; sandipb.net</title>
		<link>https://blog.sandipb.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://blog.sandipb.net/osd.xml" title="sandipb.net" />
	<atom:link rel='hub' href='https://blog.sandipb.net/?pushpress=hub'/>
	<item>
		<title>Documenting both class and constructor in Sphinx</title>
		<link>https://blog.sandipb.net/2016/10/10/documenting-both-class-and-constructor-in-sphinx/</link>
		<comments>https://blog.sandipb.net/2016/10/10/documenting-both-class-and-constructor-in-sphinx/#respond</comments>
		<pubDate>Mon, 10 Oct 2016 01:23:05 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/?p=820</guid>
		<description><![CDATA[How to make Sphinx document your Python class and constructor properly.<img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=820&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p><img data-attachment-id="868" data-permalink="https://blog.sandipb.net/2016/10/10/documenting-both-class-and-constructor-in-sphinx/sphinx/" data-orig-file="https://sandipb.files.wordpress.com/2016/10/sphinx.png?w=840" data-orig-size="166,115" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="sphinx" data-image-description="" data-medium-file="https://sandipb.files.wordpress.com/2016/10/sphinx.png?w=840?w=166" data-large-file="https://sandipb.files.wordpress.com/2016/10/sphinx.png?w=840?w=166" class=" size-full wp-image-868 alignright" src="https://sandipb.files.wordpress.com/2016/10/sphinx.png?w=840" alt="sphinx" srcset="https://sandipb.files.wordpress.com/2016/10/sphinx.png 166w, https://sandipb.files.wordpress.com/2016/10/sphinx.png?w=150 150w" sizes="(max-width: 166px) 85vw, 166px"   />I lost an hour of my life today trying to figure out why Sphinx would not document a class inside a module specified by <a href="http://www.sphinx-doc.org/en/stable/ext/autodoc.html#directive-automodule">:automodule:</a>.</p>
<p>I learnt two things today.</p>
<p>Firstly, Sphinx will not document a class automatically as part of <code>:automodule:</code> if the class itself doesn&#8217;t have a docstring. You can force the class to be displayed by having an additional <code>:autoclass:</code>directive though.</p>
<p>If the class does have a doc string, it will be displayed including the documentation of its regular (ones without a leading <code>_</code> in the name) methods. It will still not show the constructor though.</p>
<p>To display the constructor, I first thought I would add the <code>:special-members:</code> option to the <code>:automodule:</code> directive. But that didn&#8217;t work very well, as it showed various unnecessary private functions as well, e.g. <code>_weakref</code>.</p>
<p>I finally discovered that the best way to get the constructor documentation displayed was using the <a href="http://www.sphinx-doc.org/en/stable/ext/autodoc.html#confval-autoclass_content">autoclass_content</a> config in the sphinx config file.</p>
<pre class="brush: python; gutter: false; title: ; notranslate">
autoclass_content = 'both'
</pre>
<p>As per the documentation,</p>
<blockquote><p>This value selects what content will be inserted into the main body of an autoclass directive. The possible values are:</p>
<ul>
<li>&#8220;class&#8221;: Only the class’ docstring is inserted. This is the default. You can still document __init__ as a separate method using automethod or the members option to autoclass.</li>
<li>&#8220;both&#8221;: Both the class’ and the __init__ method’s docstring are concatenated and inserted.</li>
<li>&#8220;init&#8221;: Only the __init__ method’s docstring is inserted.</li>
</ul>
</blockquote><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=820&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2016/10/10/documenting-both-class-and-constructor-in-sphinx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>

		<media:content url="http://sandipb.files.wordpress.com/2016/10/sphinx.png" medium="image">
			<media:title type="html">sphinx</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Python to update a required field while performing a transition in Jira</title>
		<link>https://blog.sandipb.net/2016/02/19/using-python-to-update-a-required-field-while-performing-a-transition-in-jira/</link>
		<comments>https://blog.sandipb.net/2016/02/19/using-python-to-update-a-required-field-while-performing-a-transition-in-jira/#respond</comments>
		<pubDate>Fri, 19 Feb 2016 03:08:17 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[jira]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/?p=722</guid>
		<description><![CDATA[This might be a very esoteric topic for most people, but since I could not find information about this anywhere, I decided to document this in a post. Here is the problem. I use Jira at work, and today, I needed to close a bunch of tickets based on a search result. Now, searching or &#8230; <a href="https://blog.sandipb.net/2016/02/19/using-python-to-update-a-required-field-while-performing-a-transition-in-jira/" class="more-link">Continue reading<span class="screen-reader-text"> "Using Python to update a required field while performing a transition in&#160;Jira"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=722&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<figure data-shortcode="caption" id="attachment_694" style="width: 526px" class="wp-caption aligncenter"><a href="https://www.flickr.com/photos/donsolo/3967812185/" rel="attachment wp-att-694"><img data-attachment-id="815" data-permalink="https://blog.sandipb.net/2016/02/19/using-python-to-update-a-required-field-while-performing-a-transition-in-jira/gojira/" data-orig-file="https://sandipb.files.wordpress.com/2016/02/gojira.jpg?w=840" data-orig-size="375,500" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="gojira" data-image-description="" data-medium-file="https://sandipb.files.wordpress.com/2016/02/gojira.jpg?w=840?w=225" data-large-file="https://sandipb.files.wordpress.com/2016/02/gojira.jpg?w=840?w=375" src="https://sandipb.files.wordpress.com/2016/02/gojira.jpg?w=840" alt="gojira"   class="aligncenter size-full wp-image-815" srcset="https://sandipb.files.wordpress.com/2016/02/gojira.jpg 375w, https://sandipb.files.wordpress.com/2016/02/gojira.jpg?w=113 113w, https://sandipb.files.wordpress.com/2016/02/gojira.jpg?w=225 225w" sizes="(max-width: 375px) 85vw, 375px" /></a><figcaption class="wp-caption-text">&#8220;Gojira!&#8221; by <a href="https://www.flickr.com/photos/donsolo/">donsolo</a><br /></figcaption></figure>
<p>This might be a very esoteric topic for most people, but since I could<br />
not find information about this anywhere, I decided to document this<br />
in a post.</p>
<p>Here is the problem. I use <a href="https://www.atlassian.com/software/jira">Jira</a> at work, and today, I needed<br />
to close a bunch of tickets based on a search result. Now, searching<br />
or doing batch operations is simple enough from the browser, but a<br />
small detail made the exercise impossible via the web UI.</p>
<p>Our Jira project requires a field to be filled while closing the<br />
ticket &#8211; the time spent in the ticket. This breaks Jira in all sorts<br />
of ways &#8211; the batch operation doesn&#8217;t work, some of the email-to-jira<br />
interface at work breaks as well.</p>
<p>So I looked at doing this via the <a href="https://github.com/pycontribs/jira">Jira Python library</a>. But<br />
it didn&#8217;t work as expected.</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; from jira import JIRA
&gt;&gt;&gt;
&gt;&gt;&gt; jira = JIRA(&quot;https://JIRA_URL&quot;, basic_auth=(&#039;USER_NAME&#039;, &#039;Password&#039;))
&gt;&gt;&gt;
&gt;&gt;&gt; issue = jira.issue(&quot;ISSUE-123&quot;)
&gt;&gt;&gt;
&gt;&gt;&gt; [(t[&#039;id&#039;], t[&#039;name&#039;]) for t in jira.transitions(issue)]  # What are the workflows available?
[(u&#039;4&#039;, u&#039;Start Progress&#039;), (u&#039;5&#039;, u&#039;Resolve Issue&#039;), (u&#039;2&#039;, u&#039;Close Issue&#039;), (u&#039;711&#039;, u&#039;Planning&#039;), (u&#039;751&#039;, u&#039;Blocked&#039;), (u&#039;801&#039;, u&#039;To Monitor&#039;)
&gt;&gt;&gt;
&gt;&gt;&gt; jira.transition_issue(issue, &#039;2&#039;)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
...
jira.exceptions.JIRAError: JiraError HTTP 400
    text: Time Spent is required
    url: ...
    response headers = {...}
    response text = {&quot;errorMessages&quot;:[&quot;Time Spent is required&quot;],&quot;errors&quot;:{}}

</pre>
<p>The <a href="http://jira.readthedocs.org/en/latest/#transitions">documentation on transitions</a> mentioned that<br />
we could add fields in the call to <code>jira.transitions()</code>. That didn&#8217;t<br />
work as well.</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; jira.transition_issue(issue, &#039;2&#039;, timespent=&quot;1h&quot;)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
...
jira.exceptions.JIRAError: JiraError HTTP 400
    text: Field &#039;timespent&#039; cannot be set. It is not on the appropriate screen, or unknown.
    url: ...
    response headers = ...
    response text = {&quot;errorMessages&quot;:[],&quot;errors&quot;:{&quot;timespent&quot;:&quot;Field &#039;timespent&#039; cannot be set. It is not on the appropriate screen, or unknown.&quot;}}
</pre>
<p>So I scoured the Internet for a long time, till I found <a href="https://answers.atlassian.com/questions/217485/transition-via-the-jira-rest-api-with-a-custom-field">this post</a><br />
about how to do it via the <a href="https://docs.atlassian.com/jira/REST/latest/">REST API</a> &#8211; the only official<br />
interface to Jira. Here is what needs to be sent as the body to the<br />
POST request.</p>
<pre class="brush: jscript; title: ; notranslate">
{
    &quot;transition&quot;: {
        &quot;id&quot;: &quot;2&quot;
    },
    &quot;update&quot;: {
        &quot;worklog&quot;: [
            {
                &quot;add&quot;: {
                    &quot;timeSpent&quot;: &quot;2m&quot;
                }
            }
        ]
    }
}
</pre>
<p>I felt that to be odd, till I looked at both the <a href="https://docs.atlassian.com/jira/REST/latest/#api/2/issue-doTransition">api documentation<br />
for transition</a> and the <a href="http://jira.readthedocs.org/en/latest/_modules/jira/client.html#JIRA.transition_issue">doc for transition using the<br />
python library</a> and I found out why I have not been<br />
successful till now.</p>
<p>The REST api supports two ways to update the issue while doing a<br />
transition &#8211; you can set certain fields using the <code>fields</code> option, or<br />
you can use the <code>update</code> option to do more complex changes.</p>
<p>The comment in the Python code revealed that the <code>update</code> method has<br />
not yet been implemented.</p>
<pre class="brush: python; title: ; notranslate">
    def transition_issue(self, issue, transition, fields=None, comment=None, **fieldargs):

        # TODO: Support update verbs (same as issue.update())
</pre>
<p>That put me in a bind. I had only one way to hack around this problem<br />
now &#8211; using the REST api for the specific operation I wanted, and the<br />
Python library for the rest of the work &#8211; ugly, but works for now,<br />
till the Python library is complete.</p>
<p>So here was the final solution that did what I wanted.</p>
<pre class="brush: python; title: ; notranslate">
from jira import JIRA
import requests

jira = JIRA(&quot;https://JIRA_URL&quot;, basic_auth=(&#039;USER_NAME&#039;, &#039;PASSWORD&#039;))

d = {}
d[&quot;transition&quot;]={&quot;id&quot;: &quot;2&quot;}
d[&quot;update&quot;]={&quot;worklog&quot;: [{&quot;add&quot;: {&quot;timeSpent&quot;: &quot;1h&quot;}}]}

s = requests.Session()
s.auth = (&quot;USER&quot;, &quot;PASSWORD&quot;)
s.headers.update({&quot;Content-Type&quot;: &quot;application/json&quot;})

j=&quot;https://JIRA_URL&quot;

issue_list = jira.search_issues(&quot;assignee = currentUser() AND resolution = Unresolved  and status != Closed and updatedDate &lt; &#039;2015-10-01&#039; and project=&#039;PROJECT&#039; ORDER BY updatedDate DESC&quot;)

for i in issue_list:
    print i
    s.post(j+&quot;/rest/api/2/issue/&quot;+i.key+&quot;/transitions&quot;, data=json.dumps(d))
</pre><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=722&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2016/02/19/using-python-to-update-a-required-field-while-performing-a-transition-in-jira/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>

		<media:content url="http://sandipb.files.wordpress.com/2016/02/gojira.jpg" medium="image">
			<media:title type="html">gojira</media:title>
		</media:content>
	</item>
		<item>
		<title>Software patents put on hold in India</title>
		<link>https://blog.sandipb.net/2015/12/22/software-patents-put-on-hold-in-india/</link>
		<comments>https://blog.sandipb.net/2015/12/22/software-patents-put-on-hold-in-india/#respond</comments>
		<pubDate>Tue, 22 Dec 2015 18:13:38 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[India]]></category>
		<category><![CDATA[software patents]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/?p=656</guid>
		<description><![CDATA[In a welcome move, the Indian patent office has temporarily stopped issuing software patents. &#8220;In view of several representations received regarding interpretation and scope of section 3(k) of the Patents Act 1970 (as amended), the Guidelines for Examination of Computer Related Inventions&#8230; are kept in abeyance till discussions with stakeholders are completed and contentious issues &#8230; <a href="https://blog.sandipb.net/2015/12/22/software-patents-put-on-hold-in-india/" class="more-link">Continue reading<span class="screen-reader-text"> "Software patents put on hold in&#160;India"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=656&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In a welcome move, <a href="http://economictimes.indiatimes.com/articleshow/50275687.cms?utm_source=contentofinterest&amp;utm_medium=text&amp;utm_campaign=cppst">the Indian patent office has temporarily stopped issuing software patents</a>.</p>
<blockquote><p>
  &#8220;In view of several representations received regarding interpretation and scope of section 3(k) of the Patents Act 1970 (as amended), the Guidelines for Examination of Computer Related Inventions&#8230; are kept in abeyance till discussions with stakeholders are completed and contentious issues are resolved,&#8221; the Controller General of Patents said in a notification issued last week.
</p></blockquote>
<p>Again, this is a temporary measure and given the intensive lobbying that happens behind doors, it could still be revised. But thanks to <a href="http://www.ispirt.in/">Ispirt</a>, <a href="https://www.softwarefreedom.org/">The Software Freedom Law Center</a>, this is being considered seriously by the office.</p>
<p>As the article points out, software patents are ravaging the US software industry. For the big guys, they are used akin to the Mutually Assured Destruction mentality of the cold war, with every company keeping a vast portfolio of patents to fight back with if they are attacked for the same. But there is a big impact on smaller companies too. <a href="http://www.bloomberg.com/bw/articles/2014-06-09/money-for-nothing-how-to-stop-patent-trolls-from-stifling-innovation">Bloomberg reports that</a>:</p>
<blockquote><p>
  Big companies are not the only ones being clobbered. According to a 2012 study by Boston University Law School professors Michael J. Meurer and James Bessen, some 90 percent of all patent-troll lawsuits are aimed at small and midsize companies. And these companies, when faced with unfathomable potential legal costs, often pay off the trolls just to make them go away.<br />
  &nbsp;<br />
  Overall, Meurer and Bessen found, this abusive system is draining billions of dollars annually from the economy, transferring an estimated $29 billion in 2011 alone from the bank accounts of companies that produce things to patent trolls. Of this, small and midsize businesses, the types that are often at the cutting edge of innovation, paid about 37 percent of the total–money that could have been put to much better use.
</p></blockquote><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=656&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2015/12/22/software-patents-put-on-hold-in-india/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>
	</item>
		<item>
		<title>New HTTP status code for legally unavailable resources</title>
		<link>https://blog.sandipb.net/2015/12/22/new-http-status-code-for-legally-unavailable-resources/</link>
		<comments>https://blog.sandipb.net/2015/12/22/new-http-status-code-for-legally-unavailable-resources/#respond</comments>
		<pubDate>Mon, 21 Dec 2015 23:19:34 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[ietf]]></category>
		<category><![CDATA[standards]]></category>

		<guid isPermaLink="false">http://sandipb.wordpress.com/?p=653</guid>
		<description><![CDATA[The Internet Engineering Task Force(IETF) has finally created a standard for when a page has been taken down due to legal reasons. The new status code, 451, indicates that a host has received a legal demand to deny access to a resource. Via TheNextWeb<img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=653&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<blockquote><p>The Internet Engineering Task Force(IETF) has finally created a standard for when a page has been taken down due to legal reasons. The new status code, 451, indicates that a host has received a legal demand to deny access to a resource.</p>
</blockquote>
<p><a href="http://thenextweb.com/dd/2015/12/21/theres-now-an-official-http-status-code-for-legal-takedowns-451/">Via TheNextWeb</a></p><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=653&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2015/12/22/new-http-status-code-for-legally-unavailable-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>
	</item>
		<item>
		<title>Serializing Structured Data Into Avro Using Python</title>
		<link>https://blog.sandipb.net/2015/05/20/serializing-structured-data-into-avro-using-python/</link>
		<comments>https://blog.sandipb.net/2015/05/20/serializing-structured-data-into-avro-using-python/#respond</comments>
		<pubDate>Wed, 20 May 2015 09:31:12 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[avro]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[snappy]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/2015/05/20/serializing-structured-data-into-avro-using-python</guid>
		<description><![CDATA[It is impossible to ignore Avro at work &#8211; it is the data serialization format of choice at work (and rightly so), whether it is to store data into Kafka or into our document database Espresso. Recently, I had the need to read avro data serialized by a Java application, and I looked into how &#8230; <a href="https://blog.sandipb.net/2015/05/20/serializing-structured-data-into-avro-using-python/" class="more-link">Continue reading<span class="screen-reader-text"> "Serializing Structured Data Into Avro Using&#160;Python"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=363&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img data-attachment-id="574" data-permalink="https://blog.sandipb.net/2015/05/20/serializing-structured-data-into-avro-using-python/avro-logo/" data-orig-file="https://sandipb.files.wordpress.com/2015/05/avro-logo.png" data-orig-size="296,92" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="avro-logo" data-image-description="" data-medium-file="https://sandipb.files.wordpress.com/2015/05/avro-logo.png?w=296" data-large-file="https://sandipb.files.wordpress.com/2015/05/avro-logo.png?w=296" class=" size-thumbnail wp-image-574 alignright" src="https://sandipb.files.wordpress.com/2015/05/avro-logo.png?w=150&#038;h=47" alt="Avro" width="150" height="47" srcset="https://sandipb.files.wordpress.com/2015/05/avro-logo.png?w=150&amp;h=47 150w, https://sandipb.files.wordpress.com/2015/05/avro-logo.png 296w" sizes="(max-width: 150px) 85vw, 150px" />It is impossible to ignore Avro at work &#8211; it is the data serialization format of choice at work (and rightly so), whether it is to store data into <a href="http://kafka.apache.org/">Kafka</a> or into our document database <a href="http://data.linkedin.com/projects/espresso">Espresso</a>. Recently, I had the need to read avro data serialized by a Java application, and I looked into how I might use Python to read such data.</p>
<p><!-- more --></p>
<p><span id="more-363"></span>The <a href="http://avro.apache.org/docs/1.7.6/gettingstartedpython.html">avro python library</a> uses schemas, and can store data in a <a href="http://avro.apache.org/docs/current/spec.html#binary_encoding">compact binary format</a> using both deflate and <a href="https://code.google.com/p/snappy/">snappy</a> compression. I wanted to test out how compact the serialization format is as compared to say, CSV.</p>
<p>I set up a <a href="http://docs.python-guide.org/en/latest/dev/virtualenvs/">Python virtual environment</a> using the nifty <a href="https://virtualenvwrapper.readthedocs.org/en/latest/">virtualenv wrapper</a> and installed the Python Avro library and the snappy library. On my Ubuntu system, the python snappy library is available from the package repository, but I used the Pypi one anyway. I had to install the c development package (<code>libsnappy-dev</code>) as a prerequisite though.</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
$ mkvirtualenv avro

$ workon avro

(avro) $ pip install avro

# Remember that it is 'python-snappy', and not just 'snappy', which is a
# completely different library
(avro) $ pip install python-snappy
</pre>
<p>And I was ready for my code. First I decided on a simple data set: a <a href="https://raw.githubusercontent.com/jvns/pandas-cookbook/master/data/weather_2012.csv">weather data set</a> which was part of the <a href="http://pandas.pydata.org/pandas-docs/stable/cookbook.html">Pandas cookbook</a>.</p>
<p>Based on this, I created this simple schema.</p>
<pre class="brush: jscript; gutter: false; title: ; notranslate">
{
&quot;namespace&quot;: &quot;net.sandipb.avro.example.weather&quot;,
&quot;type&quot;: &quot;record&quot;,
&quot;name&quot;: &quot;Reading&quot;,
&quot;doc&quot;: &quot;Weather reading at a point in time&quot;,
&quot;fields&quot;: [
{&quot;name&quot;: &quot;time&quot;, &quot;type&quot;: &quot;int&quot;, &quot;doc&quot;: &quot;Seconds since epoch&quot;},
{&quot;name&quot;: &quot;temp&quot;, &quot;type&quot;: &quot;float&quot;, &quot;doc&quot;: &quot;Temperature in Celsius&quot;},
{&quot;name&quot;: &quot;dew_point_temp&quot;, &quot;type&quot;: &quot;float&quot;, &quot;doc&quot;: &quot;Dew point temperature in Celsius&quot;},
{&quot;name&quot;: &quot;humidity&quot;, &quot;type&quot;: &quot;int&quot;, &quot;doc&quot;: &quot;Relative humidity %&quot;},
{&quot;name&quot;: &quot;wind_speed&quot;, &quot;type&quot;: &quot;float&quot;, &quot;doc&quot;: &quot;Wind speed in km/h&quot;},
{&quot;name&quot;: &quot;visibility&quot;, &quot;type&quot;: &quot;float&quot;, &quot;doc&quot;: &quot;Visibility in km&quot;},
{&quot;name&quot;: &quot;pressure&quot;, &quot;type&quot;: &quot;float&quot;, &quot;doc&quot;: &quot;Atmospheric pressure in kPa&quot;},
{&quot;name&quot;: &quot;weather&quot;, &quot;type&quot;: &quot;string&quot;, &quot;doc&quot;: &quot;Weather summary&quot;}
]
}
</pre>
<p>Now to actually process the file, I created <a href="https://gist.github.com/sandipb/53ce9e81569adf29d37a#file-csv_to_avro-py">this Python script</a> to read the CSV file and to write to three different avro files, each with a different compression format &#8211; null (no compression), deflate and snappy.</p>
<p>Here are some relevant parts of the code:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
# Load the avro schema to validate and serialize data
schema = avro.schema.parse(open(&quot;weather.avsc&quot;).read())

# Open using a avro container class, providing the schema to use and the
# compression to use
writer_deflate = DataFileWriter(open(&quot;weather_data_deflate.avro&quot;, &quot;wb&quot;), DatumWriter(), schema, codec=&quot;deflate&quot;)

# Write a dict with the data
writer_deflate.append(row)

# close the container
writer_deflate.close()
</pre>
<p>The result of this was … unexpected. The deflate codec showed more compression than snappy.</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
$ ls -lSh *.avro *.csv
-rw-rw-r-- 1 sandipb sandipb 492K May 20 01:34 weather_2012.csv
-rw-rw-r-- 1 sandipb sandipb 317K May 20 02:29 weather_data_null.avro
-rw-rw-r-- 1 sandipb sandipb 178K May 20 02:29 weather_data_snappy.avro
-rw-rw-r-- 1 sandipb sandipb 121K May 20 02:29 weather_data_deflate.avro
</pre>
<p>It is possible that a larger dataset could show better compression for snappy. This is the first time I have used this codec, I need to read up a bit more about it. I will try this experiment with a larger dataset and update this post in the future.</p><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=363&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2015/05/20/serializing-structured-data-into-avro-using-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>

		<media:content url="http://sandipb.files.wordpress.com/2015/05/avro-logo.png?w=150" medium="image">
			<media:title type="html">Avro</media:title>
		</media:content>
	</item>
		<item>
		<title>Difference Between Python and Ruby When It Comes to Hashes With Default Values</title>
		<link>https://blog.sandipb.net/2015/05/14/difference-between-python-and-ruby-when-it-comes-to-hashes-with-default-values/</link>
		<comments>https://blog.sandipb.net/2015/05/14/difference-between-python-and-ruby-when-it-comes-to-hashes-with-default-values/#respond</comments>
		<pubDate>Thu, 14 May 2015 11:13:44 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/2015/05/14/difference-between-python-and-ruby-when-it-comes-to-hashes-with-default-values</guid>
		<description><![CDATA[Having worked with Python for a while, I am trying to pick up Ruby, especially for some of my work with logstash. While trying out a small program in Ruby, I got stumped with a peculiar trait of Ruby hashes with default values. It made me lose an hour of my life I am not &#8230; <a href="https://blog.sandipb.net/2015/05/14/difference-between-python-and-ruby-when-it-comes-to-hashes-with-default-values/" class="more-link">Continue reading<span class="screen-reader-text"> "Difference Between Python and Ruby When It Comes to Hashes With Default&#160;Values"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=364&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Having worked with <a href="https://www.python.org">Python</a> for a while, I am trying to pick up <a href="https://www.ruby-lang.org">Ruby</a>, especially for some of my work with <a href="http://logstash.net">logstash</a>. While trying out a small program in Ruby, I got stumped with a peculiar trait of Ruby hashes with default values. It made me lose an hour of my life I am not going to get back. <img src="https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f626.png" alt="😦" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><!-- more --></p>
<p><span id="more-364"></span>In Python, dictionaries with default values is not part of the core language, and need to be imported from a standard library. For some reason I still don&#8217;t know, you cannot set a simple default <em>value</em>, you need supply a <em>function object</em> which is going to create a value for you. <img width='16' height='16' class='wp-smiley emoji' draggable='false' alt=':/' src='https://s1.wp.com/wp-content/mu-plugins/wpcom-smileys/uneasy.svg' style='height: 1em; max-height: 1em;' /></p>
<p>So if I want to create a default dictionary in Python, you need to do something like this:</p>
<pre class="brush: python; gutter: false; title: ; notranslate">
&gt;&gt;&gt; from collections import defaultdict
&gt;&gt;&gt; d = defaultdict(lambda: 5)
</pre>
<p>Now when you access any non-existent key in this hash, the hash gets magically populated with that key and the default value. See below.</p>
<pre class="brush: python; gutter: false; title: ; notranslate">
&gt;&gt;&gt; if d[&quot;one&quot;]: print &quot;not empty&quot;
...
not empty
&gt;&gt;&gt;
&gt;&gt;&gt; print dict(d)
{'one': 5}
&gt;&gt;&gt;
</pre>
<p>Ruby hashes support default values in the core language. So you can do something like:</p>
<pre class="brush: ruby; gutter: false; title: ; notranslate">
&gt;&gt; d = Hash.new(5)
=&gt; {}

&gt;&gt; puts d[&quot;a&quot;]
5
=&gt; nil

&gt;&gt; d
=&gt;&gt; {}
</pre>
<p>Wait! See the difference? Evaluating a non-existing hash position is Ruby returns the default value, but unlike Python, <strong>it doesn&#8217;t set the value!</strong></p>
<p>After it drilled down to this quirk, I looked around and found some interesting articles.</p>
<p><a href="http://dablog.rubypal.com/2008/3/25/a-short-circuit-edge-case">This article</a> from 2008 by David Black was particularly interesting. He points out in this article how this Hash behaviour breaks a very popular Ruby idiom.</p>
<p>Normally, the idiomatic Ruby way to initialize or return a variable goes like this:</p>
<pre class="brush: ruby; gutter: false; title: ; notranslate">
&gt;&gt; d = Hash.new
=&gt; {}

&gt;&gt; d[&quot;name&quot;] ||= &quot;Skye&quot;
=&gt; &quot;Skye&quot;

&gt;&gt; d
=&gt; {&quot;name&quot;=&gt;&quot;Skye&quot;}
</pre>
<p>However, if you use a Hash with a default value, it breaks this idiom because evaluating a non-existing key returns the default value. However, you would intuitively expect the <code>||=</code> operator to at least set the missing key to the default value! But that doesn&#8217;t happen due to the peculiar treatment to that operator by Ruby. Ruby evaluates <code>A ||= B</code> NOT to <code>A = A || B</code>, but <code>A || A=B</code>. This never lets the value to be assigned to keys in default hashes.</p>
<pre class="brush: ruby; gutter: false; title: ; notranslate">
&gt;&gt; d = Hash.new(&quot;May&quot;)
=&gt; {}

&gt;&gt; d[&quot;name&quot;] ||= &quot;Skye&quot;
=&gt; &quot;May&quot;

&gt;&gt; d
=&gt; {}
</pre>
<p>Some gotcha lurking there in an otherwise beautiful language.</p>
<p>Another nice ref:<br />
<a href="http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html">http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html</a></p><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=364&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2015/05/14/difference-between-python-and-ruby-when-it-comes-to-hashes-with-default-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>
	</item>
		<item>
		<title>Pagerduty&#8217;s Fantastic Zookeeper Bug</title>
		<link>https://blog.sandipb.net/2015/05/12/pagerdutys-fantastic-zookeeper-bug/</link>
		<comments>https://blog.sandipb.net/2015/05/12/pagerdutys-fantastic-zookeeper-bug/#respond</comments>
		<pubDate>Tue, 12 May 2015 06:33:52 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[pagerduty]]></category>
		<category><![CDATA[site-reliability]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[zookeeper]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/2015/05/11/pagerdutys-fantastic-zookeeper-bug</guid>
		<description><![CDATA[Ok, I don&#8217;t particularly like calling a bug fantastic, in this case, it is more of a fantastic troubleshooting of a bug. What I found interesting was the layers that were unpeeled one by one to reach the probable region of the root cause. (Yeah, the root cause is probably so esoteric and confined to &#8230; <a href="https://blog.sandipb.net/2015/05/12/pagerdutys-fantastic-zookeeper-bug/" class="more-link">Continue reading<span class="screen-reader-text"> "Pagerduty&#8217;s Fantastic Zookeeper&#160;Bug"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=365&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img data-attachment-id="397" data-permalink="https://blog.sandipb.net/2015/05/12/pagerdutys-fantastic-zookeeper-bug/zookeeper/" data-orig-file="https://sandipb.files.wordpress.com/2015/05/zookeeper.jpg?w=128&#038;h=128" data-orig-size="300,300" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="zookeeper" data-image-description="" data-medium-file="https://sandipb.files.wordpress.com/2015/05/zookeeper.jpg?w=128&#038;h=128?w=300" data-large-file="https://sandipb.files.wordpress.com/2015/05/zookeeper.jpg?w=128&#038;h=128?w=300" class="wp-image-397 alignright" src="https://sandipb.files.wordpress.com/2015/05/zookeeper.jpg?w=128&#038;h=128" alt="zookeeper" width="128" height="128" srcset="https://sandipb.files.wordpress.com/2015/05/zookeeper.jpg?w=128&amp;h=128 128w, https://sandipb.files.wordpress.com/2015/05/zookeeper.jpg?w=256&amp;h=256 256w, https://sandipb.files.wordpress.com/2015/05/zookeeper.jpg?w=150&amp;h=150 150w" sizes="(max-width: 128px) 85vw, 128px" />Ok, I don&#8217;t particularly like calling a bug <em>fantastic</em>, in this case, it is more of a fantastic troubleshooting of a bug. What I found interesting was the layers that were unpeeled one by one to reach the probable region of the root cause. (Yeah, the root cause is probably so esoteric and confined to a specific combination of version, that it is unlikely to be looked at by anybody).</p>
<p>Here is Pagerduty&#8217;s <a href="http://www.pagerduty.com/blog/the-discovery-of-apache-zookeepers-poison-packet/">summary of the bug</a>.</p>
<blockquote><p>
After more than a month of tireless research and testing, we have finally got to the bottom of our ZooKeeper mystery.</p>
<p>Corruption during AES encryption in Xen v4.1 or v3.4 paravirtual guests running a Linux 3.0+ kernel, combined with the lack of TCP checksum validation in IPSec Transport mode, which leads to the admission of corrupted TCP data on a ZooKeeper node, resulting in an unhandled exception from which ZooKeeper is unable to recover. </p>
<p>Jeez. Talk about a needle in a haystack… Even after all this, we are still unsure where precisely the bug lies. Despite that fact, we’re still pretty satisfied with the outcome of the investigation. Now all we need to do is work around it.
</p></blockquote><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=365&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2015/05/12/pagerdutys-fantastic-zookeeper-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>

		<media:content url="http://sandipb.files.wordpress.com/2015/05/zookeeper.jpg" medium="image">
			<media:title type="html">zookeeper</media:title>
		</media:content>
	</item>
		<item>
		<title>Apple Patents Tech to Allow Govt to Block Recording on Mobile Devices</title>
		<link>https://blog.sandipb.net/2013/08/08/apple-patents-tech-to-allow-govt-to-block-recording-on-mobile-devices/</link>
		<comments>https://blog.sandipb.net/2013/08/08/apple-patents-tech-to-allow-govt-to-block-recording-on-mobile-devices/#respond</comments>
		<pubDate>Thu, 08 Aug 2013 02:22:00 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[digital rights]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[patents]]></category>
		<category><![CDATA[privacy]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/2013/08/07/apple-patents-tech-to-allow-govt-to-block-recording-on-mobile-devices</guid>
		<description><![CDATA[&#160; A troubling development: Apple has patented a piece of technology which would allow government and police to block transmission of information, including video and photographs, from any public gathering or venue they deem “sensitive”, and “protected from externalities.” In other words, these powers will have control over what can and cannot be documented on &#8230; <a href="https://blog.sandipb.net/2013/08/08/apple-patents-tech-to-allow-govt-to-block-recording-on-mobile-devices/" class="more-link">Continue reading<span class="screen-reader-text"> "Apple Patents Tech to Allow Govt to Block Recording on Mobile&#160;Devices"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=367&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p>A <a href="http://rt.com/news/apple-patent-transmission-block-408/">troubling development</a>:</p>
<blockquote><p><img data-attachment-id="407" data-permalink="https://blog.sandipb.net/2013/08/08/apple-patents-tech-to-allow-govt-to-block-recording-on-mobile-devices/apple-logo-100/" data-orig-file="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840" data-orig-size="100,110" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="apple-logo-100" data-image-description="" data-medium-file="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840?w=100" data-large-file="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840?w=100" class=" size-full wp-image-407 alignright" src="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840" alt="apple-logo-100"   /><br />
Apple has patented a piece of technology which would allow government and police to block transmission of information, including video and photographs, from any public gathering or venue they deem “sensitive”, and “protected from externalities.”</p>
<p>In other words, these powers will have control over what can and cannot be documented on wireless devices during any public event.</p>
<p>And while the company says the affected sites are to be mostly cinemas, theaters, concert grounds and similar locations, Apple Inc. also says “covert police or government operations may require complete ‘blackout’ conditions.”</p></blockquote>
<p>And those who think that this is not coming for Android in the future are deluded. If Apple managed to get this technology into the field, it is only a matter of time that Android handset manufacturers are forced to incorporate this as well. If the technology exists, in today&#8217;s post 9/11 world, it is difficult to resist government pressure on such matters.</p>
<p>Of course, it would be interesting to see the security features for this tech, as this is very likely to be abused &#8211; by repressive governments (read, every one) as well as criminal enterprise (recording-free drug zones everybody?)</p><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=367&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2013/08/08/apple-patents-tech-to-allow-govt-to-block-recording-on-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>

		<media:content url="http://sandipb.files.wordpress.com/2013/08/apple-logo-100.png" medium="image">
			<media:title type="html">apple-logo-100</media:title>
		</media:content>
	</item>
		<item>
		<title>A Security Vulnerability in the Toilet</title>
		<link>https://blog.sandipb.net/2013/08/07/a-security-vulnerability-in-the-toilet/</link>
		<comments>https://blog.sandipb.net/2013/08/07/a-security-vulnerability-in-the-toilet/#respond</comments>
		<pubDate>Wed, 07 Aug 2013 03:57:00 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[japan]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/2013/08/06/a-security-vulnerability-in-the-toilet</guid>
		<description><![CDATA[Who said the field of security cannot have humour! An Android app to control the commode in Japan (you know the land of fully programmable toilets, I kid you not) has announced a vulnerability because the bluetooth pairing code is hardcoded. The alert goes: An attacker could simply download the &#8220;My Satis&#8221; application and use &#8230; <a href="https://blog.sandipb.net/2013/08/07/a-security-vulnerability-in-the-toilet/" class="more-link">Continue reading<span class="screen-reader-text"> "A Security Vulnerability in the&#160;Toilet"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=368&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img data-attachment-id="415" data-permalink="https://blog.sandipb.net/2013/08/07/a-security-vulnerability-in-the-toilet/toto-washlet/" data-orig-file="https://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg?w=840" data-orig-size="580,286" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="toto-washlet" data-image-description="" data-medium-file="https://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg?w=840?w=300" data-large-file="https://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg?w=840?w=580" class="aligncenter size-full wp-image-415" src="https://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg?w=840" alt="toto-washlet" srcset="https://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg 580w, https://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg?w=150 150w, https://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg?w=300 300w" sizes="(max-width: 580px) 85vw, 580px"   /></p>
<p>Who said the field of security cannot have humour! <a href="https://play.google.com/store/apps/details?id=jp.co.lixil.remotesatis201210&amp;hl=en">An Android app</a> to control the commode in Japan (you know the <a href="http://priceonomics.com/toilets/">land of fully programmable toilets</a>, I kid you not) has announced a vulnerability because the bluetooth pairing code is hardcoded.<br />
<!-- more --><br />
<a href="https://www.trustwave.com/spiderlabs/advisories/TWSL2013-020.txt">The alert</a> goes:</p>
<blockquote><p>An attacker could simply download the &#8220;My Satis&#8221; application and use it to cause the toilet to repeatedly flush, raising the water usage and therefore utility cost to its owner. Attackers could cause the unit to unexpectedly open/close the lid, activate bidet or air-dry functions, causing discomfort or distress to user.</p></blockquote>
<p>(via <a href="http://nakedsecurity.sophos.com/2013/08/06/just-when-you-thought-it-was-safe-to-go-back-in-the-water-closet/">Sophos Security</a>)</p><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=368&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2013/08/07/a-security-vulnerability-in-the-toilet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>

		<media:content url="http://sandipb.files.wordpress.com/2013/08/toto-washlet.jpg" medium="image">
			<media:title type="html">toto-washlet</media:title>
		</media:content>
	</item>
		<item>
		<title>Apple-touch-icon 404 Errors in Logs</title>
		<link>https://blog.sandipb.net/2013/08/07/apple-touch-icon-404-errors-in-logs/</link>
		<comments>https://blog.sandipb.net/2013/08/07/apple-touch-icon-404-errors-in-logs/#respond</comments>
		<pubDate>Wed, 07 Aug 2013 02:35:00 +0000</pubDate>
		<dc:creator><![CDATA[Sandip]]></dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.sandipb.net/2013/08/06/apple-touch-icon-404-errors-in-logs</guid>
		<description><![CDATA[Curious about several peculiar Apple related 404 errors for images in my web server logs, I decided to find what is going on, and became knowledgeable about yet another nugget that I really didn&#8217;t want to know. (sigh) The puzzle was these log lines frequently coming up in my web server access logs. I first &#8230; <a href="https://blog.sandipb.net/2013/08/07/apple-touch-icon-404-errors-in-logs/" class="more-link">Continue reading<span class="screen-reader-text"> "Apple-touch-icon 404 Errors in&#160;Logs"</span></a><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=369&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img data-attachment-id="407" data-permalink="https://blog.sandipb.net/2013/08/08/apple-patents-tech-to-allow-govt-to-block-recording-on-mobile-devices/apple-logo-100/" data-orig-file="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840" data-orig-size="100,110" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="apple-logo-100" data-image-description="" data-medium-file="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840?w=100" data-large-file="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840?w=100" class=" size-full wp-image-407 alignright" src="https://sandipb.files.wordpress.com/2013/08/apple-logo-100.png?w=840" alt="apple-logo-100"   /></p>
<p>Curious about several peculiar Apple related 404 errors for images in my web server logs, I decided to find what is going on, and became knowledgeable about yet another nugget that I really didn&#8217;t want to know. (sigh)</p>
<p><!-- more --></p>
<p>The puzzle was these log lines frequently coming up in my web server access logs.</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
...
GET /apple-touch-icon-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon.png HTTP/1.1&quot; 404
GET /apple-touch-icon-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon.png HTTP/1.1&quot; 404
GET /apple-touch-icon-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon.png HTTP/1.1&quot; 404
GET /apple-touch-icon-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon.png HTTP/1.1&quot; 404
GET /apple-touch-icon-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon-114x114-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon-114x114.png HTTP/1.1&quot; 404
GET /apple-touch-icon-precomposed.png HTTP/1.1&quot; 404
GET /apple-touch-icon.png HTTP/1.1&quot; 404
...
</pre>
<p>I first thought that I got something in my web site theme wrong, and grepped everywhere but could not spot this URL anywhere. When it didn&#8217;t turn up anything, I searched on the web for a bit and this is what I found out.</p>
<p>These queries are sent out by mostly Apple devices, and maybe some Android ones too, just to be compatible.</p>
<p>These URLs are the equivalent of favicons in Apple&#8217;s world. So instead of implementing the <a href="http://www.w3.org/2005/10/howto-favicon">standard favicon definition using &#8220;link&#8221; tags</a>, Apple apparently implemented their <a href="http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW11">own convention</a>.</p>
<p>So, if you have OCD about these matters (404s in logs) like me, and really lazy on the other hand (the Apple standards will require you to create several versions of these icons) you should create a <code>144x144</code> PNG file with your favicon and place it in the root of your website with both these names &#8211; <code>apple-touch-icon.png</code> and <code>apple-touch-icon-precomposed.png</code>. That will show them apples. Heh. Umm. I will end here.</p>
<p><strong>References:</strong></p>
<ol>
<li>Stackoverflow: <a href="http://stackoverflow.com/questions/12480497/why-am-i-getting-error-for-apple-touch-icon-precomposed-png">Why am I getting error for apple-touch-icon-precomposed.png</a></li>
<li>Ghacks: <a href="http://www.ghacks.net/2012/03/16/why-webmasters-should-analyze-their-404-error-log/">Why Webmasters Should Analyze Their 404 Error Log</a></li>
<li>Mathias Bynens: <a href="http://mathiasbynens.be/notes/touch-icons">Everything you always wanted to know about touch icons</a></li>
<li><a href="http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW11">Apple&#8217;s guidelines on creating &#8220;web clips&#8221;</a></li>
</ol><img alt="" border="0" src="https://pixel.wp.com/b.gif?host=blog.sandipb.net&#038;blog=86170&#038;post=369&#038;subd=sandipb&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://blog.sandipb.net/2013/08/07/apple-touch-icon-404-errors-in-logs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/43fd58fc3d047ad8687bafb338041da8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sandipb</media:title>
		</media:content>

		<media:content url="http://sandipb.files.wordpress.com/2013/08/apple-logo-100.png" medium="image">
			<media:title type="html">apple-logo-100</media:title>
		</media:content>
	</item>
	</channel>
</rss>
