Using Emacs - 11 - Reveal.js presentations

Happy to be back after a couple of weeks.

My wife and son spent some time in San Francisco, Mountain View, and Seattle. The main reason was to see our daughter who's interning out there for the summer but it was also a great opportunity to catch up with over 100 former students. If you're interested in seeing more, I wrote a bit about it here.

I was originally going to start talking about Python development but then saw this post on reddit about reveal.js and using it with org-mode. Since reveal.js with org-mode is my goto presentation tool I thought I'd do a video on that before getting back to "your regularly schedueld program."

The main package you have to use for reveal.js presentations in org-mode is org-reveal. The package to install is ox-reveal. I also installed htmlize for syntax highlighting. Here's the code from our configuration file:

(use-package ox-reveal
:ensure ox-reveal)

(setq org-reveal-root "")
(setq org-reveal-mathjax t)

(use-package htmlize
:ensure t)

The org-reveal-root setq tells your presentation where to find the reveal.js code. In this example, we're getting from the cloud. You can also install it locally.

The org-reveal-mathjax is just so that LaTeX equations will look nice.

I'm hoping the video is pretty self-explanitory and the org-reveal home page is pretty thorough but since the documentation is lagging a bit behind the code and due to some versioning issues, here are a couple of things to watch out for:

  • I made a samples folder where I'll put code for this series that isn't part of the configurations.
  • I showed :frag (roll-in) as an example of revealing list items one at a time. Those parens are important and are needed but weren't in earlier versions - this took me far too long to figure out.
  • If you read the docs you'll see that there are many more transitions and you can mix and match them on a page.
  • You might have to upgrade your emacs packages. If you list-packages in eamcs it will tell you if you have packages to upgrade. You mark them for upgrading by typing U and then do the upgrade with x. If this doesn't work, you can try getting rid fo the elpa folder and then re-installing.
  • The mazelesson sample presentation shows more features, many that we haven't covered yet. Check it out but remember that it's for an earlier version of org-reveal.
  • Github pages and rawgit are cool.

Hope you enjoy this. Please add any reveal.js tips and tricks of your own.

Relevant links:

West coast trip - a nice close to act I


If I look at my leaving Stuyvesant and the NYC Department of Education to join Hunter College as the end of Act I of my teaching career, then our family's West Coast swing was a nice way to pull down the curtain.

The impetus for the trip was visiting Batya - she's interning at Facebook this summer and having an absolute blast.

The plan was to spend a few days in San Francisco, then a little south to Mountain View, where Batya was staying, and then fly up to Seattle for a couple of days.

Of course, while out there, why not see if some of the StuyCS family wanted to get together.

I knew I had a lot of former students out on the West Coast but still, I was overwhelmed and humbled by the number of people who wanted to spend time and catch up.

We kicked things off at Bloomberg Beta thanks to Roy Bahat. Roy was never actually my student but we've gotten to know each other over the years and I value him as a friend and advisor. Roy provided the food and the space and about 60 former students + a few old timers showed.


A couple of days later, we had a lunch meetup for the Googlers:


and a happy hour at Facebook (sorry, no picture). Then in Seattle, a nice dinner to close things out.


Between these events there were some lunches, a barbecue at Batya's place and even a drive by visit with a former student at Microsoft. Overall, it was easily over 100 students over the course of the week or so we were out there.

I've often said that one of the things I'm proudest of is helping to build the StuyCS family. A community of people spanning decades. Over the week, we had events mixing students from the mid 90's to youngsters currently in college and on their internships.

Seeing all these people meeting and supporting each other gave me a "proud pappa" type feeling even though I didn't do any more than set the stage for them getting together.

Over the week, the conversations were also great - not the straight tech ones, but the ones that really made me proud of the crew. From Seth talking about how to better get good CS Ed to more kids, to PJ discussing why he feels it's so important to be an active mentor to his young programmers and how to get them to be real thinkers, to Mike, Sam, Kathy, and Leo discussing the disconnect between privileged families and those struggling to get by.

What more could a teacher want than their former students being both happy in their lives and careers as well as good people seeking to make the world better for everyone.

The only thing that made me sad about the trip is that with all the big events, I really didn't get a chance to spend the time I wanted with everyone. I hope to do better next time.

So, I've now been at Hunter for one semester and things will really ramp up in the Fall. I'm still a proud part of our StuyCS family and if being a part of pulling it together is the legacy I left, I can live with that.

