Python

EmailsFromFile is a Python script that finds all email addresses in a file. It shows one email address per line by default, but you can pick your own separator (i.e. a comma or space) if you want.

The script is very simple; the magic lies in the email regular expression (based on the RFC 2822 standard) which is, quite frankly, one of the craziest I’ve seen:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

You can find more information about email regex here.

MIT Logo“MIT 6.00 — Introduction to Computer Science and Programming” is one of the best introductions to programming I’ve seen, and I guess I shouldn’t expect less from the Massachusetts Institute of Technology. 24 video recordings of Computer Science lectures (totalling roughly 20 hours) by Professors Eric Grimson and John Guttag, current and former heads of Electrical Engineering and Computer Science at MIT. The course focuses on, quite simply, teaching you how to think like a programmer and solve problems computationally. Historically, LISP was the language of choice for Computer Science introductions at MIT, but was since replaced by every imperative programmer’s new darling, Python.

To quote the overview given in the first video, the course revolves around:

  • Computational thinking
  • Understanding code
  • Understanding abilities and limits
  • Mapping problems into computation

I highly recommend watching this if you’re new to programming, a hobby programmer, or even if you’re pretty well-versed — I’m sure there are nuggets of useful information inthere for everyone. Give Lecture 1 a look; if you like it, I’ve embedded the entire course after the jump, but it can also be found on the official course website, along with assignments, exams and solutions.

Lecture 1: Goals of the course; what is computation; introduction to data types, operators, and variables

[click to continue…]

My first exposure to computer programming was back when I was about 10. Some cool boys at school were playing a fantasy game with each other, all in text. They called it a “MUD“, one of the oldest genres of computer games. I grew curious and it didn’t take long before I was sat at home, emerged in textual worlds rather than the typical graphical games like Quake and Counter-Strike, both of which were wildly popular back then.

Briefly about MUDs: If you’ve never heard of or played MUDs, I strongly encourage you to give them a try. They may not have graphics, but that is exactly what gives them power. They’re like books — if you have a decent imagination, you don’t need graphics. In fact, I’d play a MUD over a game with crappy graphics any day. MUDs are also incredibly educational — if I hadn’t played MUDs, I wouldn’t be speaking nor writing English nearly as well as I do today (I’m not a native speaker), and I probably wouldn’t know much about programming either.

After a while I decided I wanted to create my own game. I downloaded a C codebase and started hacking away at the source, experimenting and learning the basics of programming (I was completely clueless before MUDs). Creating something out of nothing was no longer a fantasy, I was actually doing it.

Eventually, my little project evolved into more than just a spare-time thing and was serving a couple thousand players, admittedly not simultaneously but I was still quite impressed, and I had learned many a valuable lesson about everything from love to programming.

I took the plunge into the world of programming without reading any books on the subject. I am a person who learns best from practice, so it wasn’t all that bad. I bent, I broke and I played with the code and eventually I learned all about functions, pointers, memory management, and all the other fun feats of C. The only downside to this was that I was not learning contemporary programming languages and methods. Until recently, that has been the single biggest reason why I haven’t recommended that anyone interested in programming start out by trying to create their own MUD. MUD codebases are old… Well, most of them, anyway.

NakedMud

NakedMud is a modern MUD codebase whose core is still in the good old C, but everything else is accomplished using Python as an embedded scripting language. Don’t let C discourage you — if you want, you can leave the core alone, do everything in Python and only make the small, necessary changes in C. Python is incredibly easy to learn, and games are much more fun to work with than traditional learning tools, right? Could it be any better? Besides, as soon as you’re comfortable with Python, modifying C will be painless, too.

Geoff Hollis, the creator of NakedMud, describes the codebase as a clean and easy way to create your own MUD, without all the usual hassle that other codebases bring — and that’s exactly what it is. NakedMud’s source is beautifully clear and concise in comparison to other codebases, making it a perfect tool for those who want to create their own game for the first time, and have no clue how to do it from scratch. If you want to create your own game, really, use it.

What now?

I won’t go into details about NakedMud as Geoff has literally written books about it. If any of this has even remotely tickled your curiosity, I will, however, end this off by strongly recommending that you learn more on your own. Here’s a few links to get you started:

The source of the MUD I created, Shattered Dreams MUD (SDMUD), can be found here. As you can probably imagine from what I said about it being my first, it isn’t a masterpiece. If anything, studying the source of it will make you realize what makes NakedMud better than the other, old, mainstream codebases.