Using Emacs - Setting up the Package Manager

This video will step you through setting up Emacs to use MELPA for packages.

We configured emacs by creating a folder named .emacs.d and creating a file within it named init.el.

Here's the contents of that file:

(setq inhibit-startup-message t)

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
	     '("melpa" . ""))


;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
	(package-install 'use-package))

(use-package try
	:ensure t)

(use-package which-key
	:ensure t 

The last two inituse-package clauses install two helpful packages:

  • try: let's you try packages without installing them.
  • which-key: brings up help on key combinations.

Relavent links:

Using Emacs - Introduction

I'm sure I've mentioned that I've been an Emacs wonk for decades. Since the mid-80's in fact. I've spent time using other editors, word processors, and development tools but always find my way back.

I recommend that budding computer science students develop a good tool set and encourage them to explore Emacs but while it's pretty easy to load Emacs and find your way around, particularly if you use the mouse and menus there isn't a clear path to take you from beginner to using it as an efficient tool let alone customizing it.

Inspired by Mattias Petter Johansson, or MPJ who make a weekly video, I decided to try to create a series of YouTube videos and matching blog posts. I'll try to post one a week and I'll try to keep the videos, at least after the first couple to just a few minutes and have them focus on micro-habits - one or two small things that you can bring to your work flow and internalize.

The first three four (this one and the next three) will focus on setting things up. After this post we'll have

  • Setting up the package manager
  • Intro to org-mode (just so that you recognize the markup)
  • Intro to Elisp (just so you have an idea of those configuration lines)

and then we're off to the races. Here's what I'm thinking about for the first few topics after the above mentioned ones:

  • Efficient Navigation
  • Windows and Buffers
  • Theming
  • Auto Completion

and then a series of short topics to show some of my favorite editing tools. We'll also cover some larger topics including:

  • Python Development
  • C/C++ Development
  • Document Preparation
  • Scheduling / Calendaring / Note Taking

I'll put together an index to these posts along with any ancillary materials here:

Getting started

This series is going to assume you've installed emacs and worked your way through the included tutorial.

To help you get to that point, here are some links to posts and sites that I've found useful:

And here's a 10 minute getting started guide:

So, stay tuned.

Collaborative Coding or Cheating

I haven't been teaching this past semester. That's why I haven't been writing much about lessons. I miss working with students but that will resume in the fall and this semester has allowed me to get a jump on new projects.

It's also allowed me to look at some student issues from a bit of a distance.

One issue that keeps coming up is cheating.

Some of it, classroom cheating. my friend Ria recently asked a question on Facebook about it. A nice thread ensued but unfortunately, it's locked in the Facebook silo. I've got a lot to say on that and hope to explore it soon but today let's focus on project cheating - something that could just as easily apply to homeworks and student essays and research papers as well.

One part of the question is on students using code they find out in the wild. Alfred wrote a bit about it on his blog here where he points out some pluses, some minuses, and raises some good thought points.

I want to keep it in the class - code sharing amongst students, project and source code submission, and group projects.

Teachers have all sorts of options these days including:

  • Using a CMS like Blackboard or Moodle
  • Dropbox based solutions
  • Emailing projects
  • Using development tools and sites such as git with GitHub, BitBucket or other repository hosting services

I've always been a fan of having the kids learn real software engineering skills along with the CS so Git, GitHub and public repos have been my weapon of choice.

Interesting enough, I've gotten an earful both from fellow teachers and professors and online for my stance on public repos.

I keep hearing "the kids will copy from each other" or something like that.

As Alfred said in his post: "Students have been copying from classmates for years."

Students who want to copy assignments have done so long before we've been teaching CS and they'll be doing it for years to come.

Using a hidden submission system doesn't help and could hurt.

Far better to create an open environment. You get an opportunity to talk about code sharing, attribution, learning from each other, supporting each other, and where to draw the line.

On top of that, the students learn a real tool set and have a chance to learn real development methodologies.

It's a win all around.

Will open repos stop cheating and irresponsible copying? Certainly not. It could, however, raise awareness.

So what do I do on the cheating front?

Besides trying to create a culture where cheating is discouraged, cooperation is encouraged but where students know the line, I will try to keep them honest.

Frequently, the day a big project is due, I'll give a quiz on the project. Students will have to describe parts of the project and what they did. Either a student will have had to contributed or at least will have had to have studied the rest of the teams code to pass the quiz.

GitHub also gives tools that help.

Here's the GitHub graph for a project:


You can see who did what and when. The teacher can drill down further to examine the diffs – what code did each student write, when, and from where. If two students submit very similar code, the commit timestamps will even tell you who was first.

The tooling for teachers could be better but the infrastructure is there.

Technology isn't going to prevent cheating and more often than not, it seems that measures taken don't stop the bad guys but inconvenience those trying to do it right.

Much better to build a class culture where the kids want to do it the right way.

Shell short - tagging old posts in Nikola

Quick post to add to the recent command line fu I've been writing about.

Douglas Peterson had another Whatever happened to post. This time on Logo. I wanted to reply, talk about NetLogo and link to some of my old NetLogo posts to help show how cool it is.

Nikola supports tags, makes a nice tags page and for each tag, a nice page of all the links.

Nikola has a plugin tags which lets you manage tags from the command line. For instance:

nikola tags -a netlogo posts/

Would add the tag netlogo to the specified post.

The problem: The tags plugin only works if the post has a tag: line already present in it's header comment and I hadn't put them in my older posts.

I had a bunch of posts, all of them in one directory. All the new ones were .org files and had the tag slug. The others were .md markdown files and .html html files.

Here's what a typical top block looks like:

.. title: Looking for interesting questions
.. slug: 2010-01-03-looking-for-interesting-questions.html
.. date: 2010-01-03
.. type: text

Sed to the rescue. Here's the what I ended up typing (from within the posts directory) to add the tags slug to the top comments right above the .. type: text: line:

ls *md *html | while read filename
    sed "/type: text/ i .. tags: " $filename

A line at a time:

ls *md *html

This lists all the files with that end in md or html

| while read filename

The vertical bar (pipe) sends the output of ls into the while read command. The while command sets up a loop which, each time through, reads the next input and places into the variable filename. The body of the loop is between the do and the done.

sed "/ type: text/ i .. tags: " $filename

Sed is the stream editor. The stuff between the slashes finds the line with the text type: text in it. The i inserts a line above and the rest of the stuff in the quotes is what to insert. The $filename expands to each filename, one each time through the loop.

Now all of my files have blank tag slugs so I can find my netlogo posts and tag them:

nikola tags -a netlogo `grep -i -l netlogo posts/*`

Any command in backticks expands to the result of the commmand. The grep command has two argiments: -i means ignore case so it will find netlogo, NetLogo, NETLOGO, etc.. The -l tells grep to just output the filenames. So, the grep command will expand to a list of files that mention netlogo. The full command adds the netlogo tag to all of them.

So, just a bit of quick shell scripting and I've:

  • modified all old posts to accept tags.
  • added the netlogo tag to all my netlogo posts.

You can find all those posts here.

REPOST - Shell games - who confirmed attendance


This is a repost from March 2015. It didn't transfer when I rebooted the blog.


Quick post on why I love the Unix command line.

We're busy organizing CSTUY's first hackathon. It's going to be at SumAll, where we hold our weekly hacking sessions but while taking registration, we had a little program.

The kids signed up on a Google doc but we all know the story – when people sign up for a free event, even one with free food and t-shirts, many don't show. I asked all of the applicants to confirm by filling out a second Google doc.

Then it got to reminder time - I wanted to send an email out to all those kids who signed up on the first form, but hadn't confirmed on the second.

Two Google spreadsheets with an email field. I needed all the people on sheet 1 that weren't on sheet 2. I'm sure there's some spreadsheet-fu that accomplishes this, but nothing I know. I also could have written a little python script which isn't so bad, but this was a perfect time to turn to the shell.

So, here's how a command line guy would do this.

To start, I put the emails in two files: e1 and e2. The first has all the original applicants, the second those that confirmed.

e1   e2    

If we put these lists together, any email that appears twice would indicate that it's the email of someone that confirmed entry. Here we use cat to catenate e1 and e2 and pipe them through sort.

cat e1 e2 | sort 

First problem –the upper case F – let's use tr to make everything lower case:

cat e1 e2 |  tr A-Z a-z | sort

Now we can see the duplicates next to each other. Next, uniq -c tells us how many times each line appears:

cat e1 e2 | tr A-Z a-z | sort | uniq -c | sort

I added the sort at the end, but we didn't need it.

Here's what we get:

 1 c@c.dom

To pull out the ones that haven't replied I used egrep with a regex that means "any line that starts with 1 or more spaces followed by the number 1":

cat e1 e2 | tr A-z a-z | sort | uniq -c | egrep "^ +1"

and finally to isolate the emails using sed which removes the spaces and number 1 from the beginning of the line:

cat e1 e2 | tr A-z a-z | sort | uniq -c | egrep "^ +1" | sed "s/\ \+1 //g"

Each of the little utilities aren't all too useful by themselves but if you learn them over time you start thinking about how you can combine them to solve problems.

If you think this way and know some basic tools, all of a sudden all manner of text manipulation problems become pretty easy.

BASH scripting?

Over in the Facebook AP Computer Science Teachers group someone asked for thoughts on covering BASH scripting as a post AP topic.

A number of us made suggestions. I linked to this old blog post.

One group member said she asked around for similar suggestions and the response she got was "vi and awk." I wanted to jokingly respond "and after they suggested that they got into their time machine and went back to the 70's."

In all seriousness though, I think that suggesting specific tools or commands is off base.

The important thing to know about Vi is how to get out of it but it isn't really a tool in the scripting sense. I do think students should spend a good amount of time learning a powerful editor and should try bot Emacs (my choice) and Vim but that's another story.

I also use AWK but as it's a programming language in it's own right, I'm not sure if I'd introduce it right off the bat.

There are a number of important ideas kids can take away from learning some Linux (or other Unix flavor):

  • There's something out there besides Windows and MacOS
  • All about free software
  • The Unix Philosophy

That last one is the biggie and more specifically, there's a huge upside in teaching kids the value of "OS as Toolset" where they can compose the many tools that comprise the Linux experience to get things done.

I gave an example of that in the post I previously linked to.

For the teacher, that means wrapping your head around that way of working. Living in the shell and using pipes to connect program to progarm to program.

I'd recommend getting into a time machine ourselves and taking a look at:


It's dated but it's really a great book on getting into the Unix way of doing things, particularly the chapter about filters. It also has one of the best and clearest introductions to writing a compiler in the chapter on program development.

As I said, it is dated - shells are much easier to use and much more robust, there are many more tools now, and they've evolved but it's really a must read book.

In terms of tools, I get a lot of mileage out of:

command description example explanation
cat catenate or display a file    
tr Translate characters tr A-Z a-z convert upper to lower case
sed Stream editor sed "s/a/b/g" Replace all a with b
wc word count   counts words lines and chars
cut cut columns    
sort sort lines    

A nice simple thing you can do with these is clean data. Let's say you want to do some analytics on a book from Project Gutenberg. You might want to convert all non letters to spaces, and all letters to lower case:

cat book.txt | sed "s/[^a-zA-Z ]/ /g | tr A-Z a-z"

That sends book.txt into sed which uses a regular expression to convert no space and letters to spaces. The tr command converts all upper case letters to lower case.

If you want one word per line, add:

| sed "s/\n/g"

and maybe get rid of blank lines:

| sed "/^$/d"

We can now count the number of words in the file using *wc or even get counts of all the words:

| sort | uniq -c | sort -n

sort will sort all the lines, uniq -c will compress the lines that are adjacent and the same and give you a count and then sort -n will sort the results numerically.

I wrote another post a while ago about using the shell to detect who responded on a Google form. It looks like it didn't convert when I moved to my current blogging platform - I'll repost that shortly.

Should We Teach HTML?

Yesterday, Doug Peterson wrote a "Whatever happened to" post subtitled HTML as an essential 21st Century skill? It's a nice post.

I left a comment but thought I'd elaborate here.

No, knowing HTML is not programming - it's markup. Even so, when I help people design CS programs, I'll frequently recommend starting with HTML or at least introducing it early.


It's a gateway and not just to programming.

HTML is pretty easy, you want something bold, you just wrap the word in <b> and </b>:


It's also empowering and demystifies the web. Kids can create a simple web page and load it right into their browser.

It's true that today's web pages are chock-full-o javascript and css but with just the basics, students can get the idea. You can also show them pages by right clicking and viewing source.

You can even have them change a live page.

Try it.

Right click on the top of this page where it says "Musings about…" Chose inspect element. In the "debugger" window double click the text, change it and hit enter. This is just temporary - just reload the page but it's pretty neat for a kid to change an article and then screenshot it.

HTML is also a nice stepping stone towards coding. You're working in a plain text editor by adding special code words to basic text which are then interpreted by, in this case, the web browser.

The big reason for teaching html actually goes beyond this. Next step after learning HTML is having the kids programatically generating web pages in whatever language you're using for the class. I like using Python. This requires a little infrastructure setup to serve kids work but then there are two huge wins.

First, as the kids learn programming, instead of just printing out results, they can make a web site with their results and share it with friends, family, and the world.

The other big bonus is that kids might be able to leverage take these skills to other classes. If the student has a history paper to write, maybe the teacher will accept a history web site where the student can write code to do their analytics and build nice looking tables and graphs with results.

So while knowledge of HTML in and of itself isn't really needed anymore it's still an important part of the programs I build.

A World Without Advanced Placement

Some good points in the Facebook comments on my last post. One notable comment was the fact that many teachers wouldn't be able to gain the traction needed to teach CS without an AP designation. This is true but also sad that we've awarded such educational authority to a private company that's accountable to no one. Schools should run courses because they're good for kids not specifically because they're AP.

Stuyvesant just implemented a policy that every student has to take at least one AP class to graduate and that now every student in an AP class has to take the AP exam. There's also been a push for Stuy to run APCS Principles in spite of the fact that the current home grown intro course is superior.

These policies and pushes at Stuy are purely for the sake of ratings and in no way for the benefit of the student.

But let's imagine a world without the college board. To do this we're going to have to take off our computer science hats and look at another, more established high school subject area - mathematics.

First, setting the stage.

It's the mid 1990's. High school students across the nation are taking math classes. Some are even taking calculus. This makes the College Board happy since they offer two AP Calculus exams. But the College Board notices that many students aren't ready for calculus. To fill this gap, they create AP Statistics. First offered in 1997 to 7,667 students it was given to almost 200,000 students last year.

According to wikipedia, the course was created to give an AP mathematics option for students not ready for calculus.

I don't seem to recall any huge demand for an AP statistics course but it was created and adopted. It turned into one of the fastest growing AP classes and a nice money maker for the college board. I don't know how the class was pushed or perceived in other schools but at Stuy it was seen as a way to get an easy AP math course on the transcript. Before any statisticians get the torches and pitchforks - I'm just relaying the student perception. I haven't looked into the course sufficiently to form an opinion on it.

Now, let's imagine a world without the College Board.

An individual school would look at it's students needs and decide if they needed an additional math course. Maybe they'd conclude that what they were doing was fine or maybe they would conclude that a new class was needed.

If they decided they needed a new advanced course the school would either have the expertise to create it in house or they'd probably turn to the local college or university for guidance.

They might end up with a course very similar to AP Statistics or they might end up with something very different. They might end up with another class like Discrete Math or they might end up partnering with the college and having students take classes there. In all cases, since math teachers generally have a pretty good math backgroud, schools could make good decisions and design sound educational experiences for their kids.

All of these seem to be better results for the students than blindly following the College Board - keeping education and education decisions local.

What about CS?

I admit that's a tougher nut to crack.

Most schools generally don't currently have the in house expertise needed to build their own solutions or even to really critically judge what's out there.

That said, even if you need join the cult of the College Board to get your school to run some CS you can:

  • Grab all the materials you can find - those labeled AP and those not labeled AP.
  • Don't bother with AP Syllabus certification. Teach what you think is best. Designate the class as honors to differentiate them from other classes.
  • Engage with your local college and tech sector. They're not high school educators but they are valuable resources.
  • Unrelated side note - be wary of code schools - most don't really have any educational chops.
  • Don't force kids to sit for the exams and only encourage them to do so if the exam will likely do something for the kid.

I think that's it or my College Board rants.

Then again, I also thought that when I wrote Friday's post.

Advanced Placement - Because We Don't Trust Teachers

Yesterday, I ranted on about the College Board. This led to a Facebook hosted discussion which got me thinking a little more:

Advanced Placement exams basically exist because we don't trust our high school teachers.

I usually use phrases like "society doesn't trust" but let's personalize it this time – for parents, think about whether or not you trust your kids teachers? Do you a large private, unaccountable organization more?

If you teach an advanced placement course, in order for your class to be listed as AP you have to submit your syllabus to the college board for approval. This sounds like they're setting a standard but it's not. I can point to a bunch of teachers who have submitted identical syllabi where sometimes it's accepted but ofttimes it's rejected. This is the syllabus we submitted originally for Stuy. Yes, we have high achieving kids, but given the fact that the syllabus was approved originally and that Stuy students just about all score 4 or 5 on APCS-A should tell you something about the level of care or competence of the College Board.

Then you teach the class and in May, one to two months before the end of the semester the kids take the AP exam - you don't see results until the summer.

In theory, if the kids do well they can receive placement or credit. The problem is, fewer and fewer schools are giving credit, when they do, it might not help due to the way undergrads pay for courses and placement can generally be achieved by appealing to college departments or by taking college administered placements.

Back to the trust thing.

In college, you take a course, the final exam is created by the professor or a group of professors and it's graded by the people that teach the course - possibly as a committee. Kids final grades include these exams but a student can fail a final or even miss one and still pass the class whereas an AP exam is a one shot deal and even if you "pass" you might not get anything from it. I'm not even getting into questioning the quality and content of the exams.

Kids get their grades and college credit. There are no outside "standardized exams" and we trust that the professors and the colleges are educating our kids.

Now, in high school, teachers make their lessons, teach their classes, create, administer, and grade final exams and kids get grade - but not for college level classes.

I know multiple high school physics, chemistry, math, and computer science teachers who are far better at teaching than their college counterparts yet my friend the math teacher isn't trusted to assess his calculus students for the purpose of college credit - we don't trust him but we trust the faceless entity known as the College Board.


Think about that for a minute.

You trust your child's teacher with your child's well being every day but you don't trust him to say whether or not your kid knows calculus?

This is a real problem.

I have a friend who frequently doesn't quite finish the BC Calculus test topics because he actually teaches the material in depth – instead of "follow the scripts" the kids go through proofs and derivations. It costs the kids - I know a number of them who got a 4 on the BC exam rather than a 5 but come the end of June when the class is done, they know more calculus more deeply than a lot of kids who've taken the class in college.

The lines of college have been blurred with more and more "remedial" classes being taught at the college level and more and more "college level" being taught in the high schools.

It's a really sad state of affairs when we trust our professors - many of whom are hired more for research than for their teaching chops and we don't trust our teachers during our kids more formative years.

Remember, school is all about profit, wait no, I mean testing, no, I mean...

It's important to remember, the college board is about making money for the college board. It's not about supporting teachers and it's certainly not about educating kids.

Kids took the AP Computer Science A exam last week and the College Board just released the free response questions. There seems to me more chatter about them in social media than in past years.

I'm just left wondering how AP became the be all and end all.

From where I stand, the College Board, who runs AP, SAT, and PSAT exams is all about making money for the College Board - they're a non-profit in name only.

It's all about market share and dominance.

Looking at APCS A, it's not a great exam or course. At Stuy, I taught a super-set of the old AB and pretty much ignored the parts I didn't like (that is, the case study) but many schools can't do that. In my case, most of the schools my kids went to didn't award credit, even for a 5. They did sometimes award placement but I've had just as many, if not more kids gain placement just by showing their work to the CS department at their chosen school.

Now they're rolling out APCS Principles. I do get the fact that many schools don't have people to roll their own courses, but I'm not overly impressed by much of what's come out. I think what we've developed is stronger and time proven.

Regardless, and moving beyond just CS, the College Board has somehow bamboozled the public to think AP = Good. Colleges are awarding less and less credit but everyone's telling the kids to take more and more AP classes. What's worse, somehow US News and World Report magically became an authority on school ratings and now the more AP classes your kids take the better.

I know of at least one school with a highly lauded principal boast about all his kids came in behind in math and by their senior year passed honors calculus. Looking at the data unfortunately showed that while all his seniors took the class, all failed, scoring below a 3. It made the school look great but I'd argue that it was child abuse.

The principal of course parlayed that gig to an even higher profile one.

Now, you could just file the stupid paperwork so that you can run classes labeled as AP and have kids take the classes but not the exam but the College Board's working on that - there are rumblings in NY on using student AP scores in teacher ratings. Using student test results for teacher ratings is already a bad idea - using AP is even worse.

Of course, to really get the cash cow going, AP is entering deals with agencies and municipalities for large scale testing – in NY students will have to take the SAT and take it for free. Then there's's deal free PD for school's that have their kids take yet another meaningless exam, the new PSAT/8-9.

Of course, none of this is free - it's our taxpayer money hard at work being shuttled right into the college board.

What are we getting? Tests that they create and control and are EXTREMELY secretive about that don't tell us anyhting that we don't already know about our kids. Oh, and teachers lose instructional time and have to proctor these exams instead of teaching.

Great deal if you can get it.

Now, what's the value of this – more meaningless tests for the kids. I don't know if there's a record of this anywhere but in the pre-internet day, I remember watching a news report where a College Board representative stated that the SAT was a valid predictor of one thing - how students would do on future SAT exams.

So, were left with more money flowing to an outside company with students taking more meaningless tests.

I wish more schools showed the backbone that Fieldston, an elite private school in NY had when it dropped A.P. courses over 10 years ago. They still seem to be well regarded as a school and their kids do just fine in terms of college acceptance.

Enter your email address:

Delivered by FeedBurner

Google Analytics Alternative