Sign in or Join FriendFeed
FriendFeed is the easiest way to share online. Learn more »

Mark Eichin › Comments

Mark Eichin
_Mark_ on When ctypes comes to the rescue - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Thinkpad Turtle: You can drive the little turtle by turning your laptop - http://www.reddit.com/r...
"Here's the rest of it; needed an axis-reversal too... #!/usr/bin/python # linux version of http://code.activestate.com/recipes... # (via reddit) but drop the windll stuff import time import turtle import sys hdaps_file = "/sys/devices/platform/hdaps/position" def current_pos(): """Get current position from the file""" pos = file(hdaps_file).read().strip().strip("()") return map(int, pos.split(",")) def getXY(): raw_x, raw_y = current_pos() return raw_x / 10.0, raw_y / 10.0 def done(_x, _y): print "done!" turtle.bye() sys.exit() def main(): centerx, centery = getXY() turtle.pensize(3) turtle.onscreenclick(done) while 1: x, y = getXY() turtle.left(centerx-x) turtle.forward(centery-y) time.sleep(0.01) if __name__ == '__main__': main()" - Mark Eichin
Mark Eichin
_Mark_ on Thinkpad Turtle: You can drive the little turtle by turning your laptop - http://www.reddit.com/r...
"On ubuntu karmic: sudo m-a a-i tp-smapi sudo modprobe hdaps cat /sys/devices/platform/hdaps/position (-419,-498) (so, replace getXY with something that opens and parses that...)" - Mark Eichin
Mark Eichin
_Mark_ on Perl has ack, Ruby has rak, and now Python has grin (a grep replacement for programmers) - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Is it possible to write a Python app with a device file api? - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Video on the Web - Dive Into HTML5 - http://www.reddit.com/r...
"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 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
Mark Eichin
_Mark_ on Open Source Is Really About Documentation – Twisted vs. Tornado - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on The mystery of immortal, migrating sockets and Python's getstatusoutput. - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on The mystery of immortal, migrating sockets and Python's getstatusoutput. - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Least astonishment in python: the mutable default argument - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on What is wrong with ruby? - http://www.reddit.com/r...
"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 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...
"Chris Maden - probably http://crism.maden.org/ -- according to *my* quotes file, dated 2005 (TFA only has a vague attribution)" - Mark Eichin
Mark Eichin
_Mark_ on Start your Python project with optparse and logging - 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
Mark Eichin
_Mark_ on Trust No One - To be a good problem solver you have to be untrusting - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on The First Few Milliseconds of an HTTPS Connection - http://www.reddit.com/r...
"Isn't that what http://en.wikipedia.org/wiki... is for?" - Mark Eichin
Mark Eichin
_Mark_ on PyCon 2009 Videos - http://www.reddit.com/r...
"Got it up to 93%, one of the files seems missing from blip.tv, so we've got close to full coverage even without any seeds..." - Mark Eichin
Mark Eichin
_Mark_ on PyCon 2009 Videos - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on PyCon 2009 Videos - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Android 1.5 will, among other things, support upload from phone to Youtube - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Report a Bug - The feature all products should have - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on How to undelete any open, deleted file in linux. - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Why does gets() exist? - http://www.reddit.com/r...
"And it wasn't until the Morris Worm (1988) that a lot of programmers found out the hard way that it didn't stop at BUFSIZ either..." - Mark Eichin
Mark Eichin
_Mark_ on How to undelete any open, deleted file in linux. - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on Parsing C++ - http://www.reddit.com/r...
"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
Mark Eichin
_Mark_ on [Dive Into Python 3] Please critique this code that I'm considering using for chapters 2-4 - http://reddit.com/r...
"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
Mark Eichin
_Mark_ on Motivating Minds (The Economist on why TDD makes you work harder) - http://reddit.com/r...
"> 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
Mark Eichin
_Mark_ on One of the coolest Unix tools I've discovered in some time: Expect - http://reddit.com/r...
"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 Eichin
_Mark_ on The Year 2038 Problem - http://reddit.com/r...
"Didn't the BSDs switch to 64 bit time_t years ago (even on 32-bit systems?) Solaris likewise?" - Mark Eichin
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
Other ways to read this feed:Feed readerFacebook