CrossFit and Coding (and Meat)
In 2009 I achieved some significant things that weren’t on my list of goals, although they’re not concrete achievements in the same sense.
[more...]
In 2009 I achieved some significant things that weren’t on my list of goals, although they’re not concrete achievements in the same sense.
[more...]
Python Tips, Tricks, and Hacks at Siafoo is an excellent overview of useful Python knowledge. I was familiar with most of it but still think it’s worth reading over. I did learn a couple of new things, too.
[more...]
Earlier this evening Gever suggested a service dedicated to shortening URLs that had geolocation data in them. My immediate responses were that a) this was a great idea, and b) that I wanted the shortened URLs to still be human-readable in some sense—specifically, I wanted a person to be able to look at two URLs returned by this service and have some idea of how close to each other they were.
[more...]
This post details why they’re making the move. I find this of interest partly because it’s a move from a very popular web language (PHP) to one that’s become vastly more popular in the last couple of years (Python), and also because Django is the one major Python framework I haven’t tried out yet. Because of my liking for Python, I have a personal bias that makes me happy to see a prominent project such as this one move to the language.
I find it odd that they’re going from Subversion to git instead of to Mercurial, but I like the fact that they’re moving their documentation to the reStructuredText-based Sphinx.
Test-Driven Development (TDD) is a programming methodology that calls for programmers to first write tests that will only be passed by code that meets the specifications for whatever component they’re working on, and then to write the code for the component and keep working on it until it passes the tests.
I don’t tend to use Test-Driven Development, even though I often think I should. When working on personal projects, I don’t even write many tests after the code is done, and that’s something I should definitely do. But I generally regard it as a good practice.
[more...]
I never knew about this optional third parameter to list slices—in addition to e.g. getting the third to fifth items in a list with somelist[2:5], you can also get every nth item with somelist[::n].
This makes it very easy to get every odd or even item in a list, odd with somelist[::2] and even with somelist[1::2].
Where I think this is particularly handy is if you have to grab e.g. three-line chunks out of some text:
chunks = [] lines = text.split("\n") for i in range(0, len(lines))[::3]: chunk = [] chunk.append(lines[i]) chunk.append(lines[i+1]) chunk.append(lines[i+2]) chunks.append("\n".join(chunk))
It took me a while to get there, but I now have a working toolchain to automate going from an RTF file (or a Word document) to reStructuredText. The final link took the longest to find, and turned out to have been right there all along (no, I’m not going to turn this into a retelling of The Alchemist). But if you’re interested in how to get from Word to a sane format (like reStructuredText), this post will interest you.
[more...]
wpbeginner has a list of their favorite WordPress 404 pages. There are some good ones in there, but none of them do what I think they should do—that is, as well as provide helpful links to popular pages, also provide a list of guesses about where the user was actually trying to go. Coincidentally, today I also read this excellent article about finding the longest common subsequence between two strings. So, at some point, I’ll improve my blog’s 404 page so that it calls, probably via asynchronous request, a Python script that checks the user’s requested URL against all valid URLs WordPress knows about, and then suggests to the user whatever the closest matches are. I’m somewhat surprised that this isn’t done more often, but it seems that far too many sites are really blasé about 404s.
I find in my use of Subversion that I often want to see a side-by-side list of files that aren’t under version control and files that have some other status. I also want these lists to be sorted alphabetically. Naturally, I ended up writing a Python script for this.
[more...]
Last week I posted about my setup for going from reStructuredText to WordPress. It involved a shell script, some Python scripts, and the pbpaste and pbcopy commands. It worked, but it was a little on the convoluted side.
Now I have a slightly better process, and one that I will have used to publish this post.
[more...]
I tend to care about word count in my writing. I’ve never been paid by the word, but nevertheless, it matters to me. From time to time I write fiction where I set the word count in advance, and then I try to hit it precisely. Even when that’s not the case, I just like to know how many words there are in a piece I’m writing. For this reason, a "word count" function is completely critical to me for whatever word processor or text editor I’m using to write.
jEdit has such a feature. It’s more or less the same as the one that I’ve been using in AbiWord, and in various word processors before that. But for quite some time I’ve wanted a better word counter. Since jEdit is now my application for all writing and I can script for it in Python, it was time to make the word counter I wanted.
[more...]
jEdit has long been my text editor of choice, and I’m using it more than ever now that I’m writing more or less everything in it. I’ve been waiting a while for 4.3 to come out, but overall I remain quite happy with it. I do occasionally wonder about switching to vim or Emacs, but jEdit’s generally been able to do whatever I wanted it to.
I haven’t done much scripting with it, though. I recently came up with some use cases for scripts—involving reStructuredText, naturally—but I was a little reluctant to do the scripting because it involves Java and I really want to keep my current focus on Python and JavaScript.
I was therefore rather happy to discover the existence of the JythonInterpreter plugin, which makes it possible to write macros for jEdit in Python.
[more...]
While scripting my reStructuredText to WordPress workflow, I ran into a bunch of character encoding problems.
[more...]
I wrote about moving my writing over to reStructuredText on Sunday, and since then I’ve moved both my morning pages and my blog writing to it. The latter proved more complicated, primarily because I wanted to make the process almost as easy as writing pseudo-HTML (which is more or less WordPress’ native format, and kind of mine, too, for the last several years). With some hacky wrangling, I’ve managed to set that up.
[more...]
OS X has built-in functionality to rotate between different desktop backgrounds, but if you have multiple monitors and want backgrounds that fit together (i.e. that have two halves, one on each monitor), you need to set that manually. I wanted a script to do this for me, selecting a pair of backgrounds for each day. I wrote one in AppleScript, but was so unimpressed by it that I decided I’d do it over in Python.
[more...]
A couple of years ago I plugged star-light, a syntax highlighter that’s entirely client-side. I’ve been happy with it, but wanted a Python mode for it. I was going to post some other code this evening, and then decided that I should just make the Python mode myself.
This led to fun with regular expressions.
[more...]
I did some work on the PyWebSF site, so that it looks rather better than it did with the default WordPress theme. I altered a pretty good WordPress theme called Arras Theme, which I was fairly impressed with. As a reminder, the first meeting is tonight.
I’ve been using Pylons (and, more recently, the Pylons-based TurboGears 2.0) for various projects for a while, and a few weeks ago ran into an annoying and specific problem: using Pylons via Apache made Pylons occasionally think it was running on a different port.
There’s a relatively easy answer to this, but until I was reading through TurboGears documentation, I didn’t find it.
[more...]
My brother is organizing what will hopefully become a regular web-centric Python meeting. The first meeting is planned for 18:00 Tue 23 Jun 2009 at the SF Public Library. I think a couple of speakers are lined up already, although I don’t have details on the talks. I’ll be there, and if you’re a Python developer with web interests, or a web developer into or curious about Python, you should attend too!
I already have a buch of plans for larger projects, including finishing the sfmagic.org rewrite, but I think it makes sense to have some smaller projects to work on as well, things that I can switch to and make significant progress on in a relatively short amount of time.
[more...]
Sadly, I’m not quite going to finish a drop-in replacement for the current sfmagic.org codebase by my deadline of tomorrow. I’m close, and I think I have everything except the data entry portion, which I’ll lay out in this post.
[more...]
Unless I’m forgetting about something important, head-to-head is done.
[more...]
I haven’t had much time to work on the project over the weekend, but I have made some progress in getting the queries into SQLAlchemy form.
[more...]