<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7982849380034260862</id><updated>2011-04-22T04:02:25.436+08:00</updated><category term='fun'/><category term='blogger'/><category term='python'/><category term='NDS'/><category term='programming'/><title type='text'>Ars Pythonica</title><subtitle type='html'>Ingraining us in the Pythonic Way since 2009</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://arspythonica.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://arspythonica.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Waiz</name><uri>http://www.blogger.com/profile/15984244474052651241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_lpdI6U76ZbY/SaKadxb3DVI/AAAAAAAAAAM/IdWXg0dMFJA/S220/facepalm.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7982849380034260862.post-4172439852942968875</id><published>2009-03-18T20:32:00.007+08:00</published><updated>2009-03-19T17:30:04.895+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fun'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>One-liners</title><content type='html'>Python doesn't seem to be the language you'd immediately turn to if you wanted a one-liner to gazump your programmer buddies (well, at least it isn't for me), but can it be done? You betcha:
&lt;br&gt;
&lt;span class="center-caption"&gt;
&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.nishiohirokazu.org/blog/files/jankenoneliner.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 645px; height: 434px;" src="http://www.nishiohirokazu.org/blog/files/jankenoneliner.png" alt="" border="0" /&gt;&lt;/a&gt;
&lt;p style="text-align: center;"&gt;&lt;small&gt;Lambda hell.&lt;/small&gt;&lt;/p&gt;
&lt;/span&gt;&lt;br&gt;
No way am I going to type this out! Especially as &lt;a href="http://subtech.g.hatena.ne.jp/otsune/20060904/PythonOneliner"&gt;someone&lt;/a&gt; has already done this for us. :D

