How advertising ruined the rickroll

I’m currently teaching a class called Who owns you? In this class students take a critical look at the apps we use on a daily basis, and they can learn to build their own simple apps if they want. To lighten things up, I’ve been starting each class with a computer-related joke – Why did the mosquito fly away from the computer? It didn’t want to get caught in the World Wide Web! Students love it, and the jokes often lead to meaningful critical and technical conversations.

Today I tried to go a step further and rickroll my entire class. I set up a document with the following text showing:

Today’s joke: (scroll to see the joke)

Then below the visible screen:

Why did the chicken cross the road? (scroll to see the answer)

And a little further down:

It worked – most of the students had never been rickrolled, and I got to sit back and watch them enjoy their first exposure to Rick Astley. In many ways, it was my most successful rickroll to date.

But in one significant way, the experience was utterly disappointing. When the student unknowingly clicked the link with all of us watching, a 30-second youtube ad started playing. Students are so used to ads that it didn’t ruin the rickroll – they were still caught off guard, and they still laughed and started dancing when they realized they’d been had. But the joke didn’t have nearly the same impact it would have had the video started playing instantly.

This led to a great discussion about the impact of online advertising. Students talked about the kinds of ads they like, and the kinds of ads that just get in the way of meaningful online experiences. Students recognize the need to fund online services; they know developers need to be paid, and they know that servers don’t run themselves. But most of us felt that anyone who cares about quality online experiences would never place an ad at the beginning of a Rick Astley video.

We didn’t stick to just advertising in today’s conversation; the rickroll is much more interesting than that. We also talked about what links meant in the original text-only internet, and how commerce helped and hurt the overall development of the internet.

It’s a great class. I just wish we could sort out online advertising well enough that today’s generation can enjoy the full experience of the rickroll.

Posted in education | Leave a comment

Ever’s First Starship

Ever has made many small ships, but this is his first larger ship that has a nice degree of symmetry, that he’d like to be able to build again. We decided to take it apart step by step, and take a picture of each step. I’ll do a more consistent job of photographing the steps next time, but I think this will serve as a functional set of instructions.

The Finished Ship



resized021 resized022


Building the Ship




resized069 resized068

resized067 resized066 resized065

resized064 resized063 resized062 resized061 resized060

resized059 resized058 resized057 resized056 resized055 resized054 resized053 resized052 resized051 resized050

resized049 resized048 resized047 resized046 resized045 resized044 resized043 resized042resized039 resized038 resized037 resized036 resized035 resized034 resized033 resized031 resized030 resized029 resized028 resized027 resized026 resized025

All done!

Posted in family | Leave a comment

The CyberConstitution Class

Each fall I teach an Introduction to Programming class, and it’s always fascinating to see the connections students make as they experience their first real exposure to programming. Today I introduced the concept of classes, and we ended up in one of the most engaging conversations I’ve had with students in a while. Instead of drawing from my own experience to make up an example during the lesson, I asked students the following question:

If you had infinite programming skills, what would you build?

It’s a question I like to ask from time to time, and I’m really glad I asked it again today. I gave students a couple minutes to jot their answers on notecards, then asked a few students to share what they had come up with. After discussing a couple ideas I asked if anyone wanted us to use their idea as an example. One student raised her hand, and here’s what she had written:

I would write a cyber constitution for America that would have a solid set of laws, but wouldn’t limit freedom of speech.

I told her it was a great example because we can easily identify some kinds of information that should be stored in an electronic constitution, and we can also identify some actions you’d want to take when working with an electronic constitution. Here’s the class we developed during the lesson:

class CyberConstitution():
    """A solid set of laws, that doesn't limit speech."""
    def __init__(self):
        """Initialize the constitution."""
        self.state = '' = ''
        self.preamble = ''
        self.laws = []
    def add_law(self, new_law):
        """Add the new law to the list of existing laws."""
    def show_laws(self):
        """Show all the laws in the constitution."""
        for law in self.laws:
    def show_constitution(self):
        """Show the entire constitution."""
        print("This is the cyber constitution for the state of " +
            self.state.title() + ".\n\n")
        print("Authored by: " +
        print("\n\nOur constitution contains the following laws:\n")

I had no idea how compelling this example would turn out to be. Right away, a number of questions came up:

  • “How many constitutions are there?” (51 in the US alone, and ours was one of the most recently written. Many students had no idea each state has its own constitution.)
  • “Are there laws in a constitution, or are they called something else?”
  • “What’s a preamble? What would we say in a preamble?”

I asked what laws students would put in a constitution, and recorded their responses in code:

# Make a constitution.
my_constitution = CyberConstitution()

# Set the attributes (information) for the constitution.
my_constitution.state = 'alaska' = 'sr'
    'All internet users must be licensed to access the internet')
    'Marijuana possession, manufacture, etc. is legal in this state.')
    'Gas prices will always be less than $2.00 per gallon.')
    'Everyone will have access to a free, ' +
    'high-quality, invidualized education.')
