<?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>Code Painters</title>
	<atom:link href="http://blog.codepainters.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codepainters.com</link>
	<description>The Art of Coding</description>
	<lastBuildDate>Mon, 28 Jan 2013 20:41:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Embedded Android from O&#8217;Reilly &#8211; finally!</title>
		<link>http://blog.codepainters.com/2013/01/28/embedded-android-from-oreilly-finally/</link>
		<comments>http://blog.codepainters.com/2013/01/28/embedded-android-from-oreilly-finally/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 20:40:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[embedded]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=1010</guid>
		<description><![CDATA[I've just received an e-mail about a new update of "Embedded Android" e-book available. Finally! It took 15 months to write all the chapters (the first early preview from October 2011 contained only 4 chapters), browsing the PDF confirmed however that it was worth waiting. If you're serious about Android development, this book is a [...]]]></description>
				<content:encoded><![CDATA[<p>I've just received an e-mail about a new update of <a href="http://shop.oreilly.com/product/0636920021094.do">"Embedded Android"</a> e-book available. Finally! It took 15 months to write all the chapters (the first early preview from October 2011 contained <a href="http://blog.codepainters.com/2012/05/03/embedded-android-from-oreilly-is-coming/">only 4 chapters</a>), browsing the PDF confirmed however that it was worth waiting. If you're serious about Android development, this book is a must!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2013/01/28/embedded-android-from-oreilly-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the CPU type on Mac?</title>
		<link>http://blog.codepainters.com/2012/12/28/how-to-get-cpu-type-on-mac/</link>
		<comments>http://blog.codepainters.com/2012/12/28/how-to-get-cpu-type-on-mac/#comments</comments>
		<pubDate>Fri, 28 Dec 2012 18:52:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=1004</guid>
		<description><![CDATA[For those (like me) missing /proc/cpuinfo badly: slimac:~ czajnik$ sysctl -n machdep.cpu.brand_string Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz Sure, it only gives a CPU model, but well... It's still better than System Information level of details More detailed info can be obtained by printing all sysctl variables with names starting with machdep.cpu. Not as human [...]]]></description>
				<content:encoded><![CDATA[<p>For those (like me) missing <code>/proc/cpuinfo</code> badly:</p>
<pre class="brush:bash">
slimac:~ czajnik$ sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
</pre>
<p>Sure, it only gives a CPU model, but well... It's still better than <em>System Information</em> level of details <img src='http://blog.codepainters.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  More detailed info can be obtained by printing all <code>sysctl</code> variables with names starting with <code>machdep.cpu</code>. Not as human readable as <code>/proc/cpuinfo</code>, but still very useful:</p>
<pre class="brush:bash">
slimac:~ czajnik$ sysctl -a | grep '^machdep\.cpu'
machdep.cpu.max_basic: 13
machdep.cpu.max_ext: 2147483656
machdep.cpu.vendor: GenuineIntel
machdep.cpu.brand_string: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
machdep.cpu.family: 6
machdep.cpu.model: 58
machdep.cpu.extmodel: 3
machdep.cpu.extfamily: 0
machdep.cpu.stepping: 9
machdep.cpu.feature_bits: 3219913727 2142954431
machdep.cpu.leaf7_feature_bits: 641
machdep.cpu.extfeature_bits: 672139520 1
machdep.cpu.signature: 198313
machdep.cpu.brand: 0
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 xAPIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0 RDRAND F16C
machdep.cpu.leaf7_features: RDWRFSGS SMEP ENFSTRG
machdep.cpu.extfeatures: SYSCALL XD EM64T LAHF RDTSCP TSCI
machdep.cpu.logical_per_package: 16
machdep.cpu.cores_per_package: 8
machdep.cpu.microcode_version: 21
machdep.cpu.processor_flag: 0
machdep.cpu.mwait.linesize_min: 64
machdep.cpu.mwait.linesize_max: 64
machdep.cpu.mwait.extensions: 3
machdep.cpu.mwait.sub_Cstates: 135456
machdep.cpu.thermal.sensor: 1
machdep.cpu.thermal.dynamic_acceleration: 1
machdep.cpu.thermal.invariant_APIC_timer: 1
machdep.cpu.thermal.thresholds: 2
machdep.cpu.thermal.ACNT_MCNT: 1
machdep.cpu.thermal.core_power_limits: 0
machdep.cpu.thermal.fine_grain_clock_mod: 1
machdep.cpu.thermal.package_thermal_intr: 1
machdep.cpu.thermal.hardware_feedback: 0
machdep.cpu.thermal.energy_policy: 0
machdep.cpu.xsave.extended_state: 7 832 832 0
machdep.cpu.arch_perf.version: 3
machdep.cpu.arch_perf.number: 4
machdep.cpu.arch_perf.width: 48
machdep.cpu.arch_perf.events_number: 7
machdep.cpu.arch_perf.events: 0
machdep.cpu.arch_perf.fixed_number: 3
machdep.cpu.arch_perf.fixed_width: 48
machdep.cpu.cache.linesize: 64
machdep.cpu.cache.L2_associativity: 8
machdep.cpu.cache.size: 256
machdep.cpu.tlb.inst.small: 64
machdep.cpu.tlb.data.small: 64
machdep.cpu.tlb.data.large: 32
machdep.cpu.tlb.shared: 512
machdep.cpu.address_bits.physical: 36
machdep.cpu.address_bits.virtual: 48
machdep.cpu.core_count: 2
machdep.cpu.thread_count: 4
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/12/28/how-to-get-cpu-type-on-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gevent monkey patching versus sniffer &amp; nose</title>
		<link>http://blog.codepainters.com/2012/11/20/gevent-monkey-patching-versus-sniffer-nose/</link>
		<comments>http://blog.codepainters.com/2012/11/20/gevent-monkey-patching-versus-sniffer-nose/#comments</comments>
		<pubDate>Tue, 20 Nov 2012 12:25:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[gevent]]></category>
		<category><![CDATA[nose]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sniffer]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=988</guid>
		<description><![CDATA[Unless you already know, gevent is a great library built on top of greenlet module and libevent event loop, that allows for easy coroutine-based cooperative multitasking in networked applications. By the way, you know the C10K paper, don't you? One of gevent's important features is monkey patching - ability to patch some standard Python modules [...]]]></description>
				<content:encoded><![CDATA[<p>Unless you already know, <a href="http://blog.codepainters.com/go/gevent/">gevent</a> is a great library built on top of <a href="http://blog.codepainters.com/go/greenlet/">greenlet</a> module and <a href="http://blog.codepainters.com/go/libevent/">libevent</a> event loop, that allows for easy coroutine-based cooperative multitasking in networked applications. By the way, you know the <a href="http://blog.codepainters.com/go/c10k/">C10K</a> paper, don't you? </p>
<p>One of <code>gevent</code>'s important features is <a href="http://blog.codepainters.com/go/monkey/">monkey patching</a> - ability to patch some standard Python modules to make them cooperative. There's no magic here, thanks to Python's dynamic nature <code>gevent</code> simply replaces the standard APIs with its own cooperative equivalents. Existing blocking code can then be reused without any modifications. Cool, isn't it? Most notably, <code>gevent</code> patches <a href="http://blog.codepainters.com/go/socket/">socket</a> (replacing blocking I/O with libevent-based asynchronous one), <a href="http://blog.codepainters.com/go/thread/">thread</a> and <a href="http://blog.codepainters.com/go/threading/">threading</a> modules (replacing threads with greenlets). <span id="more-988"></span></p>
<p>There are some gotchas, however. Due to the way the patching work, it is important to patch all the necessary modules before they are imported by any 3rd party library you want to use. For example, this snippet works fine:</p>
<pre class="brush:python">
import gevent.monkey; gevent.monkey.patch_thread()
import threading
</pre>
<p>It is enough, however, to swap the lines:</p>
<pre class="brush:python">
import threading
import gevent.monkey; gevent.monkey.patch_thread()
</pre>
<p>Now this simple 2 lines snippet triggers an exception:</p>
<pre class="brush:python">
Exception KeyError: KeyError(3072570908L,) in &lt;module 'threading' from
 '/usr/lib/python2.7/threading.pyc'&gt; ignored
</pre>
<p>Why it happens? When <code>threading</code> module is imported it uses main thread ID as a key in some module-level thread dictionary. At exit time it tries to obtain the thread instance from this dictionary (using current thread ID) to perform some clean up, but the ID of the main thread is no longer the same, thanks to patching. If patching is performed before importing the <code>threading</code> module (as in the first example above), all is fine, as the thread ID stored at import time comes from patched threads implementation already. For more details, see my <a href="http://blog.codepainters.com/go/stack_answer/">StackOverflow answer</a>.</p>
<p>The above example was trivial, things get more nasty in real life scenarios. I came across this problem again recently when trying to use <a href="http://blog.codepainters.com/go/sniffer/">sniffer</a> for testing. It's enough to patch threading in the test file to trigger the problem. Let's start with the following test file, <code>test.py</code>:</p>
<pre class="brush:python">
import gevent.monkey; gevent.monkey.patch_thread()
import unittest

class TestTesting(unittest.TestCase):

    def test_nose(self):
        self.assertTrue(True)
</pre>
<p>Sniffer works fine when started, nothing indicates the problems to come:</p>
<pre class="brush:text">
Did not find 'scent.py', running nose:
.
----------------------------------------------------------------------
Ran 1 test in 0.009s

OK
In good standing
</pre>
<p>But it's enough to touch the test file to make it explode (there are more exceptions, but I copy the first one only for brevity):</p>
<pre class="brush:text">
Traceback (most recent call last):
  File "/home/czajnik/env/local/lib/python2.7/site-packages/sniffer/runner.py", line 95, in _run
    if self.run():
  File "/home/czajnik/env/local/lib/python2.7/site-packages/sniffer/runner.py", line 177, in run
    return super(ScentSniffer, self).run()
  File "/home/czajnik/env/local/lib/python2.7/site-packages/sniffer/runner.py", line 115, in run
    import nose
  File "/home/czajnik/env/local/lib/python2.7/site-packages/nose/__init__.py", line 1, in <module>
    from nose.core import collector, main, run, run_exit, runmodule
  File "/home/czajnik/env/local/lib/python2.7/site-packages/nose/core.py", line 11, in <module>
    from nose.config import Config, all_config_files
  File "/home/czajnik/env/local/lib/python2.7/site-packages/nose/config.py", line 8, in <module>
    from nose.util import absdir, tolist
  File "/home/czajnik/env/local/lib/python2.7/site-packages/nose/util.py", line 19, in <module>
    log = logging.getLogger('nose')
  File "/usr/lib/python2.7/logging/__init__.py", line 1555, in getLogger
    return Logger.manager.getLogger(name)
  File "/usr/lib/python2.7/logging/__init__.py", line 1022, in getLogger
    _acquireLock()
  File "/usr/lib/python2.7/logging/__init__.py", line 217, in _acquireLock
    _lock.acquire()
  File "/usr/lib/python2.7/threading.py", line 122, in acquire
    me = _get_ident()
  File "/home/czajnik/env/local/lib/python2.7/site-packages/gevent/thread.py", line 28, in get_ident
    return id(getcurrent())
TypeError: 'NoneType' object is not callable
</pre>
<p>Clearly, logging module uses threads (fair enough - it tries to make logging API thread-safe). Unfortunately, not much can be done here, all the imports are performed before our module even gets loaded. As a workaround I've hacked <code>nose/core.py</code>, adding this line just before <code>logging</code> import:</p>
<pre class="brush:python">
  import gevent.monkey; gevent.monkey.patch_thread()
</pre>
<p>Now <code>sniffer</code> works fine, yet it's a hack, obviously. For my project it's enough, as I use separate virtual environment and thus I can hack around without consequences. But this problem<br />
definitely asks for some clean solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/11/20/gevent-monkey-patching-versus-sniffer-nose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python care and feeding, the Dropbox way</title>
		<link>http://blog.codepainters.com/2012/09/17/python-care-and-feeding-the-dropbox-way/</link>
		<comments>http://blog.codepainters.com/2012/09/17/python-care-and-feeding-the-dropbox-way/#comments</comments>
		<pubDate>Mon, 17 Sep 2012 10:59:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[reverse engineering]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=975</guid>
		<description><![CDATA[I've just revealed (by pure accident, actually), that Dropbox client binary (i.e. Dropbox.exe file) is in fact a zip file with compiled Python files inside (.pyc files, that is). Interesting, huh? A closer look at the executable file (as well as googling for some strings found in the binary) points to the tool used to [...]]]></description>
				<content:encoded><![CDATA[<p>I've just revealed (by pure accident, actually), that <a href="http://dropbox.com">Dropbox</a> client binary (i.e. <code>Dropbox.exe</code> file) is in fact a zip file with compiled Python files inside (<code>.pyc</code> files, that is). Interesting, huh? A closer look at the executable file (as well as googling for some strings found in the binary) points to the tool used to pack the application into a single executable file - it's <a href="http://www.py2exe.org/" title="py2exe">py2exe</a>!</p>
<p>Needless to say, it's tempting to look closer at the <code>.pyc</code> files, or even try to decompile them. Here comes the surprise - the files seem encrypted. Typically, <code>.pyc</code> contains a lot of human-readable strings (at least the file name and variable/function names), but it's not the case with files from unzipped <code>Dropbox.exe</code>:</p>
<pre class="brush:bash">
czajnik@czajnik:~/work/dropbox/exe$ strings distutils/__init__.pyc  
Oc {
z4E7ls
]yD~
:z&lt;n
</pre>
<p>Also, every <code>.pyc</code> file starts with a <a href="http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html">4-byte magic number</a> - in case of extracted <code>.pyc</code> files, the magic number equals <code>0xb7f20d0a</code> - no public Python release ever used this value.</p>
<p>It seems that Dropbox team decided to patch the Python interpreter with some decryption routines, in order to protect the application from reverse engineering. Note, that the Python interpreter (<code>Python25.dll</code>) itself is embedded inside <code>Dropbox.exe</code> as a resource, it can be easily extracted with any resource editor. I guess it's time to start <a href="http://www.hex-rays.com/products/ida/index.shtml">IDA Pro</a> and look deeper <img src='http://blog.codepainters.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Edit:</strong> For the curious - I've spent some time digging deeper. It turned out there are 2 protection levels - one is a decryption routine plugged into code demarshalling part of <code>static PyObject *r_object(RFILE *p)</code> function (see <code>marshall.c</code>). It's fairly easy to work it around, even without fully disassembling it - nothing stops one from building a small <code>.exe</code> which calls original code in the DLL to decrypt the file. However, there is another protection - the Python virtual machine opcodes are mixed. This required a bit of manual reverse engineering of <code>PyObject *PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)</code> (see <code>ceval.c</code>), but also turned out to be fairly easy. Now I'm able to <a href="https://github.com/codepainters/uncompyle2" class="broken_link">uncompyle</a> nearly all the files.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/09/17/python-care-and-feeding-the-dropbox-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WSGI deployment under a subpath using uWSGI and Nginx</title>
		<link>http://blog.codepainters.com/2012/08/05/wsgi-deployment-under-a-subpath-using-uwsgi-and-nginx/</link>
		<comments>http://blog.codepainters.com/2012/08/05/wsgi-deployment-under-a-subpath-using-uwsgi-and-nginx/#comments</comments>
		<pubDate>Sun, 05 Aug 2012 14:26:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[uwsgi]]></category>
		<category><![CDATA[webapps]]></category>
		<category><![CDATA[wsgi]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=946</guid>
		<description><![CDATA[It's relatively obvious how to deploy a WSGI application using Nginx, and there are many tutorials out there dealing with this very task. It took me quite a few minutes, however, to figure out how to deploy the application under non-root URL, e.g. http://some.site.com/admin/. This is typically dealt with by configuring the SCRIPT_NAME CGI parameter, [...]]]></description>
				<content:encoded><![CDATA[<p>It's relatively obvious how to deploy a <a href="http://wsgi.readthedocs.org/en/latest/index.html" title="WSGI">WSGI</a> application using <a href="http://nginx.org/" title="Nginx">Nginx</a>, and there are many <a href="http://liangsun.org/2012/02/pyramid-nginx-uwsgi-mysql/">tutorials</a> out there dealing with this very task. It took me quite a few minutes, however, to figure out how to deploy the application under non-root URL, e.g. <code>http://some.site.com/admin/</code>.</p>
<p>This is typically dealt with by configuring the <code>SCRIPT_NAME</code> <a href="http://www.perlfect.com/articles/cgi_env.shtml">CGI parameter</a>, and letting this name be removed from the beginning of the <code>PATH_INFO</code> parameter by the WSGI environment, before the path is passed down to the application. This way the WSGI application routing remains the same, no matter where in the URL tree it is deployed. The application needs to be aware of <code>SCRIPT_NAME</code> parameter only to generate proper URLs to self. <span id="more-946"></span></p>
<p>It turned out that Nginx configuration need to contain magical <code>uwsgi_parameter1 30;</code> setting, e.g.: </p>
<pre class="brush:javascript">
server {
    // ...
    location /admin/ {
        uwsgi_pass unix:/path/to/uwsgi.socket;
        include uwsgi_params;
        uwsgi_param SCRIPT_NAME /admin;
        uwsgi_modifier1 30;
    }
}
</pre>
<p>The <code>uwsgi_modifier1</code> parameter is listed in the Nginx's <a href="http://wiki.nginx.org/HttpUwsgiModule">uWSGI module documentation</a>, but it doesn't really explain what <code>modifier1</code> is? Why it needs to be 30? The answer can be found in the <a href="http://projects.unbit.it/uwsgi/wiki/uwsgiProtocol">uWSGI protocol documentation</a>. The <code>modifier1</code> is simply used to denote the uWSGI protocol's packet type. According to the table, value 30 means:</p>
<blockquote><p>Standard WSGI request followed by the HTTP request body. The PATH_INFO is automatically modified, removing the SCRIPT_NAME from it.</p></blockquote>
<p>Packets of type 0 (default) and 30 differ only in how <code>SCRIPT_INFO</code> is handled. I really wish there was a better documentation for this kind of feature. The parameter names used don't help googling, either...</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/08/05/wsgi-deployment-under-a-subpath-using-uwsgi-and-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The weirdest programming language feature ever</title>
		<link>http://blog.codepainters.com/2012/07/12/the-weirdest-programming-language-feature-ever/</link>
		<comments>http://blog.codepainters.com/2012/07/12/the-weirdest-programming-language-feature-ever/#comments</comments>
		<pubDate>Thu, 12 Jul 2012 09:50:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[webapps]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=938</guid>
		<description><![CDATA[I have to admit I had a long break from web applications development, and the topic changed a lot over the last few years. As I'm developing a web app now, I decided to improve my JavaScript knowledge, just to learn about an exceptionally awkward language feature. In JavaScript, each statement can be terminated with [...]]]></description>
				<content:encoded><![CDATA[<p>I have to admit I had a long break from web applications development, and the topic changed a lot over the last few years. As I'm developing a web app now, I decided to improve my JavaScript knowledge, just to learn about an exceptionally awkward language feature.<span id="more-938"></span> </p>
<p>In JavaScript, each statement can be terminated with a semicolon. If it is not, the semicolon is inserted automatically by the language implementation (the exact rules are irrelevant here, you can easily find it). Sounds innocent at first, but it is actually quite dangerous. Let's say we want to return an array from a function:</p>
<pre class="brush:javascript">
function a()
{
    return [ 'a' ]
}
print (a());
</pre>
<p>The result matches our expectations: </p>
<pre class="brush:bash">
czajnik@lapcio:~$ rhino a.js
a
</pre>
<p>Now let's insert a new line after the <code>return</code> statement:</p>
<pre class="brush:javascript">
function b() 
{
    return
    [ 'b' ]
}
print (b());
</pre>
<p>This snippet produces the following output: </p>
<pre class="brush:bash">
czajnik@lapcio:~$ rhino b.js
undefined
</pre>
<p>That's because a semicolon was inserted automatically after <code>return</code>, and the array alone on the next line is acceptable syntax (in JavaScript an expression alone is a valid statement). This is weird, pathetic and scary...</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/07/12/the-weirdest-programming-language-feature-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RaspberryPi finally arrived!</title>
		<link>http://blog.codepainters.com/2012/06/05/raspberrypi-finally-arrived/</link>
		<comments>http://blog.codepainters.com/2012/06/05/raspberrypi-finally-arrived/#comments</comments>
		<pubDate>Tue, 05 Jun 2012 10:41:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Embedded]]></category>
		<category><![CDATA[RaspberryPi]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=891</guid>
		<description><![CDATA[After 3 months of waiting my Raspberry Pi eventually arrived from Farnell. Time to give it a try! Unfortunately I have to look for another SD card, as it doesn't boot properly with the one I have (kernel panic, due to init not found). In case you're curious about the beverage - it's kvass]]></description>
				<content:encoded><![CDATA[<p>After 3 months of waiting my <a href="http://raspberrypi.org">Raspberry Pi</a> eventually arrived from <a href="http://farnell.com/">Farnell</a>. Time to give it a try! Unfortunately I have to look for another SD card, as it doesn't boot properly with the one I have (kernel panic, due to init not found). In case you're curious about the beverage - it's <a href="http://en.wikipedia.org/wiki/Kvass">kvass</a> <img src='http://blog.codepainters.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
				<div class="gallery_box_single">
											<div class="gallery clearfix">
															<div class="gllr_image_row">
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6708.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6708.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6708.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6728.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6728.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6728.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6710.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6710.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6710.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																</div>
																<div class="gllr_image_row">
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6711.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6711.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6711.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6734.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6734.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6734.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6737.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6737.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6737.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																</div>
																<div class="gllr_image_row">
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6739.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6739.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6739.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																	<div class="gllr_image_block">
										<p style="width:180px;height:140px;">
																						<a rel="gallery_fancybox" href="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6735.JPG" title="">
												<img style="width:160px;height:120px; border-width: 10px; border-color:#F1F1F1" alt="" title="" src="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6735.JPG" rel="http://blog.codepainters.com/wp-content/uploads/2012/06/IMG_6735.JPG" />
											</a>
																						</p>
										<div style="width:180px; " class="gllr_single_image_text">&nbsp;</div>
									</div>
																</div>
														</div>
											</div>
					<div class="clear"></div>
							<script type="text/javascript">
		(function($){
			$(document).ready(function(){
				$("a[rel=gallery_fancybox]").fancybox({
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'titlePosition' 	: 'inside',
					'speedIn'					:	500, 
					'speedOut'				:	300,
					'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
						return '<span id="fancybox-title-inside">' + (title.length ? title + '<br />' : '') + 'Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
					}				});
			});
		})(jQuery);
		</script>
	
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/06/05/raspberrypi-finally-arrived/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedded Android from O&#8217;Reilly is coming!</title>
		<link>http://blog.codepainters.com/2012/05/03/embedded-android-from-oreilly-is-coming/</link>
		<comments>http://blog.codepainters.com/2012/05/03/embedded-android-from-oreilly-is-coming/#comments</comments>
		<pubDate>Thu, 03 May 2012 18:08:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[embedded]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=827</guid>
		<description><![CDATA[Note: Code Painters site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com. There are dozens of books about Android application development published already, adding little value to what can be found in [...]]]></description>
				<content:encoded><![CDATA[<p><font style="font-size: smaller;"><em>Note: Code Painters site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.</em></font></p>
<p>There are dozens of books about Android application development published already, adding little value to what can be found in the official <a href="http://blog.codepainters.com/go/aospguide/">Android developer's guide</a>. On the other hand, no single book has been published until now (as far as I know) about porting and customizing the platform itself, making <a href="http://blog.codepainters.com/go/aosp/">AOSP site</a> and mailing lists the only sources of information. This situation is going to change with <a href="http://www.amazon.com/gp/product/1449308295/ref=as_li_ss_tl?ie=UTF8&#038;tag=codepainblog-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1449308295">Embedded Android: Porting, Extending, and Customizing</a><img src="http://www.assoc-amazon.com/e/ir?t=codepainblog-20&#038;l=as2&#038;o=1&#038;a=1449308295" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> by Karim Yaghmour coming from <a href="http://blog.codepainters.com/go/oreilly/">O'Reilly</a> in June.</p>
<p>The first four chapters of the book are <a href="http://blog.codepainters.com/go/oreillybook/">already available</a> directly from <a href="http://blog.codepainters.com/go/oreilly/">O'Reilly</a> (digital <a href="http://blog.codepainters.com/go/earlyrelease/">Early Release</a>). What's available now is already worth looking at, let me describe the contents briefly.<span id="more-827"></span></p>
<p>The first chapter, <em>Introduction</em>, gives a brief Android platform introduction (with some good background about how Android platform emerged) - it's fun to read, but nothing new to those interested in Android development. </p>
<p>The second chapter, titled <em>Internals Primer</em>, is where the book starts to shine. It gives a great overview of the whole platform, starting with a basic outline from the application developer perspective, then describing the platform architecture in more details - the motivation behind the Android's proprietary kernel modifications (wakelocks, binder, ashmem, etc.), general approach to hardware support (e.g. how the code is split between kernel space and C/Java user space code), filesystem layout, list of system daemons and services, etc. It's a kind of Android's missing architecture manual.</p>
<p>The third chapter, titled <em>AOSP Jumpstart</em>, is the first "hands-on" chapter of the book, giving all the information needed to download the AOSP source tree, prepare the build environment and eventually perform a basic build. Nothing very revelatory though, anyone who has ever tried to build a custom Android build should know it all already.</p>
<p>The fourth chapter, titled <em>The Build System</em>, is a great one, giving more detailed description of the Android's build system. It contains all the information necessary to add a new device, application, native library or daemon. Again, I'd expect such information to be available from AOSP site, but this book fills the gap perfectly.</p>
<p>The following chapters are going to describe the individual subsystems in more details. Even with only four chapters released so far I'd really recommend this book, as I believe the next ones will be as great, and I just can't wait for the final release!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/05/03/embedded-android-from-oreilly-is-coming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi has passed the EMC testing!</title>
		<link>http://blog.codepainters.com/2012/04/07/raspberry-pi-has-passed-the-emc-testing/</link>
		<comments>http://blog.codepainters.com/2012/04/07/raspberry-pi-has-passed-the-emc-testing/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 22:03:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Embedded]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[RaspberryPi]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=816</guid>
		<description><![CDATA[Eventually some good news about the so long awaited Raspberry Pi - it passed the EMC testing! The announcement also includes a funny story about Ethernet communication testing troubles, thanks to the hub being susceptible to the EM radiation Well, testing gets hard if you can't trust the tools&#8230; I hope that the boards assigned [...]]]></description>
				<content:encoded><![CDATA[<p>Eventually some good news about the so long awaited Raspberry Pi - it passed the EMC testing! The <a href="http://www.raspberrypi.org/archives/978">announcement</a> also includes a funny story about Ethernet communication testing troubles, thanks to the hub being susceptible to the EM radiation <img src='http://blog.codepainters.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Well, testing gets hard if you can't trust the tools&hellip;</p>
<p>I hope that the boards assigned to <a href="http://wiki.qt-project.org/QtonPi">Qt on Raspberry Pi</a> program will be available soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/04/07/raspberry-pi-has-passed-the-emc-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why RS232 uses negative voltage when idle?</title>
		<link>http://blog.codepainters.com/2012/03/29/why-rs232-uses-negative-voltage-when-idle/</link>
		<comments>http://blog.codepainters.com/2012/03/29/why-rs232-uses-negative-voltage-when-idle/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 22:43:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[rs232]]></category>

		<guid isPermaLink="false">http://blog.codepainters.com/?p=810</guid>
		<description><![CDATA[Have you ever asked yourself this question? I've found it answered in April issue (261) of Circuit Cellar, in Test Your EQ section. The answer is quite intriguing. First of all, DTL and TTL logic families were the most popular when RS232 was developed. In both DTL and TTL input current is significantly lower in [...]]]></description>
				<content:encoded><![CDATA[<p>Have you ever asked yourself this question? I've found it answered in April issue (261) of <a href="http://circuitcellar.com">Circuit Cellar</a>, in <em>Test Your EQ</em> section. The answer is quite intriguing. </p>
<p>First of all, DTL and TTL logic families were the most popular when RS232 was developed. In both DTL and TTL input current is significantly lower in the high state (a TTL input is equivalent to NPN transistor's emitter), so it makes perfect sense to use high state when idle to minimize the power consumption in the logic part.</p>
<p>The second part of the story is more funny. Why is high state represented by negative voltage on the line? This is because copper wires exposed to moisture are less likely to corrode if the voltage is negative. Indeed, it's the anode (positive electrode in electrolytic cell) where the oxidation happens. Beautiful explanation, isn't it?  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codepainters.com/2012/03/29/why-rs232-uses-negative-voltage-when-idle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