&lt;p&gt;&lt;span style="color:green"&gt;Edit: Forgot to mention &lt;a href="http://koichitamura.blogspot.com/2009/02/python-one-liner.html"&gt;who&lt;/a&gt; alerted me this monstrosity.&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7982849380034260862-4172439852942968875?l=arspythonica.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arspythonica.blogspot.com/feeds/4172439852942968875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arspythonica.blogspot.com/2009/03/one-liners.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/4172439852942968875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/4172439852942968875'/><link rel='alternate' type='text/html' href='http://arspythonica.blogspot.com/2009/03/one-liners.html' title='One-liners'/><author><name>Waiz</name><uri>http://www.blogger.com/profile/15984244474052651241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_lpdI6U76ZbY/SaKadxb3DVI/AAAAAAAAAAM/IdWXg0dMFJA/S220/facepalm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7982849380034260862.post-8858110647384659457</id><published>2009-03-04T18:21:00.006+08:00</published><updated>2009-03-04T18:54:27.566+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NDS'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>NDSTrim</title><content type='html'>Finally, a new post! Yay me, for drudging up enough silly stuff to write a post about!
&lt;br&gt;&lt;br&gt;
Seriously though, it has been a pretty hectic week (tests, exams, assignments, the usual) so it's a wonder that I have any time left over for blogging. Anyhoos, I thought I would post up something that didn't take too much time to make, and is at least a somewhat fun exercise in Python coding for myself.
&lt;br&gt;&lt;br&gt;
So, without further ado, let me present &lt;a href="http://sites.google.com/site/braindump2009/python/ndstrim.py?attredirects=0"&gt;&lt;span&gt;ndstrim.py&lt;/span&gt;&lt;/a&gt;! For those of you who like to back up their precious NDS games regularly, like I do, space is a consideration, especially if your collection runs into hundreds of games, like mine (I really do have a lot of games, don't ask). What this Python script does is trim your NDS backups (or ROMs) by a factor of up to 50%, depending on the actual size of the game itself.
&lt;br&gt;&lt;br&gt;
How can it save that much, you wonder? Well, considering some ROMs might be 70-80 MB, they'll decide to use 128MB ROM cartridges, with the remaining space doing precisely...nothing. The space can add up real quick!
&lt;br&gt;&lt;br&gt;
Anyway, the original C++ code was posted on a forum somewhere (I won't tell because I've forgotten where), and I simply took the liberty of translating it to the Bestest Programming Language in The World &lt;span style="font-size:78%;"&gt;TM&lt;/span&gt;&lt;span style="font-size:100%;"&gt;, because I can. If anyone reading this knows the original source of the code, please do tell me and so I can properly thank the guy. :)&lt;/span&gt;
&lt;br&gt;&lt;br&gt;
I might write up a GUI (with wxPython) if I feel up to it, so Windows aficionados can enjoy the fruits of my work too! If you're impatient for some GUI goodness, go &lt;a href="http://code.google.com/p/ndstrim/"&gt;here&lt;/a&gt; and get your fix.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7982849380034260862-8858110647384659457?l=arspythonica.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arspythonica.blogspot.com/feeds/8858110647384659457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arspythonica.blogspot.com/2009/03/ndstrim.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/8858110647384659457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/8858110647384659457'/><link rel='alternate' type='text/html' href='http://arspythonica.blogspot.com/2009/03/ndstrim.html' title='NDSTrim'/><author><name>Waiz</name><uri>http://www.blogger.com/profile/15984244474052651241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_lpdI6U76ZbY/SaKadxb3DVI/AAAAAAAAAAM/IdWXg0dMFJA/S220/facepalm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7982849380034260862.post-1574066017497104465</id><published>2009-02-24T18:49:00.015+08:00</published><updated>2009-03-18T20:45:03.820+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='blogger'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Source Code Highlighting in Blogger</title><content type='html'>&lt;p&gt;... is something Google don't have a good solution for right now and is a huge source of pain for me and a lot of other bloggers, judging by the &lt;a href="http://www.google.com/search?hl=en&amp;amp;q=source+code+highlighting+in+blogger&amp;amp;btnG=Google+Search&amp;amp;aq=f&amp;amp;oq="&gt;large&lt;/a&gt; quantity of posts related to the subject. Hopefully it's something Google can provide in the near future.
&lt;/p&gt;&lt;br&gt;
&lt;span class="center-caption"&gt;
&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lpdI6U76ZbY/SaPSPOVI-5I/AAAAAAAAAAw/_rk13c-p1P4/s1600-h/src.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 91px;" src="http://2.bp.blogspot.com/_lpdI6U76ZbY/SaPSPOVI-5I/AAAAAAAAAAw/_rk13c-p1P4/s320/src.png" alt="" id="BLOGGER_PHOTO_ID_5306315944959212434" border="0" /&gt;&lt;/a&gt;&lt;p style="text-align: center;"&gt;&lt;small&gt;Message for Blogger Labs&lt;/small&gt;.&lt;/p&gt;&lt;/span&gt;&lt;br&gt;
In the meantime, I'm using the solution posted by &lt;a href="http://blog.giladnaor.com/2009/02/source-code-highlighting-in-blogger.html"&gt;Gilad Naor&lt;/a&gt;, which uses the &lt;span style="font-weight: bold;"&gt;"&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;TOhtml&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;" feature found in &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Vim&lt;/span&gt;. It's not a bad solution, and I've found that putting "let html_use_css = 1" in your .vimrc tells Vim to output CSS (yeah baby!), which makes everything easier on the eye and more maintainable. &lt;p&gt;Huge thanks to Gilad for being the first person to alert me to the possibility of using everyone's favourite terminal editor in this way, and I would've posted to thank him, except &lt;a href="http://knownissues.blogspot.com/2009/02/word-verification-form-is-currently.html"&gt;Blogger's word verification isn't working&lt;/a&gt;. :(&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7982849380034260862-1574066017497104465?l=arspythonica.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arspythonica.blogspot.com/feeds/1574066017497104465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arspythonica.blogspot.com/2009/02/source-code-highlighting-in-blogger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/1574066017497104465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/1574066017497104465'/><link rel='alternate' type='text/html' href='http://arspythonica.blogspot.com/2009/02/source-code-highlighting-in-blogger.html' title='Source Code Highlighting in Blogger'/><author><name>Waiz</name><uri>http://www.blogger.com/profile/15984244474052651241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_lpdI6U76ZbY/SaKadxb3DVI/AAAAAAAAAAM/IdWXg0dMFJA/S220/facepalm.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_lpdI6U76ZbY/SaPSPOVI-5I/AAAAAAAAAAw/_rk13c-p1P4/s72-c/src.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7982849380034260862.post-4373642245305447325</id><published>2009-02-23T19:04:00.009+08:00</published><updated>2009-02-24T19:42:21.771+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>List Comprehensions</title><content type='html'>&lt;span class="fullpost"&gt;&lt;p style="margin-bottom: 0in;"&gt;I love them. They're just so &lt;b&gt;Pythonic&lt;/b&gt;.&lt;/p&gt;
&lt;p style="margin-bottom: 0in;"&gt;
What they do is provide you a succinct way to describe a list. You know, our favourite little squiggly snakes with [] at the ends. If you haven't the foggiest what a list comprehension is (and you'd be missing out on a lot of fun), here's a little example to get your juices flowing. Let's say, just for argument's sake, you want to represent the following mathematical expression in your program:&lt;/p&gt;&lt;pre&gt;M = {x| x in S and x odd}&lt;/pre&gt;&lt;p style="margin-bottom: 0in;"&gt;How would you do that in Java? You would likely go:&lt;/p&gt;&lt;pre&gt;ArrayList M = &lt;span class="Statement"&gt;new&lt;/span&gt; ArrayList();

