logo: drawing of an eevee lounging atop the website

fuzzy notepad

Blog

Page 19
Atom feed

[articles] Python FAQ: Equality

Part of my Python FAQ.

What does is do? Should I use is or ==?

[articles] On principle

Alice shows some code to Bob. Something about it catches Bob’s eye; he tells her that some mechanism is a bad idea and she should find another approach. She asks why.

Bob, despite being absolutely correct, can’t answer.

Or maybe he can, but is worse off nonetheless: for every pitfall or potential consequence he dreams up, Alice fires back with how she’ll compensate or why it doesn’t apply in this case. Eventually Bob runs out of ideas, and Alice carries on with what she’s doing, now feeling more vindicated—she’s fought for her work and won, after all.

Bob is arguing from principle, and Alice is scoffing at the idea of principle for its own sake. Principles are for academics; out here in the real world, whatever gets the job done is good enough.

Right?

[articles] tmux is sweet as heck

People occasionally ask me why tmux is significantly better than screen, and I end up mumbling the first few things that come to mind. This has yet to sway anyone. Here, then, are some things that I enjoy about using tmux.

First, some terminology, so the rest of this makes any sense at all.

  • tmux and screen, if you were not aware, are multiplexers—they let you run multiple terminals (or terminal programs) at the same time, switch between them, and disconnect or close your terminal without killing everything you were running. If you didn’t know this then you should probably stop now and poke around tmux’s site or something.
  • A session is a particular group of terminals owned by tmux (or screen). When you run tmux bare, you get a new session.
  • A window is a numbered terminal inside a session.
  • A pane is each compartment within a split window. (I lied above; a window might actually have several panes and thus several terminals. But a window is identified by one number.)
  • An xterm is a single GUI terminal window (or tab). You may be using another terminal emulator, or you may be in a non-GUI virtual terminal; I’m using “xterm” as an umbrella term for all of these.

I’m also assuming that ^A is your multiplexer trigger key, although tmux defaults to the more awkward ^B.

Works out of the box

Here’s my .screenrc, fiddled by hand over the course of many months after I started using screen.

1caption always "%{= kw}%?%-Lw%?%{Kw}%n*%f %t%?(%u)%?%{kw}%?%+Lw%? %=%{= dw} %H "
2
3# terminfo and termcap for nice 256 color terminal
4# allow bold colors - necessary for some reason
5attrcolor b ".I"
6# tell screen how to set colors. AB = background, AF=foreground
7termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
8# erase background with current bg color
9defbce "on"

What the fuck is any of this? The only real configuration here is the first line, which sets a fairly simple status bar. The rest is unreadable sludge picked off of Google to make terminals inside screen work the same way as terminals outside it. I see this as a serious failing in the one core feature that defines a multiplexer: being invisible.

Some of this might not be necessary any more; maybe termcaps have been improved in the meantime. Part of the very problem is that I can’t know; the best I can do is delete bits of it and see if screen still behaves correctly, assuming I remember all the quirks I was trying to fix in the first place. It’s 2012. I shouldn’t ever see the word “termcap”.

Contrast with tmux, which just worked. The only terminal-related fudging I ever had to do was set my $TERM to xterm-256color for it to respect 256-color sequences. Not entirely unreasonable.

tmux can also inherit parts of the environment when it’s detected a change; by default it looks for some common X and SSH stuff. The upshot of this is that your SSH agent continues to work across SSH connections; the new environment only applies to newly-created windows, but zero hacks are necessary.

By default as of tmux 1.6 (I think), when you create a new window, it’ll get the same current working directory as the current window.

[updates] Once more, with feeling

Let’s try this again.

Blogofile was a cool experiment, but unfortunately it’s been effectively abandoned. It’s not bad, but it has a lot of warts that add friction to blogging, and I need all the non-friction I can get.

So this is powered by Octopress. It’s a Ruby thing wrapped around Jekyll, which I guess is GitHub’s wiki engine or something, and I strongly suspect that Blogofile took a lot of inspiration from it.

It’s still the same basic idea: static generation, Markdown, templates, Disqus, etc. But it’s a bit more fully-featured from the get-go, has some shortcuts that make it harder for me to avoid writing thoughts down, and does the deployment for me.

This default theme ain’t bad, either. Rather not have the exact same blog as dozens of other nerds, but it’s a start.

[personal] Eevee has gained 1801 experience points…

Eevee grew to level 25!

Ho jeez what have I even done this year.

[articles] FUCK PASSWORDS

I’m so tired of passwords. So, so, so tired.

Most people don’t understand this. Most people use the same password everywhere. Most people can just mechanically type out password3 in every password box, smirking to themselves at how clever they are, because who would ever guess 3 instead of 1?

I don’t do that. Let me tell you what i do.

I generate a different password for every service, based on a convoluted master password and the name of the thing. I do this because it’s what you’re supposed to do; it’s what security nerds (including myself for the purposes of this post) tell everyone else to do. “Ho ho!” we all chuckled to ourselves after the Gawker leak, and the subsequent breakins to various other things that used the same passwords. “If only these chumps had been generating different random passwords for every service!”