# Show the constitution.

Here’s the output:

This is the cyber constitution for the state of Alaska.

Authored by: sr

Our constitution contains the following laws:

All internet users must be licensed to access the internet.
Marijuana possession, manufacture, etc. is legal in this state.
Gas prices will always be less than $2.00 per gallon.
Everyone will have access to a free, high-quality, invidualized education.

It helps to read these suggestions with an understanding of what high school students might be thinking about on a typical morning. The first suggestion comes from students who have watched their peers be bullied to the point of physical violence, and watched people’s lives be significantly affected by the negative impacts of social media. The second comes from students watching many non-violent people in their lives face all kinds of legal issues for marijuana violations, while many better-connected people around them get away with the same behaviors. The third suggestion comes from students who struggle to pay for gas with their high-school level jobs. The last one was my contribution.

These are great issues to discuss, and they place programming in a much-needed context. It’s not really about the code you write, it’s about what problems you might be able to address if you stay interested in programming. It’s about knowing what can be done with code, event if you don’t stay with programming.

After the lesson students went back to work on their own programming exercises. Most of them are not using classes yet, so no one expanded on the CyberConstitution class today. But they went away with a better understanding of how programmers can build tools that re-engage people in the fundamental question of how we might build the kind of society we want to live in. What more could we want for students in an Introduction to Programming class?

If you’re a programmer, you can play around with CyberConstitution on github.

Posted in education, programming | Tagged , , , | 1 Comment

Processing a long list efficiently in Python

This post was inspired by Brandon Rhodes‘ excellent talk at Pycon 2014,  All Your Ducks In A Row: Data Structures in the Standard Library and Beyond.

Python’s lists are dynamic.  You do not need to declare their length ahead of time, and you can add to them at any time. How does Python manage memory for a list when it doesn’t know how long your list is going to be? It allocates a little extra room at the end of the list, in case you end up adding some more items. Most of the time this makes your list operations fast, but it can catch you off-guard if you don’t think through some operations carefully.

Consider an example where you want to work through a long list, popping items until the list is empty:

numbers = [x for x in range(0, 100000)]

while len(numbers) > 0:
    number = numbers.pop()
    print number

This code makes a simple list of 100,000 numbers. It then removes the numbers one at a time from the end of the list, and prints each number as it is removed. When I time this program on my computer, it takes roughly 1.3 seconds.

Now let’s try the exact same program, except each item will be popped from the beginning of the list instead of the end of the list:

numbers = [x for x in range(0, 100000)]

while len(numbers) > 0:
    number = numbers.pop(0)
    print number

This program takes twice as long! The difference is even more significant if you use a longer list.

Why does it take so long? Python is constantly moving all of the items in the list, since lists are more optimized for adjustments at the end of the list than they are at the beginning.

An efficient solution

How can you do this more efficiently? Since the goal is to work through each item from the beginning of the list, you can reverse the list before popping its items. Then you can pop from the end of the list, which is efficient, and still work through items in the order you intended to:

numbers = [x for x in range(0, 100000)]

while len(numbers) > 0:
    number = numbers.pop()
    print number

The reverse() operation takes a negligible amount of time to run, so this version takes rougly 1.3 seconds again.

The takeaway? If you are looking at performance issues, understanding how Python manages memory can be really helpful in making optimizations.

Posted in programming | Tagged , , , | 3 Comments

The education community needs a better online discussion tool

The Educator News homepage.

The Educator News homepage.

I just finished building Educator News, and I’d like to explain a bit about why I built the site. It’s an early draft of what I want it to be, but the basic functionality is there. If you would like to see a beter online conversation about education taking place, take a look and share your feedback.

I have wanted to find an education-focused site that has these criteria:

  • Good submissions. Good submissions are articles that offer some specific insights about how to do education well. Good submissions offer specific critiques of certain issues in education. Artilces may be political in nature, but good submissions avoid anything to do with simply spreading FUD.
  • Good comments. Good comments contribute to a constructive conversation about education. Good comments respond to specific points in the article being discussed, and to other points people are raising. Like good submissions, good comments avoid spreading FUD. And of course, good comments are respectful of other people even in the midst of heated disagreement.
  • Good community. A discussion site needs a healthy, active community in order to be interesting. People need to submit thought-provoking and informative articles, and read some of the submissions that others share. People need to encourage positive submissions and commenting behavior, and respectfully but decisively address poor submissions and poor commenting behavior.

I have never found a strong education-focused news and discussion site online. The sites I have found all suffer from some significant drawbacks – they are not very active; they are active, but there is not much substance to the discussion; they are active, but they only focus on one aspect of education.

