"Right, it's the _next_ bit of added code that will make the advantages of python of C more clear... "leaving the last 10 pics on the camera" or "watching a motion sensor and then triggering the camera" (although chdk might be more useful for that part, I'm still going to try this code, since I just got ahold of the same camera :-)"
- Mark Eichin
"I recommend commandlinefu.com for versions of that which actually *work*; `find -print0` and `xargs -0` are keys there, and if you *really* don't want context, `grep && echo` is just `grep -l`..."
- Mark Eichin
"Fuse is the wrong layer (device-opens don't go through it.) [fusd](http://www.circlemud.org/~jelson...) **is** the right layer, but hasn't been touched since 2003, apparently..."
- Mark Eichin
"The mention of matroska seems to come out of nowhere... _love_ the fonts, except that I'm not sure how to tell which ones I'm actually getting, even after reading the style tag..."
- Mark Eichin
_Mark_ on A logic gate simulator, inspired by Logicly. I plan to use this with my students later this term. Feedback welcome. - http://www.reddit.com/r...
"Have you considered adding [race detection](http://en.wikipedia.org/wiki...)? Something I did for a thesis project decades ago - if you have a minimum and maximum propagation delay for a gate, you can take your usual HI/LOW/UNDRIVEN and add EARLY_HI/EARLY_LOW - then any EARLY that doesn't make it to the actual state represents a race or "glitch" condition. Not sure if that's too high level for the course, but if you get as far as actually building circuits..."
- Mark Eichin
"True, but twisted.web is (or at least should be) a "gateway" app - HTTP is about the least subtle protocol out there, so you should be able to look at twisted.web and learn about just the twisted part, since you already "get" the HTTP part (and then apply what you've learned to something more interesting like twisted.words.) On top of that, [90% of everything is HTTP](http://en.wikipedia.org/wiki...) anyway..."
- Mark Eichin
"I think that's just the list of related functions; it affects the file descriptor itself. execve(2) talks about actually performing the close. The only trick with using it in python is that usually you have a `file()` or `socket.socket` object, and you want `.fileno()` to pass to `fcntl.fcntl`."
- Mark Eichin
"I suspect they'd have found it a lot faster using `lsof -i`, that's my first choice went hunting this (relatively common) problem... on the prevention side, `fcntl.FD_CLOEXEC` is useful..."
- Mark Eichin
"Indeed, and it surprises me that the other references only talk about the confusion; we teach it to people early because it's *useful* to have a near-equivalent of C's function-local "static" variables (though a memoizing decorator is better, it doesn't always fit the problem.) Also several of the comments talk about the argument being global - that's simply not true, it's not in the global namespace at all: def foo(bar=[]): bar.append(len(bar)) return bar print bar NameError: name 'bar' is not defined"
- Mark Eichin
"I found python (via QMtest) after years of guru level perl work (incl. pure-perl crypto, and writing for TPJ) and now the only reason I even look at perl is to translate it; while I've fixed bugs in ruby programs, it looks ("smells") far too much like perl for me to want to actually get deeper. (Also, the documentation bit mentioned here; I've actually used the Poignant Guide to convince people to look elsewhere...)"
- Mark Eichin
_Mark_ on My programming quotes file was well received when I posted it to reddit three years ago, here is a much updated and expanded version. - http://www.reddit.com/r...
"But it's a *C-specific* artifact; since statements are not expressions in python, all it does is confuse the reader, as the interpreter will raise `SyntaxError` if you try to use assignment where you meant equals..."
- Mark Eichin
"There are still positive things one can do, rather than merely seething, though; BITD (of expensive dot matrix printers) I was taught that you did *not* ask the user "is the power light on" - they'd answer yes. Instead you asked "what color is the light on the front" - they were less likely to read "what-did-you-screw-up" judgement into the question, and were thus less likely to try and give you the "right" answer, and would actually give you useful information..."
- Mark Eichin
"Oh hey, that worked (yay having the content hashes in the .torrent file...) I added two of them, now it's your turn (because the whole point of using the torrent is that I'm lazy and don't want to hammer on blip.tv myself) - stop your client, pick one of the zero-length entries at random, wget http://blip.tv/file/get/... the file (those names are the blip.tv download names...) and when that's done, restart the client, which should reverify and include your new content.)"
- Mark Eichin
"I only see 729M of content among the current peers. If these are the blip.tv flvs, I wonder if downloading them from there and stuffing them in would work..."
- Mark Eichin
"I used JetCet PDF on the G1 (during the free beta) - a little slow on zoom, and the UI is different from the standard Android UI in ways that make it look "wrong" - but it rendered some notably nasty pages (high-detail vector maps in particular) successfully. (I'll probably buy the real version next time I actually *want* to read a pdf on a tiny screen, but the G1 is too short on memory to casually leave large apps around (one of the few standard complaints you *didn't* include :-)"
- Mark Eichin
"Hmm, I was hoping it would mention http://bug.gd/ (while you can reference that in your product, people can use it *without* your involvement :-)"
- Mark Eichin
"Throw in an int status; and status = linkat(odir, ofile, ndir, nfile, AT_SYMLINK_FOLLOW); if (status) { perror("linkat failed"); } And: $ lsof -p 30878 | tail -1 tail 30878 eichin 3r REG 8,5 10 178919 /tmp/testfile1 (deleted) $ linkat /proc/30878/fd/3 /tmp/net_file2 linkat failed: No such file or directory and `/tmp/net_file2` is in fact not created. As I mentioned, I'm on intrepid with a 2.6.27 kernel -- what are *you* running?"
- Mark Eichin
"Really? I tried it (ubuntu intrepid, so 2.6.27) and just get `ENOENT` if the fd is on a deleted file. (Works perfectly if the file isn't yet deleted, but so does `ln $(readlink /proc/$pid/fd/3) /tmp/newfile`...)"
- Mark Eichin
"Ah, that's from 2001... that's why he doesn't mention [GCC-XML](http://www.gccxml.org/HTML...) which is designed pretty much exactly for this use case - leverage the "real" GCC C++ parser, and spit out XML to play with using "modern" tools. That said, the Roskind grammar isn't hard to work with, I added exceptions to it as a junior developer at HP/Apollo back in 1992 or so (as part of a C++-with-exceptions to C++-with-setjmp/longjmp translator, eww :-)"
- Mark Eichin
"As far as the code itself (rather than its teaching value) it discards excess argument without either processing them or complaining about their presence; also, no file-wide docstring (adding usage=__doc__ to the OptionParser constructor call would add named args and "magic" variables to the list too - again, perhaps too much for this stage, but I'd do it if it were "real" code...)"
- Mark Eichin
"> Think of edge cases and exceptional conditions, then think of how to test for them A complementary benefit of doing even casual TDD is that it can help you discover that there are cases you *don't* have to handle; I've had a few overwhelming-looking projects "collapse" when I started writing tests (which also serve as worked examples) and discovered that actual problem was much simpler than I'd imagined it. The tests really are a different perspective on the problem..."
- Mark Eichin
"Start doing more testing :-) (Not "this code does what I wrote" unit testing, but higher level "this application does something useful"...) (Though as suggested above, pexpect is nicer for that...)"
- Mark Eichin
_Mark_ on Ask Reddit: What do you use to orchestrate building a large C/C++ project? If the answer is autotools, what's a good tutorial? - http://reddit.com/r...
"If you use make, take a look at the [Recursive Make Consider Harmful](http://miller.emu.id.au/pmiller...) approach, where you store information locally around the tree but build globally. (Of course, my current large project goes in an entirely different direction - all modules are debian packages, and there's a higher level Jam-based package-set builder... but you probably don't want that :-)"
- Mark Eichin