Snippets
July 22, 2008
The notebook, to me, is an idea, an all-encompassing repository for my quirky consciousness as it winds its way forever upriver. It’s a continuously evolving incubator, inherently messy, fragmented, idiosyncratic, loquacious, forgetful, quixotic, and occasionally (okay, often) full of half-witted and badly expressed notions.
the most elegant answer to the problem is the simplest one that meets all of the necessary constraints, and is implemented in a readable manner.
Plagiarism
July 5, 2008
Yes, stealing from Wikipedia is still plagiarism. Apparently Stacy Conradt of mental_floss finds it too difficult to include a link to her source material. In this post she posted a sampling of events from this Wikipedia page, and she didn’t even bother to paraphrase them all.
The mental_floss blog is worthless entertainment, but that doesn’t excuse this sort of thing.
I wonder if she’ll cop to it or change the post or ignore this (I posted a comment pointing out the issue).
Last Day of the Month
June 15, 2008
When a blog has never been visited my dissertation software retrieves any posts from the past 24 hours. This isn’t hard:
from datetime import datetime lastvisit = datetime.utcnow().replace(day=(datetime.utcnow().day-1))
But when this happens and it’s the first day of the month you get:
ValueError: day is out of range for month
Since my project is only going to run for this summer, I did changed it so that it will work this year but not next year (sorry, WordPress strips out all of the tabs…):
from datetime import datetime
n = datetime.utcnow()
if n.day != 1:
lastvisit = datetime.utcnow().replace(day=(datetime.utcnow().day-1))
elif n.month - 1 in (1, 3, 5, 7, 8, 10, 12):
lastvisit = datetime.utcnow().replace(month=(n.month-1), day=31)
elif n.month - 1 in (4, 6, 9, 11):
lastvisit = datetime.utcnow().replace(month=(n.month-1), day=30)
elif n.month - 1 == 2:
try:
lastvisit = datetime.utcnow().replace(month=(n.month-1), day=29)
except ValueError:
lastvisit = datetime.utcnow().replace(month=(n.month-1), day=2
Today I ran across this article on ASPN. And now here’s what I would write (omitting some of the boilerplate from above):
if n.day == 1:
days_in_month = [calendar.monthrange(year,month)[1] for year in [n.year] for month in range(1,13)]
datetime.utcnow().replace(day=days_in_month[n.month-2], month=n.month-1)
elif:
datetime.utcnow().replace(day=n.day-1)
If I would have spent 5 minutes looking for The Right WayTM to do this, I would have saved a little time and had cleaner code. Now I don’t want to change what I’ve got working well enough.
Dear Lazyweb: How do I post pretty code snippets?
Random Data
June 15, 2008
In the last 3 and a bit days my software has gathered over 125,288 posts from 96,000 blogs. 37,594 blogs have at least one post from that period.
Below’s a crappy table ripped right from the mysql console. The first column is the total number of posts and the second column is the number of sites that have the corresponding number of posts.
+—————–+—————–+
| number of posts | number of sites |
+—————–+—————–+
| 100 | 1 |
| 89 | 1 |
| 87 | 1 |
| 83 | 1 |
| 79 | 2 |
| 75 | 12 |
| 74 | 1 |
| 72 | 1 |
| 70 | 1 |
| 69 | 1 |
| 68 | 3 |
| 66 | 1 |
| 65 | 3 |
| 63 | 3 |
| 62 | 2 |
| 61 | 1 |
| 60 | 3 |
| 59 | 2 |
| 58 | 4 |
| 57 | 1 |
| 56 | 2 |
| 55 | 2 |
| 54 | 2 |
| 53 | 4 |
| 52 | 8 |
| 51 | 2 |
| 50 | 2 |
| 49 | 3 |
| 48 | 6 |
| 47 | 4 |
| 46 | 2 |
| 45 | 3 |
| 44 | 4 |
| 43 | 8 |
| 42 | 9 |
| 41 | 8 |
| 40 | 10 |
| 39 | 5 |
| 38 | 7 |
| 37 | 10 |
| 36 | 10 |
| 35 | 12 |
| 34 | 7 |
| 33 | 7 |
| 32 | 12 |
| 31 | 9 |
| 30 | 16 |
| 29 | 19 |
| 28 | 16 |
| 27 | 32 |
| 26 | 27 |
| 25 | 43 |
| 24 | 28 |
| 23 | 45 |
| 22 | 45 |
| 21 | 49 |
| 20 | 66 |
| 19 | 69 |
| 18 | 78 |
| 17 | 71 |
| 16 | 116 |
| 15 | 106 |
| 14 | 140 |
| 13 | 166 |
| 12 | 184 |
| 11 | 259 |
| 10 | 312 |
| 9 | 410 |
| 8 | 548 |
| 7 | 791 |
| 6 | 1093 |
| 5 | 1699 |
| 4 | 2959 |
| 3 | 5139 |
| 2 | 8170 |
| 1 | 14695 |
+—————–+—————–+
Gin, Fire and Boobies
June 13, 2008
I’d bet Clay Shirky would probably call MMORPGs one of the many “gins” of our era. I’d agree. But that’s not going to deter me from giving Age of Conan a try when I get home in September.
Scott Jennings convinced me in his post about how you can set stuff on fire. And I mean lots of stuff.
I can’t wait to play with fire (and boobies) come September!
Dark Secrets of Programming
June 9, 2008
Via Coding Horror:
Programming is all about knowing when to boil the orange sponge donkey across the phillipines with an orangutang gorilla crossed with a ham sandwich to the fourth power of twelve across the nile with an awful headache from the previous night when all of alfred’s naughty jalapeno peppers frog-marched the nordic elves across the loom-lined geronimo induced swamp donkey over and above the fortran fortified kilomanjaro fence past the meticulously crafted anti disgusting sponge cake scenario where all the hats doth quoteth the milk which is not unlike the super werewolf from the infinite realm of ninja-step. it’s hard to define, really.
I always knew it was all about donkeys and things made of sponges.
But seriously, comments are good. I sometimes think bloggers should promote the best comments up to replace the original post.
Why I Don’t Blog More
June 5, 2008
Wanna know why?
Because every time I want to write I have to log into this big flashy website, when all I want to post is a little text and a few links. I don’t need tags. I don’t need categories. I don’t need previews. I don’t need rich editors and statistics.
Me and My Blog
May 27, 2008
The rigor and candor and general sense of exploration I enjoy in other blogs is absent from what I post. I just don’t feel strongly enough about blogging, and I’m not willing to devote enough time to blogging to write posts at a level I’m proud of.
I originally intended this blog to house some of my craziest, most radical ideas. The failure is totally on me, but my big external discouragement is that I’ve tried posting some of my middle of the road ideas and received alarmed messages from those who don’t get what this blog is supposed to be about.
So from now on this blog will be darker than it already is. I might occassionally post some drivel, or I might start posting anonymously elsewhere. Who knows.
Daily Stupid
April 18, 2008
I was posting a comment on GigaOm a minute ago, and I used a line-initial double-dash. For some reason WordPress interpreted this as “please insert a series of spaces here,” so instead of getting “– Mr. Ludd” I got “ Mr. Ludd”.
Such magic is annoying.
If a form I submit for display is going to be reinterpreted in some way, I want to know in advance.
Genius
April 15, 2008
I watched a few videos today on YouTube. I noticed they’ve started putting advertisements at the top of the right-hand column. After training us for years to look at that spot to see general information about the video, it’s now an advertisement. I’m sure most people are still habitually looking at that spot, which is wonderful for advertisers.