A clear set of guidelines is critical for building a strong community.

A clear set of guidelines is critical for building a strong community.

What does Educator News offer that should make it a strong community? I believe EN has the right structures to create a better online conversation about education:

  • An upvoting system for submissions. Upvote the submissions that add to the conversation, and ignore the sumissions that distract from a meaningful conversation. If people do this consistently, the front page will be full of meaningful submissions and free of low-quality submissions.
  • A flagging system for submissions. If a submission is pure spam, or otherwise completely inappropriate, you can flag the submission. Flagged submissions will be reviewed, and can be set invisible by moderators.
  • A system for ignoring bad domains. When some domains are identified as consistently being a source of inappropriate or low-quality submissions, these domains can be ignored. The community will no longer need to manage submissions from these domains individually.
  • A system for upvoting comments. Everyone who registers on Educator News can upvote comments. Upvoting is not about agreeing with a comment; it is more about encouraging well-written, thoughtful responses.
  • Downvoting comments is a privilege. When users gain enough experience on Educator News, they can then help downvote non-constructive comments. There is a clear set of guidelines for what kinds of comments we want to avoid. This includes abusive and offensive comments, but it also includes vague comments such as “I agree!” and “Me too!” These kinds of comments tend to clutter up online discussions.
  • A system for flagging comments, and ignoring users. If a comment is abusive, seriously offensive, or way off-topic, the comment can be flagged instead of downvoted. Flagged comments are reviewed, and these comments can be ignored. When a comment is ignored, it becomes invisible to everyone else on the site. If a user consistently makes inappropriate comments, their entire account can be made invisible to everyone else.

Not an echo chamber

There is a bit of a danger, when building a new community, of creating an echo chamber for your own ideas. Educator News is not an echo chamber. When I built EN, I put aside all of my opinions on what makes good education except for one: I want people to disucss the substance of ideas that relate to education. I put aside my own political beliefs about education, and simply focus on helping to facilitate meaningful, evidence-based conversation. It’s the same thing I do on a daily basis when guiding conversations between students in my classroom.

If you’d like to help build a high-quality conversation about education, please join us at Educator News!

Note: Educator News is modeled after Hacker News, which I have learned a great deal from over the last few years. For the technically-minded, EN is a fully open project, and you can see the Github repo if you are interested. It’s ugly MVP code for now, but I am steadily cleaning it up. Feel free to open an issue.

Posted in education | Tagged , , | Leave a comment

Ninety Days on Github

90 days on Github

90 days on Github