The trip was a nice symbolic way to lower the curtain on act 1. I'm counting on the StuyCS family and all the other players to help so that we can make sure act 2 is a success and we can build something similar for more young people throughout the city and perhaps the country.

Using Emacs - 10 - org init files

I'll be traveling for the next couple of weeks so I probably won't have time for another video until mid to late July. I'll probably write a post about this series and do some regular blogging over that time but probably no new videos for a couple of weeks.

Also, a couple of notes about the series:

  1. Instead of making a separate git branch for each episode, I'm just adding on to the master branch on GitHub. If you're not familiar with Git and GitHub don't worry about this. Hardly anyone will notice a difference.
  2. If this theme doesn't show well on video, please let me know, I'll change it.

Ok, now to this installments video.

It talks about using org-mode to store our emacs init file.

The first key is that you can put code-blocks in org-mode:

#+BEGIN_SRC emacs-lisp
(emacs-lisp code goes here)
(more emacs lisp goes here)
(and you can have even more here)

Since it's elisp you can run the individual line using the usual C-x C-e but you can run the entire block by placing your cursor anywhere in the block and typing C-c C-c.

One minor annoyance about editing code blocks is that it doesn't do syntax highlighting or auto indentation. To solve this, emacs lets you pull up an editing buffer by typing *C-c '*.

You're supposed to be able to save your changes with *C-c '* again or C-x C-s and kill the buffer without saving changes with C-x C-k but the version of org-mode that came with my version of emacs didn't support it - I had to install a newer version of org-mode from melpa.

I couldn't figure out how to do this via use-package, but if this problem happens to you, you can just type Alt-x package-install and then type org and hit enter to install it.

Once you do that, you might have to reload emacs but then everything should work.

This lets us move most of our configuration to a separate file. We're calling it and storing it in our .emacs.d directory. You can use any name except as I mentioned in the video.

The file's a little big so here's a link to it:

Notice how GitHub formats it to look all nice.

Here's the raw file so you can see the gory details:

Since we're loading the file in overview mode, when we load it in emacs we see:

* interface tweaks
* try
* which key
* Org mode
* Ace windows for easy window switching
* Swiper / Ivy / Counsel
* Avy - navigate by searching for a letter on the screen and jumping to it
* Autocomplete
* Themes

We can tab open and close each section and add text to clarify things around the code blocks.

All that's left in init.el is:

(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))

(org-babel-load-file (expand-file-name "~/.emacs.d/"))

With the last line performing the magic of loading our org file and running all the code blocks.

Finally, we added a couple of small interface changes:

(fset 'yes-or-no-p 'y-or-n-p)
(global-set-key (kbd "<f5>") 'revert-buffer)

The first line lets us type y or n instead of yes or no and the second let's us reload a file into our current buffer using the f5 key.

I hope you enjoy this video and find it useful:

Relevant links:

Hillary and Student Loans

Yesterday I read over Hillary's briefing on her initiative on Technology and Innovation.

A lot of it sounds good but, at least for the education piece, I have my doubts. My feeling is that she's pretty much aligned with the current administration education wise and the current administration has been as bad if not worse than the previous with respect to public education.

While I have issues with some of the education pieces and very much like some of the others, I don't want to get into that today. I want to focus on one specific part of her plan. The part that defers college debt for up to 3 years for founders and entrepreneurs. This sounds great but is this really a good thing?

Some initial responses from the education community is "what about young teachers, don't they deserve some help on college debt? What about nurses?…" and of course they're right. On the other hand, I don't want people to go into teaching for 2 or 3 years just to get some debt relief benefit and then jump ship. That's the Teach for America model that I feel has become so harmful.

But again, that's not where I'm going with this.

Let's start with "who are these founders?" I don't have any hard data but I have read a couple of recent pieces that indicate that founders right out of college are typically from well to do backgrounds. This of course makes sense. A kid up to his or her eyes in debt from a poor background. No savings, no property, likely a family, that is siblings and parents who are also treading water can ill afford to take a big financial risk. A kid from a monied family? Much more so.

This alone makes Hillary's plan a boon for the wealthy but not so much for the people we need to give a hand up.

Next, this plan talks about the founders and only says it will "explore similar incentives" for early employees, citing "10 to 20." This doesn't seem right to me.

Now let's look further into the benefits. I don't know what the success and failure rates are for startups. I've seen a bunch of figures including:

  • 90% of startups fail within the first three years
  • Three out of four startups fail
  • Of 10 startups, 3 or 4 totally fail, 3 or 4 break even and the others turn a profit.

I don't know where the truth lies but I'd imagine that the success rate for startup by a recent college graduate, wet behind the ears is probably higher than for a more season professionals.

Hillary's plan defers debt for up to three years. If any of the failure numbers cited above are near correct it means that these kids will have burned through up to three years with the experience of a failed startup to show for it.

I've always advised my students, all things being equal, start at a big or mid size company, develop your chops, learn how they do it, further build out your network, and then go out and do your thing. Most kids are better served not going directly from college to their first startup.

So there it is. A plan that makes for great "press release" but is it really addressing the issues?

On Teaching, Mentors, and Role Models

Yesterday over at AVC Fred blogged about the AFSE graduation and posted a transcript of the speech he gave. It's well worth a read.

Some of the comments touched on mentors and role models so I though I'd talk a little about that here.

I've always believed that as a parent, modeling - that is, how we behave is one of the largest shapers of our kids. It's one thing to take your kid to a museum because that's what you should do as a good parent and another if you think - "I wants to go to that museum and damn it, I'm taking you along." I'm no psychologist but my gut tells me the former is good but the latter is better.

This of course extends to schools. As teachers we deliver instruction but we also communicate through how we behave. Students are very perceptive and we can have influences that we don't even know. I remember a parent who thanked me because their child started exercising and being more active because of me. It's not something I ever talked to the kid about but I would run after my classes at Stuy, ride to school and in class I might give an exercise anecdote or two. Just by doing something healthy and positive where kids can see it led to some good.

Now, as teachers, we have limited reach and just as in many cases where a child won't listen to a parent and needs a friendly teacher to weigh in, there are plenty of times a student won't really listen to a teacher, particularly in CS. Most CS teachers don't have extensive CS backgrounds and self taught kids frequently feel they know more. Even when a student believes that a CS teacher's got the goods, they're skeptical - teaching as a profession has been so beaten up many students will have a ""so why are you teaching and not working at Google" attitude.

Even with the best intentions from parents and teachers, for many students, particularly those from poor backgrounds there are limits to our influence. If a parent has to work multiple jobs at crazy hours, they have less time to be a positive role model. If they've never been to college or worked in a white collar profession they won't have the connections and resources to effectively guide their child through the education to profession maze.

This is where mentors and role models become so important.

For me, I first saw this when I was a young teacher. My graduates hadn't gotten to the real world yet and I hadn't developed a reputation. I'd have friends come in to give tech and industry talks. What I found was that in addition to being inspirational, it help authenticate me as being legit. When they would talk about a best practice that I had already taught them, the classes got the idea that maybe I did know a thing or two about this CS stuff.

You could see the impact when we held "Tech speed dating" events where I mixed current high school students with professionals.

So many comments afterwards like "I didn' know I could do that in CS," "now I know what I want to do…." Slam dunk!!

Of course, you have to curate your volunteers. While a guest talk from a very senior, very established adult can be inspiring some times, they can be so far removed from the kids next steps, it can actually be intimidating and a turn off. As a side note, I don't think that this would be the case at all with respect to Fred's graduation speech. His overall sincerity and the fact that he's so connected to the school and known to the kids made sure of that.

When I made my first Hunter college event, I wanted to kick start and excite the current students and also give myself some CS street cred so I carefully selected the participants for our first panel / mixer. I had:

  • A young VC
  • A mid 30s CTO of a mid size company
  • A mid 30s Facebook engineer who also spent time at Google
  • Assorted recent college grad tech people from big companies, start ups, and everything in between.
  • I tried to have a diverse crowd.

I wanted a couple of more senior people to show the end of the road but I wanted most of the people there to be at "the next rung in the ladder." All indications were that the event was also a slam dunk.

Through all of this it's become pretty apparent to me that bringing in adult mentors and role models can be even more important than covering every little bit of whatever curriculum you're teaching. Some people say that we need more female High School CS teachers and while I agree with that sentiment, I'd rather have the best CS teacher I can get regardless of background as long as I have amazing women in tech to provide for my students as role models.

This led me to think about a couple of the CS Ed programs that I support. TEALS and ScriptEd. I like both, but they're different models. In TEALS the volunteer works with the teacher. In ScriptEd, the volunteer is the teacher. I have many former students that have volunteered through TEALS but I don't know any who've done SciptEd so I don't have the same "inside" info.

For TEALS, those volunteers are also role models. Every day that Etsy engineer is in the classroom those students see and hear from a tech professional. What's more, they see and hear from one who's taking the time to be with them.

Of course the same is true for ScriptEd but I wonder if after some time the students view the ScriptEd volunteer as the teacher rather than the tech professional.

There's probably some interesting research in there.

Finally nothing is better than really being able to hook kids up with long term mentors. This is something that I think AFSE's been able to do but it's an expensive proposition. It's something I'd love to see more of at schools and as part of the basic budget but with all the money wasted on things like standardized testing and flawed teacher evaluation systems, I don't see it coming any time soon.

Using Emacs - 9 - Themes

Now that we have a nice basic configuration, let's make Emacs look a little nicer.

Like most editors, Emacs can be extensively themed.

As shown in the video, you can quickly see the built in themes using the customize-themes command.

You can load one of these themes by using the load-theme command interactively or, more likely by putting:

(load-theme 'leuven t)

in your init.el. The above code loads the built in leuven theme.

I prefer the zenburn theme. For that, you have to load the zenburn package. Here's the code in our init.el:

(use-package zenburn-theme
  :ensure t
  :config (load-theme 'zenburn t))

In the video, I also mention the color theme package.

So, customize away.

In the links, you'll find some links to some Emacs theme gallery sites to help find something you like.

Thanks for reading and watching and as always, please leave comments, suggestions and favorite themes.

Here's the video:

Relevant links:

Using Emacs - 8 - Autocomplete

Out of the box, Emacs supports various types of completion.

Tab completion for filenames and commands basically work right out of the box and Emacs has built in modes like Abbrev, Hippie Expand, and Dabbrev provide a manner of completion for in buffer text.

I briefly show Dabbrev (Dynamic Abbrevs) in the video and if you're interested in the others, follow the links.

We saw ow the built in Ido mode and third party packages like Ivy, which I prefer, and Helm make for better completions on functions, filenames, and the like and Emacs also has third party packages for in buffer completion.

The two main contenders are auto-complete Mode and company Mode. I use auto-complete, others swear by company. The video shows the basics of auto-complete mode but check both out and decide for yourself.

If you feel strongly about one or the other, please share in the comments.

Here's a basic configuration:

(use-package auto-complete
  :ensure t
    (global-auto-complete-mode t)

We'll modify this as move along in the series.

Here's the video:

Relevant links:

Using Emacs - 7- Navigation with Avy

Here's a really cool navigation method that I've been meaning to use more. Avy is a replacement for ace-jump mode which is an implementation of easymotion, a vim plugin.

It's pretty cool and lets you quickly navigate to any spot on the screen.

After triggering avy, or more specifically the avy-goto-char function, emacs prompts you for a single character. When you type it, all instances of the character that start out words change to a highlighted letter. Type the highlighted letter and you jump to that location.

The avy package comes with a bunch of options including a 2 character search variant, a timed variant which drops into search, and more.

The Avy home page has all the details.

Here's the configuration I'm using:

(use-package avy
  :ensure t
  :bind ("M-s" . avy-goto-char))

You can check the avy home page for their recommended configuration which you get by configuring this way instead:

(use-package avy
  :ensure t

Relevant links:

Lesson plans - scripts to springboards

I spent last Saturday up at the Microsoft offices in Times Square observing a TEALS training session. My fried Nathaniel Granor, Teals Regional Manager in the east has invited me a number of times and this time I was able to make it.

If you don't know, TEALS is a program that takes volunteers in the tech industry and places them in classrooms. Unlike other programs, the TEALS volunteers work with the teachers while the kids learn some CS. The idea is that the teacher will learn about CS from the volunteer and the volunteer will learn something about teaching.

It's not the same as having a strong, knowledgeable CS teacher in the classroom but until we get there, TEALS is doing great work giving kids something that they need and otherwise wouldn't get.

At one point, Nathaniel started to talk to the volunteers about lesson plans emphasizing the fact that TEALS would provide all the lesson materials and the plans so these new to teaching tech volunteers wouldn't have to make curricular decisions.

The lesson plan form was pretty traditional and pretty formulaic:

  • warm up
  • hook
  • instruction
  • practice
  • Assessment

Very similar to what I was shown back in the day during my two day "teaching boot camp" that kicked off my career 1 and very appropriate as an effective and efficient way to prepare these volunteers for their first days.

This got me thinking about my lesson planning over the years.

When I started, I was teaching math but I wasn't really a math guy - I was CS all the way. I had to remember the math from high school, learn the new topics, and figure out how to teach it.

I had a very supportive department but they were busy with their own classes and this was pre internet. Fortunately, the NYC DOE published lesson plan books. They were basically bound volumes of xerox copies of hand written and typed lesson plans provided by experienced teachers.

I spent many hours copying them, studying them, and then later tweaking them.

They were a life saver back then. How was the teaching? OK. Not great. I got the material to the kids but I was nothing special. This is where I started to form my bias against the scripted teaching that's being pushed down today.

As I developed my chops, I started to design my own experiences for my classes and things improved. By the time I was done teaching math - maybe 4 years in, I was just scratching the surface of being a math teacher.

One year in, I started teaching CS along with math at Seward Park. When I was bumped to Stuy, I went back to math for a year and a half and then it was all CS all the time.

For CS, we didn't have lesson plan books so I had to craft everything from scratch. It was a lot of work but the results were much better.

At first, I would actually write out lesson plans a la math lesson plans. A "do now," "instructional objectives," "applications," "Homework," etc. The only thing I never formally wrote out was a "medial summary."

Over time, my lessons got better but my lesson plans looked worse and worse.

There were times a lesson plan might look something like this:


OK, not exactly but as I developed at my craft, I didn't need a laid out script to follow line for line rather, just a set of little reminders and maybe some printed out code. If we were going to develop a complicated algorithm or derivation, though, I would still write out all the steps.

This doesn't mean that as my career progressed I planned any less. It might appear that I'm winging it but even if little to nothing is written down, there is a plan and there's always a lot of pre work before class begins.

Now, to bring this back to TEALS.

It's interesting how what's good in one context is not so much in another.

What TEALS is doing is great - they've got to get a lot of technologists in to classrooms quickly but once there, they'll be with real, hopefully experienced teachers. What they're doing gets them ready to go. It's a starting point, not an end.

On the other hand, when I see scripted curriculum being sold as the special sauce, be it in CS teacher "training," Teach for America summer prep or in the name of charter school uniformity, I run the other way.

Let's prepare curricular materials for important programs like TEALS and for beginning teachers just starting out but let's not confuse a scripted lesson that can be delivered by one and all to be anything close to the work of a master educator and craftsman.



full disclosure: I came in to teaching with zero education credentials and took the minimum number of ed classes for my license after I started.

Better Comments or tooling as a time sink

The other day my friend and fellow CS Ed Blogger Alfred Thompson wrote about Better Comments, an extension for visual studio that displays comments that are marked up with special characters in order to highlight them. Here's a screenshot:


So, the first thing I though was "I bet emacs could do that pretty easily" and down the rabbit hole I went.

I had to figure out something about how emacs themes and font-locking (emacs for syntax highlighting) works and of course spent far too much time learning about Emacs, my favored tool, rather than getting actual work done, but I came up with this:

(make-face 'font-lock-comment-important)
(set-face-foreground 'font-lock-comment-important "#00ff00")

(make-face 'font-lock-comment-todo)
(set-face-foreground 'font-lock-comment-todo "#ff0000")

(make-face 'font-lock-comment-strike)
(set-face-attribute 'font-lock-comment-strike
		    nil :strike-through t)

(defun add-custom-keyw()
  "adds a few special keywords"
   '(("cx \\(.+\\)" 1 'font-lock-comment-strike prepend)
     ("ct \\(.+\\)" 1 'font-lock-comment-todo prepend)
     ("ci \\(.+\\)" 1 'font-lock-comment-important prepend)
(add-hook 'python-mode-hook 'add-custom-keyw)
(add-hook 'js2-mode-hook 'add-custom-keyw)
(add-hook 'js-mode-hook 'add-custom-keyw)

It's a hack but it does indeed work. In action, it looks something like this:

Truth be told, it really colors anything following cx, ct, or ci, not just in comments – I have to look a bit more into how emacs handles comments to figure that one out.

In any event, even though I spent too much time doing this, it's nice to know I'm working in a tool in which I can.

UPDATE: Thanks to user ncsuwolf on /r/emacs on reddit, here's a fully working, more properly done solution:

(defface font-lock-comment-strike
  '((t (:strike-through t)))
  "For strike-through comments")

(defface font-lock-comment-important
  '((t (:foreground "#00ff00")))
  "For important")
(defface font-lock-comment-todo
  '((t (:foreground "#ff0000"))
		"For todo comments")
(defun add-custom-keyw()
		"adds a few special keywords"
		 '(("\\s<+x[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-strike prepend)
			 ("\\s<+t[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-todo prepend)
			 ("\\s<+i[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-important prepend))))

	(add-hook 'prog-mode-hook #'add-custom-keyw)

Enter your email address:

Delivered by FeedBurner

Google Analytics Alternative