tag:blogger.com,1999:blog-140948612008-06-15T11:16:45.396+01:00me->flubFloris Bruynooghenoreply@blogger.comBlogger105125tag:blogger.com,1999:blog-14094861.post-19361753008892528702008-06-14T23:51:00.005+01:002008-06-15T11:16:45.428+01:00Bluetooth on a Toshiba Tecra A9-127<p>I got a <a href="http://uk.computers.toshiba-europe.com/cgi-bin/ToshibaCSG/jsp/productPage.do?service=UK&PRODUCT_ID=137102&PRODUCT_ID=137102&toshibaShop=true">Toshiba Tecra A9-127</a>, listening to the model number of PTS52E-06002LEN as written on the back, from work to replace my dying old HP Compaq nx9030. As my laptop OS of choice is <a href="http://ubuntu.com">Ubuntu</a>, currently in it's Hardy release, it's not completely coincidence that the hardware is almost all <a href="http://intel.com">Intel</a> based since that's what <a href="http://video.google.com/videoplay?docid=7753780993269800999&hl=en">Matthew Garrett recommends</a>. And indeed, it all works effortlessly! Apart from bluetooth.</p>
<p>For bluetooth you need a tool called <a href="http://www.schwieters.org/toshset/"><tt>toshset</tt></a>. Once you have that you can enable the internal bluetooth device:</p>
<code><pre>
flub@signy:~$ sudo toshset -bluetooth on
bluetooth: attached
flub@signy:~$
</pre></code>
<p>And all of a sudden you'll have an hci device, probably <tt>hci0</tt>, check it with <tt>hciconfig -a</tt> if you fancy. Magic! It's just like plugging in a USB dongle...</p>
<p>Only toshset is not available for the amd64 flavour of hardy, only in the i386 version. No panic though, Debian has an up to date package (Ubuntu intrepid also has the right 1.73 version but doesn't build it for amd64 yet - <a href="https://bugs.launchpad.net/ubuntu/+source/toshset/+bug/240079">bug filled</a>).</p>
<code><pre>
$ dget http://the.earth.li/debian/pool/main/t/toshset/toshset_1.73-2.dsc
$ dpkg-source -x toshset_1.73-2.dsc
</pre></code>
<p>Don't quite rejoice yet, Debian seems to have changed from the <tt>pciutils-dev</tt> package to <tt>libpci-dev</tt>. So go and edit <tt>debian/control</tt> to build depend on <tt>pciutils-dev</tt> again. Then just build the package, install and enjoy.</p>
<p>Hopefully someone will now spend less time then me figuring this out...</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-31598813178203707792008-05-10T19:24:00.003+01:002008-05-10T19:41:26.978+01:00Ripping videos from DVD<p>Physical discs are a nuisance, I really just want to play what I want to watch in the room I want to watch it just streaming it over the wireless. This actually works wonderfully well. Unfortunately just copying the file structure of a DVD works and gives you DVD-quality video, but the size is huge and streaming this over the wireless tends to create some trouble (not to mention that every byte must also be encrypted/decrypted for ssh so this is getting CPU intensive too, ssh offloading onto hardware would be so cool). Hence the need to "rip" the DVD and encode it to some smaller format arises.</p>
<p>After spending a while looking at various options I finally found the great <a href="http://thoggen.net/">thoggen</a>.</p>
<p>Only problem left is how much to compress. After some very un-scientific tests (Google failed to find me any nice studies/graphs!) I decided on a quality of 35 and no resizing. But if anyone knows of a better study on what settings to prefer it would be greatly appreciated! It would be great to see quality vs file size vs frame size for different types of video. Ideally with a subjective "human quality" level too so you'd know what still looks good.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-16100003250588124072008-05-09T11:31:00.001+01:002008-05-09T11:33:20.011+01:00Discovery of the day<code><pre>
>>> def f(a, b):
... print 'a', a, 'b', b
...
>>> f(1, b=2)
a 1 b 2
>>> f(a=1, b=2)
a 1 b 2
>>> f(b=2, a=1)
a 1 b 2
>>>
</pre></code>
<p>Now I'm debating if I should really use that in production code...</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-68175471979773437192008-04-17T08:45:00.002+01:002008-04-17T08:48:08.715+01:00Time to read standards<p>Sometimes I like quotes out of context...</p>
<blockquote>
Anyway, I don't think it really is an ambiguity in practice -- only in the minds of those that have too much time to read standards documents.<br/>
-- Greg Ewing (on distutils-sig)
</blockquote>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-1404375381516944932008-04-11T20:49:00.002+01:002008-04-11T21:00:11.003+01:00@x.setter syntax in Python 2.5<p>The new <a href="http://docs.python.org/dev/whatsnew/2.6.html#other-language-changes">property.setter</a> syntax in Python 2.6 and 3.0 looks very clean to me. So I couldn't wait and wanted it in Python 2.5. With the help of comp.lang.python I finally got there (thanks especially to Arnaud Delobelle):</p>
<code><pre>
_property = property
class property(property):
def __init__(self, fget, *args, **kwargs):
self.__doc__ = fget.__doc__
super(property, self).__init__(fget, *args, **kwargs)
def setter(self, fset):
cls_ns = sys._getframe(1).f_locals
for k, v in cls_ns.iteritems():
if v == self:
propname = k
break
cls_ns[propname] = property(self.fget, fset,
self.fdel, self.__doc__)
return cls_ns[propname]
</pre></code>
<p>The <tt>__init__()</tt> wrapper is needed to get <tt>__doc__</tt> set properly (this surprised me). The whole <tt>cls_ns</tt> stuff and the loop are required since the properties are defined in C and their <tt>fset</tt> attribute is read-only. Which is why the entire property needs to be replaced. The implementation of <tt>deleter()</tt> can now be regarded as an exercise to the reader...</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-19642618224180349482008-04-11T20:42:00.002+01:002008-04-11T20:48:57.114+01:00(O)OXML and ISO voting processes<p>Many have recently complained about ISO's voting processes, mainly how they need to be revised as currently it seems it's possible to buy yourself a standard given enough lobbyist and money.</p>
<p>But part of this is ISO's trust in ECMA. ISO allows ECMA to submit standards for the fast-track process because it trusts it to approve good standards. If OXML (as it seems to be called now it's approved, formerly OOXML) was indeed such a bad standard (which I don't doubt personally) then ISO should maybe review it's relationship with ECMA too?</p>
<p>This is only a tiny part of the picture obviously, but one I haven't seem mentioned elsewhere.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-49729135154945896542008-04-10T13:57:00.002+01:002008-04-10T14:03:08.636+01:00Shell history<p>hehe</p>
<code><pre>
flub@signy:~$ history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn |head
79 nosetests
74 ls
46 cd
36 ssh
28 man
22 apt-cache
19 vi
19 ack
17 svn
17 sudo
flub@signy:~$
</pre></code>
<p>It must be noted that most of my editing happens in emacs, but that only gets started a few times a day and then stays there (oh and emacs is started from a shortcut icon, not the shell).</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-50540456218184559142008-04-06T13:36:00.002+01:002008-04-06T14:32:04.168+01:00nose and ipython<p>I wish there was a simple way to integrate nose and ipython. Something like a command line option <em>not</em> to catch exceptions would be sufficient I think, so that you could do:</p>
<code>
In [1]: %run tests/test_module.py --do-not-catch-exceptions
</code>
<p>Obviously you'd want a shorter option switch...</p>
<p>Seems like <tt>Test.run()</tt> in <tt>case.py</tt> is where this happens, but I tried changing that with no success.</p>
<p>And to be really useful I'd want the default behaviour of test selection in a module where <tt>if __name__ == '__main__': nose.main()</tt> is used to be just that module. But maybe that's already supported and I'm just not finding it.</p>
<p>Last random thought: Maybe if nose's -d option did expand dotted names I wouldn't be wishing for any of this. Who knows.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-3138866049418158902008-04-03T12:38:00.003+01:002008-04-03T12:47:27.249+01:00One s3fs to rule them all?<p>Sometimes I wish we could fast forward 6 or 12 months or so. Hopefully by then there will be just one <a href="http://google.com/search?q=s3fs">s3fs</a> that is mature and maintained. Right now it's hard to tell which one will turn out the best.</p>
<p>Interstingly, of the ones that look like they could have potential (trying to word it carefully here) two are written in <a href="http://python.org">Python</a> (all are using <a href="http://fuse.sourceforge.net/">fuse</a>).</p>
<ul>
<li><a href="http://code.google.com/p/s3fs/wiki/FuseOverAmazon">http://code.google.com/p/s3fs/wiki/FuseOverAmazon</a></li>
<li><a href="http://code.google.com/p/s3fs-fuse/">http://code.google.com/p/s3fs-fuse/</a></li>
<li><a href="https://fedorahosted.org/s3fs/">https://fedorahosted.org/s3fs/</a></li>
</ul>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-60911464208043208812008-03-28T23:42:00.003Z2008-03-28T23:44:42.368ZGPL and python modules<p>I should probably google this, but can't think of good keywords. So instead this is a "dear lazy web" post.</p>
<p>Is importing a python module considered linking for the GPL? I.e. are you allowed to import a python module into an script or module that has a non-GPL-comptible license?</p>
<p>Thanks!</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-31623436680168943832008-03-27T21:35:00.002Z2008-03-27T21:39:40.999ZCheating the KAME turtule<p>This is shocking. Even though I have not yet used IPv6 I can see the the KAME turtle dance! I won't give you a direct link but <a href="http://sixxs.net">SixXS</a> privde an IPv6->IPv4 service as well as an IPv4->IPv6 service. Feels bad having used the 4->6 bit...</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-88392450392110894802008-03-23T18:54:00.000Z2008-03-23T18:55:05.333ZOmniORB 4.1.1 in lenny!<p>Something that happened about a week ago I think. But omniORB 4.1.1 finally make it into Debian testing aka lenny! This means that python-omniorb 3.1, which has been waiting for a while now, also make it into lenny!</p>
<p>It has been stalled for ages since we had problems with the ARM port not managing to compile omniORB 4.1.X. Thanks to Thomas Girard for his work on this.</p>
<p>I've already committed the update to 4.1.2 to the <a href="http://svn.debian.org/wsvn/pkg-corba">svn repo</a>, omniORBpy 3.2 will follow soon...</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-19776066057427314792008-03-23T18:23:00.002Z2008-03-23T18:29:37.247ZCompiling libtool examples<p>This is more a reminder to myself, but here's how to compile the libtool examples:</p>
<code><pre>
$ cd demo
$ aclocal
$ libtoolize --automake
$ automake --add-missing
$ autoconf
$ ./configure
$ make
</pre></code>
<p>It's really how to bootstrap any GNU autotools using application I suppose.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-55999370988812224382008-02-29T00:33:00.002Z2008-02-29T00:37:06.624ZMy favourite package description<p>This sentence in a package description is always great...</p>
<blockquote>
You probably don't need it if you don't understand what this is all about.
</blockquote>
<p>Brought to you today by <a href="http://packages.debian.org/unstable/admin/nut-snmp">nut-snmp</a> but can be found in many other packages.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-88681755612108072792008-02-22T16:06:00.003Z2008-02-27T21:10:36.871ZAnother shell trick<p>Let's start with the solution instead of the problem:</p>
<code>
myvar=$(myfunc) <strong>|| exit $?</strong>
</code>
<p>Assuming <tt>myfunc</tt> is a function defined elsewhere in your shell script this will execute that function and assign it's output to <tt>myvar</tt>. However when <tt>myfunc</tt> fails, the entire assignment statement fails with the exit status of <tt>myfunc</tt>, so you exit with the same exit status by using <tt>|| exit $?</tt>.</p>
<p>It is really important to have this exit statment in there, even if <tt>myfunc</tt> already has it. You could look at the <tt>$(...)</tt> construct as a subshell, so the <tt>exit</tt> of <tt>myfunc</tt> only exits that subshell. This took me quite a while to figure out!</p>
<p>On a related note, you may know you can execute things in a subshell by using <tt>(<em>list</em>)</tt>. If you do that any variables etc won't affect your current shell. However variables and hence also functions from the parent shell are usable in the subshell. Handy (and maybe obvious).</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-26801014415075376942008-02-21T19:19:00.002Z2008-02-21T20:50:47.262ZCreating a Debian ARM build host<p>If you want/need to compile a program on ARM but are not lucky enough to have the hardware available <a href="http://fabrice.bellard.free.fr/qemu/">QEMU</a> can still help you. <a href="http://www.aurel32.net/">Aurélien Jarno</a> has an excellent description of <a href="http://www.aurel32.net/info/debian_arm_qemu.php">how to do this</a>. It is still valid today, even if you want to install <em>sid</em> instead of <em>etch</em>, first install <em>etch</em> then upgrade.</p>
<p>The only thing he omits is the need to start a getty on <tt>/dev/ttyAMA0</tt> when you use <tt>-nographics</tt> with a console on <tt>ttyAMA0</tt>. Other then that everything goes terribly smooth.</p>
<p>Apparently emulating ARM on a recent machine is supposed to be even faster then a real ARM. I have no idea if this is true, but I still find it slow... Makes me think twice about considering a Thecus N2100 or so as my home server.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-89468859563519231462008-02-16T00:12:00.002Z2008-02-16T00:26:00.647ZDocstring folding<p>In my <a href="http://bruynooghe.blogspot.com/2008/02/documenting-functionsmethodsclasses.html">last post</a> I had a little rant about how python docstrings visually separate the function/method/class definition from the body. Mikko Ohtamaa <a href="http://bruynooghe.blogspot.com/2008/02/documenting-functionsmethodsclasses.html#965692649921519000">raised a very good point</a> though: <em>the editor should fold it away</em>.</p>
<p>Since my editor of choice is <a href="http://www.gnu.org/software/emacs/">Emacs</a>, said to be more an operating system then an editor, this must be possible. But surely someone more intelligent then me must have implemented this already (for I still don't know lisp, shame on me)! So I read the <tt>python-mode</tt> description which mentioned something about support for <tt>outline-minor-mode</tt>. This lead me to play around a little with outline-mode. I'ts rather nice and seems to do useful folding, once I get used to it.</p>
<p>But I'm not sure I can figure out how to fold away just the docstring in outline-mode! There seems to be a "Hide Entry" function that most of the time does just hide the docstring when the cursor is located over it. But sometimes it will hide a few more lines too... Surely I must be missing something, anyone some hints?</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-28440326212410693922008-02-12T21:32:00.000Z2008-02-12T22:16:16.516ZDocumenting functions/methods/classes<p>There are several simple guidelines for writing functions or methods (guidelines that I like that is).</p>
<ul>
<li>Keep them clean, don't intersperse them with comments. If they require more then one or two inline comments it's too complicated and you should restructure.</li>
<li>Keep them short, it should fit on one screen. I'm flexible, a screen is an emacs buffer, not a vi in a terminal as <a href="http://lxr.linux.no/linux/Documentation/CodingStyle">Linus requires</a>.</li>
<li>Write a clear description at the top, explaining parameters, return values, exceptions etc whenever these things might not be blatingly obvious in a month's time. As soon as you explain one parameter you you should describe the whole lot though.</li>
</ul>
<p>In C this is quite nice, it looks like this:</p>
<code><pre>
/** Print an integer number
*
* The number is printed to stdout. Really that's
* all there is to it.
*
* param - The integer to print.
*/
void my_func(int param)
{
printf("This is an integer: %d", param);
}
</pre></code>
<p>While in Python this would look like this:</p>
<code><pre>
def my_func(param)
"""Print a number
The number is printed to stdout. Really that's
all there is to it.
param - The number to print.
"""
print "This is a number: %d" % param
</pre></code>
<p>While python code is generally very lovely readable this is something that annoys me about it. Suddenly my function definition is separated from the code by the docstring, often causing the definition and the code not to fit on one screen anymore (it is foolish IMHO to require the documentation <em>and</em> code to fit on one screen, given my documentation conventions).</p>
<p>While I understand every reason for the way things are and acknowledge that it probably won't ever change it still annoys me from time to time so I felt like moaning about it.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-91052919403892692422008-01-31T18:09:00.000Z2008-01-31T18:34:24.129ZParadox<p>Creating a <a href="http://facebook.com/">Facebook</a> group to complain about the <a hef="http://www.homeoffice.gov.uk/passports-and-immigration/id-cards/">UK ID cards</a> because:</p>
<blockquote>
[...]
An ID card would hold ALL personal information about you including biometrics, hospital records etc etc., a perfect target for ID thieves.
[...]
</blockquote>
<p>And you're doing this on <em>Facebook</em>?</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-54544464882252600682008-01-21T20:38:00.001Z2008-01-21T20:55:22.369ZMild improvement for movie industry<p>Until now every time I bought a DVD I found a few scary and angry leaflets in the box telling me how insanely bad I might be for buying pirated DVDs. They usually convince you that you are the worst person in the world for no particular reason. So just like I feel like I'm treated as a criminal when having to see trailers of the same genre at the cinema or have to take of my shoes at the airport, I hate having to open a DVD case and see those silly slogans.</p>
<p>Today however I opened a DVD case and instead got a nice and friendly looking leaflet (almost as relaxing as "Don't Panic" compared to the normal leaflets) congratulating me for buying a genuine DVD. I have to say I find it still disappointing that they feel like having to put in such a leaflet, but it's definitely more customer friendly this way: I don't get to feel bad.</p>
<p>If only now they would make them region free and not content scramble the disk (as I'm still about to break the law by watching my genuine DVD in a few minutes) I would actually start to believe they started listening to their customers.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-91830846488702345742008-01-06T20:36:00.000Z2008-01-06T21:31:52.795ZRock climbing in Costa Daurada<p>Just spent a long week sport climbing in Costa Daurada. We stayed in a house (with about 32 students and ex-students) near the village of <a href="http://en.wikipedia.org/wiki/Cornudella_de_Montsant">Cornudella de Montsant</a> which was an excellent location really close to Siurana and Arboli. Absolutely brilliant climbing and although my brain wanted to stay a lot longer my body seems quite glad to have some rest.</p>
<p>If you like sport climbing it is definitely a recommended place. Great times.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-66211205476466111022008-01-06T19:42:00.000Z2008-01-06T20:36:46.397ZUpdated omniORB in Debian<p>A while ago <a href="http://teejeejee.livejournal.com/">Thomas Girard</a> started the <a href="http://alioth.debian.org/projects/pkg-corba/">Debian CORBA Team</a> with the aim of maintaining omniORB and related packages in Debian. After a lot of work (and time!) we managed to get the packages of up to date versions in a good state fixing almost all bugs in Debian's BTS. And thanks to Thomas' hard work he managed to upload working packages of omniORB and omniORBpy (<tt>omniorb4</tt> and <tt>python-omniorb</tt> respectively) just before Christmas (I'm only blogging this now since I was on holiday since then).<p>
<p>The only issue is that they're only available in unstable and not yet in testing. There seems to be an issue with <tt>omniidl</tt> segfaulting on ARM. Unfortunately I haven't got an ARM platform available to debug on, Thomas however had already a quick look and it thinks it looks like a stack frame corruption. Hopefully we'll find this problem sooner rather then later, just frustrating that I can't really do much about it.</p>
<p>Lastly this means that if you where using the packages that I put up on <a hef="http://flub.suffwillmade.org/debian/">http://flub.stuffwillmade.org/debian/</a> a (long) while ago you shouldn't use them anymore, instead you should fetch the packages in Debian's sid.</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-69479297310966383112007-12-15T15:55:00.000Z2007-12-15T17:17:58.019ZSeeing your browser's headers using python<p>There's a very annoying website that won't send their CSS to my normal web browser (<a href="http://www.gnome.org/projects/epiphany/">epiphany</a>) which makes it rather ugly. However when I use <a href="http://www.geticeweasel.org/">iceweasel</a> the CSS gets applied. Since both browsers use exactly the same rendering engine, <a href="http://www.mozilla.org/newlayout/">gecko</a>, on my machine as far as I know, I thought they must sniff the headers sent by my browser. So I needed to check the headers, <a href="http://python.org/">Python</a> to the rescue:</p>
<code><pre>
import BaseHTTPServer
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write('<html><body><pre>')
self.wfile.write(self.headers)
self.wfile.write('</pre></body></html>')
return
def main():
try:
server = BaseHTTPServer.HTTPServer(('', 80), MyHandler)
print 'serving...'
server.serve_forever()
except KeyboardInterrupt:
print 'ttfn'
server.socket.close()
if __name__ == '__main__':
main()
</pre></code>
<p>Running this as root (80 is a privileged port) will show you the headers sent by your browser to the server. It's so simple that it took me longer to write this post then to write that code.</p>
<p>Only a pity that it didn't help me solve my problem...</p>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-52877364865413177112007-11-28T22:17:00.000Z2007-11-28T22:19:07.197ZSchneier: hammer, nail<blockquote><a href="http://www.schneier.com/blog/archives/2007/11/animal_rights_a.html">If you remember, this was sold to the public as essential for fighting terrorism. It's already being misused.</a></blockquote>Floris Bruynooghenoreply@blogger.comtag:blogger.com,1999:blog-14094861.post-31398399988847829692007-11-26T00:01:00.000Z2007-11-26T00:27:03.487ZMaking Debian packages on an SMP machine<p>When you have an SMP machine (including dual core CPUs - but I'm sure everyone knows that by now), you quickly learn to use the <tt>-jN</tt> flag to GNU <tt>make(1)</tt>. <tt>N</tt> is the number of CPUs you have and it lets <tt>make(1)</tt> run that many jobs in parallel whenever possible, thus using all your CPUs and giving you a nice speed benefit.</p>
<p>However when creating a Debian package you can't always specify this when you use a tool like <tt>dpkg-buildpackage(1)</tt>, <tt>debuild(1)</tt> or <tt>svn-buildpackage(1)</tt>. A simple trick is to just invoke these tools with the environment variable <tt>MAKE</tt> set to <tt>make -jN</tt>. Now whenever <tt>make(1)</tt> will invoke a sub-make, it will use the <tt>-jN</tt> parameter for it and since <tt>debian/rules</tt> is the first make invocation, all your actual compilation will always happen with multiple jobs in parallel.</p>
<p>This is not perfect however, all sub-makes will be called with <tt>-j</tt> too now, so you'll get more jobs then CPUs. I tried using <tt>MAKEFLAGS</tt> but that didn't quite work out, if someone knows of a better solution let me know. But this one works anyway.</p>Floris Bruynooghenoreply@blogger.com