&lt;span class="Statement"&gt;for&lt;/span&gt; (&lt;span class="Type"&gt;int&lt;/span&gt; x: S) {
  &lt;span class="Statement"&gt;if&lt;/span&gt; (x % &lt;span class="Constant"&gt;2&lt;/span&gt; == &lt;span class="Constant"&gt;1&lt;/span&gt;)
    M.add(x);
}
&lt;/pre&gt;&lt;p style="margin-bottom: 0in;"&gt;How utterly clumsy and unPythonic. In Python you'd just do this:&lt;/p&gt; &lt;pre&gt;M = [x &lt;span class="Statement"&gt;for&lt;/span&gt; x &lt;span class="Statement"&gt;in&lt;/span&gt; S &lt;span class="Statement"&gt;if&lt;/span&gt; x % 2 == 1]
&lt;/pre&gt;&lt;p style="margin-bottom: 0in;"&gt;So easily comprehensible that anyone not well-versed in Python's syntax could probably guess what it is doing, and very, very snug, spanning only one line! (Then again, snakes do have a reputation of having flexible bodies. ;) ) Doesn't it make you say, “If only [insert here your favourite language before you fell in love with the beauty that is Python]  had such awesome syntax?”&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;So next time you have the urge to create a list in your super-duper Python program (and the urge should be often), do it the &lt;span style="font-weight: bold;"&gt;Python&lt;/span&gt; way. Now, please excuse me while I go off to drool at all the posters of &lt;i&gt;Pythonidae&lt;/i&gt; in my bedroom ;).&lt;/p&gt; &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7982849380034260862-4373642245305447325?l=arspythonica.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arspythonica.blogspot.com/feeds/4373642245305447325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arspythonica.blogspot.com/2009/02/i-love-them.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/4373642245305447325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7982849380034260862/posts/default/4373642245305447325'/><link rel='alternate' type='text/html' href='http://arspythonica.blogspot.com/2009/02/i-love-them.html' title='List Comprehensions'/><author><name>Waiz</name><uri>http://www.blogger.com/profile/15984244474052651241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_lpdI6U76ZbY/SaKadxb3DVI/AAAAAAAAAAM/IdWXg0dMFJA/S220/facepalm.jpg'/></author><thr:total>0</thr:total></entry></feed>