So my passwords look like 'fC`29ap5w78r3IJ, or Ab3HE4 2Iv5hJk\K, or mw@\_h<~o04neHiJ{. Those are actual examples i just generated. I’m eating my own dogfood, so to speak.

It’s not without its drawbacks.

[articles] In which i use GitHub, and IRC is awesome

I just wasted way too much time migrating all of my git repositories to GitHub. It’s way less janky than the old thing, and the guys running it seem to be acceptably hipster-nerdy.

I’m still using Redmine as a bug tracker, and i have a cron going that updates the old repositories regularly, so commits will still appear in tickets and whatnot. This is just a change of canon.

I am considering giving GitHub Issues a shot for small new projects, just to get a feel for it. Redmine is powerful but feels like it’s targeted at my manager. GitHub is, i must admit, very much targeted at the people on the ground doing the hacking.

Anyway, here is a story.

[articles] Google postdecrement

It’s reasonably well-known by now that, if you don’t have a Google+ name that looks sufficiently white and Anglo-Saxon, they’ll suspend your account and require photo ID.

This raises a couple questions that i don’t think have gotten adequate attention.

[articles] informative title

Hello here is what’s going on.

[articles] GNOME 3 revisited

How did I write this? I don’t know what happened. I was just jotting down notes and prose came out.

I wrote a whole thing about Shell and Unity before, but it was kinda knee-jerk ranting. With my newfound blog fame, here’s a lame attempt at a more constructive list of specific criticisms of GNOME 3, now that I’ve actually used it for a while on my laptop.

[articles] Python FAQ

I lurk in #python. It gets a lot of questions that are, shall we say, frequently asked. This is my attempt to catalogue interesting and useful questions. The answers will gradually become separate posts—perhaps on other blogs if someone else gets to them first. Let me know if there should be other questions, if the answers are unclear, or the answers have bugs in them!

[articles] Perls of Wisdom

Ha, ha! A hilarious and original pun.

I’ve had several conversations now about Perl 5’s level of deadness and Perl 6’s level of disastrousness. So here is a followup, which surely won’t get as much attention because it’s not as potentially inflammatory.

[articles] Pyramid traversal: almost useful

Pyramid is, to skip a lot of history, a successor to Pylons. It’s a Web framework for Python. (And there goes half my audience.) This post is about dispatch: mapping URLs to the code you want to run. (There goes the other half.)

[articles] Redmine vs GitHub

I’m currently hosting a small pile of projects on a combination of self-hosted gitweb and self-hosted Redmine. I keep glancing meaningfully in the direction of GitHub; it’s code-oriented, it has wiki support, it has an issue tracker, and it can do simple site hosting via some contrived abuse of git. So why am I bothering to host my own stuff? There are actually a few reasons, thus I need the Internet to decide for me.

[articles] How to drive your new project into irrelevance

Here’s a question that should be really easy to answer: what is Diaspora?

Okay, well, I know what Diaspora is. It’s an attempt to make a decentralized social networking service. But my knowledge ends around there. What kinds of things does it share? What useful functionality does it provide for me? How does its concept of identity work? And the million dollar question, how does the decentralized bit actually work? Do I show up as eevee@diaspora.com on other sites, or do I auto-get a local account, or do I manually sign in with OpenID, or is there a central registration server, or do nodes sync their account lists… or what?

[articles] Something is wrong with American culture

Today, the Supreme Court ruled that the California law prohibiting the sale of violent video games to minors is unconstitutional, violating the First and Fourteenth Amendments. The idea here is that the government can’t prevent a group of people from being exposed to media they want to see; freedom of expression goes both ways.

Unless, of course, you are expressing boobs. For some reason, while any arbitrary level of cruelty and gore is Constitutionally protected, any level of human sexuality is not. Justice Breyer pointed this out:

But what sense does it make to forbid selling to a 13-year-old boy a magazine with an image of a nude woman, while protecting a sale to that 13­year-old of an interactive video game in which he actively, but virtually, binds and gags the woman, then tortures and kills her?

Of course, he’s actually arguing that both violence and sexuality should be off-limits to children. But the question is still a good one, underscoring the long-standing American conflict of loving violence while underscoring sexuality with shame. It need not be said, but I remind you that sexuality creates life, whereas violence destroys it. These are some funny priorities we have.

I know this has been said before. I’m not done yet.

[articles] Python needs more software

Consider this a companion article.

I love Python. It’s healthy and thriving and attracts a lot of clever people. It has its warts, but they’re mostly manageable.

Unfortunately, it still strikes me as a bit invisible. I haven’t really been able to articulate why, but after reading a bunch of those Perl blogs that bring up CPAN, I think it might actually be the software.

For example: there’s no good Python forum software. I’m sure there are some bits and pieces here and there, but nothing that’s attractive, feature-rich, and easy to deploy. That last one is a bitch, I know, but it’s important. Right now, if I want to throw up a forum, my viable options are really phpBB, vBulletin, and some other crappy PHP things. I think MyBB might be Perl, but who even uses that?