Ninety days ago, I unknowingly started my first real Github streak. I didn’t really decide to start a streak until I was about 17 days in, but since then I’ve been very conscious to keep it going. I’ve thought about ending the streak a few times recently, but it’s still more of a benefit than a burden. There are a number of things I’ve noticed as the streak has started to be measured in months instead of days:

  • Contributing at a minimally meaningful level is becoming routine; it’s just part of my day now.
  • I’m aware of the length of the streak, but these days it’s more of a habit I want to keep than a number I’m trying to chase.
  • Contributing on a daily basis keeps me from losing sight of the long-term goals of my projects. This makes it much easier to work more intensively on my projects when I get a window of time.
  • Someone reached out to become involved in one of my projects ( I’m starting to mentor this person, which is very rewarding and motivating.
  • I find myself getting more involved in an active, highly professional mailing list (IPython-dev). It is inspiring to have meaningful conversations, and even some collaboration, with such focused and talented people.

I had two satisfying milestones during the last 30 days. I finally converted a Basemap tutorial from an old blog format to the new project I am working on. It’s the first project for, and I’ve already received some positive feedback about the tutorial. It was a fair bit of work to make the original tutorial, and it feels much better to have it hosted in a collaborative project rather than on my personal blog. I am more confident it can be kept up to date, and not die a rather quick death of outdated installation instructions, and broken links to government data sets.

Highlighting lines of code that have been added or modified in a tutorial.

Highlighting lines of code that have been added or modified in a tutorial.

I also made a quick and dirty method for highlighting single lines of code in the IPython Notebooks I am using to make I feel this kind of highlighting is essential for making good tutorials and learning resources. I’m sure there is a more elegant way to implement this kind of highlighting, but I was at least able to bring a bit of functionality into IPython that I needed to make an effective final product.

Maintaining a longer streak feels a little forced and artificial at times, but overall it is keeping me connected to some important projects and some inspiring people. I’m going to aim for another 30 days, and I still have a satisfying sense of wonder about where these next 30 days will lead.

Posted in programming | Tagged , , , , , , | Leave a comment

Github streak days 31-60: What I’ve learned


My current GitHub contributions graph

About two months ago I started writing some lessons for an Introduction to Programming class I was about to teach. I was using IPython Notebook to write those lessons, so I decided to put the notebooks on GitHub. I worked on the project pretty steadily, and soon passed my old GitHub record of 17 days. From then on, watching those little green boxes pile up got more and more addictive. Is it worthwhile to maintain a streak? I don’t want to keep it going forever, but it has definitely been worthwhile so far.

Introduction to Python - the main project I've been working on, as it looks now.

Introduction to Python – the main project I’ve been working on, as it looks now.

My main project at this point is Introduction to Python. Introduction to Python is an open resource for students who want to learn Python as their first language, and for teachers who want a free and open curriculum to use with their students. The project is growing steadily, both in terms of content and in terms of features that help students learn Python efficiently.

Improving my git workflow: branching

Introduction to Python, as it looked a month ago.

Introduction to Python, as it looked a month ago.

I have been a hobbyist programmer most of my life, which means I have worked mostly alone on my projects. When I started using git a few years ago, I began the bad habit of pushing all of my commits to master. This habit was great for starting a GitHub streak; it was easy to make a few commits each day, and some days I got to see some really dark green boxes show up. But as my project started to grow and attract some potential contributors, I started to feel really self-conscious about having such a cluttered master branch.

All output is collapsed by default, so readers can try to predict what the output should be.

All output is collapsed by default, so readers can try to predict what the output should be.

I knew about branches before, but had not practiced using them enough to make them part of my regular workflow. This streak has me using git every day, so it became harder and harder to put off using branches. Most of my commits involve adding content about how Python works, so many of these commits are quite appropriate to push directly to master, especially at this early stage. But one goal was to make the output of all sample code hidden by default, with a pair of show/ hide buttons below the sample code. This is a great learning feature; it allows students to predict the output of a code sample they are looking at, and then click a button to see if their prediction was correct. I am not a front-end guru, but I can find my way around js libraries and css hacks. Some of my commits while working on this feature would make no sense in master; they put buttons on the screen that didn’t do anything yet, and they put buttons on pages that had no output. So I did all this work on a feature branch, and then merged that to master. It was very satisfying to become more comfortable with a workflow I know will work well on a truly collaborative project.

A few other things I learned

I learned about a number of other things through pushing commits each day, and did some things I would not otherwise have gotten to:

  • I started writing some of my non-programming curriculum on IPython Notebook, so that I could share it easily with students. I would like to learn to use a Python static site generator such as hyde, pelican, jinja, or nikola, but I didn’t have time to dig into that this month. There’s so much that can be done just using IPython Notebook markdown cells!
  • I pushed the content on Introduction to Programming through making basic terminal applications. Now anyone who follows the curriculum starting at Hello World can learn to write simple terminal applications.
  • I feel more and more connected to the programming world outside my small town in Alaska, where my students are the only people I know who write any code.
  • I started writing tests! I wrote a test to verify that all links in this project are working. The default behavior is to start a SimpleHTTPServer and test the local working copy, but it accepts a flag to test all links on the deployed site. It does not yet test anchor tags, but just being sure that all links between pages and to external sites are not broken makes me more confident in the project overall. I also got to use Requests, which makes me feel like a Real Python Programmer.
  • I found that I am much more likely to keep a project going. I started a really cool version of a text-based Adventure game, which starts out with the player standing on the front steps of our high school. Students and staff loved the first day’s progress. In the past I would have copied this to my computer and maybe done something with it. Instead I just threw it up on GitHub, and I have worked on it a couple times since then. The simple act of using GitHub every day makes it easy to keep interesting, nascent projects alive.
  • I used Bootstrap 3.0, which I’ve been wanting to use in a project.

What’s next?

I’m going to try to keep this streak going a while longer, as long as it is keeping me productive and improving my professionalism in programming. In the next 30 days, I’d like to:

  • Keep using branches. This is a no-brainer, for everything except content that should go directly into the project.
  • Consider using pull requests. I know some people don’t merge any of their own branches, they submit all branches as pull requests, even if they are simply going to accept their own PR. I want to do this just to be more comfortable with the process of submitting and accepting PRs.
  • Keep adding content to Introduction to Python.
    • Finish the basic sections through Functions, Classes, Exceptions, and Testing.
    • Complete the first project, a mapping visualization using matplotlib Basemap.
    • Add more content around how to write programs. You’ve managed to learn a bunch of syntax, but how do you think through a project’s requirements and figure out how to  start writing code?
    • Clarify the section about setting up a programming environment: how to install linux on a donated computer, how to troubleshoot non-functioning Python environments, how to find help, etc.
  • Do some non-github work. I have one non-open project that I need to make significant progress on. It’s hard to work on closed projects when you’ve been immersed in the open source world, but I have a pretty meaningful project to work on. I aim to balance the two, instead of focusing so much on just the open source work.
Posted in programming | Tagged , , , , , , , | Leave a comment