adventures in elisp

samer masterson

...And I'm back!

This is my first post in about 3 years! A lot has changed in the meantime, but it’s pretty late right now so this post is going to be short.

I updated the site’s theme to cgmartin’s bootstrap blog theme, and now it’s responsive and a lot prettier. :D

EmacsConf 2015 thoughts

This will be a short update, because I’m feeling a bit spacey at the moment.

I’m organizing EmacsConf 2015, and I would love it if you could make it. We’ve had almost 200 signups on our interest form (https://goo.gl/forms/tv0sDuApd8) so far, which I’m really happy about.

The idea is to build infrastructure for EmacsConf 2015 that we can use for future Emacs conferences too, and potentially leverage the EmacsConf event to turn emacsconf.org into a “social space” for Emacsers. I’ll follow up with more details later.

-s

deploy hexo with "git push" (spoiler: git hooks are rad)

Hello friends,

I generate my blog with hexo, my third or fourth blog generator so far, and I’m really enjoying it. Hexo is really flexible, has all sorts of convenience functions, and is super easy to deploy (it’s literally just hexo deploy). Deploys were such a problem for me with my last blog generator that I didn’t write a blog post for 6 months! (It was seriously like five steps, and it was super slow even after I automated it!)

I’m super happy with hexo. This is my workflow:

# 100 freaking git commands, someone seriously
# needs to write a usable wrapper for git
$ git push # push to server
$ hexo generate # generate static site
$ hexo deploy # copy static site to remote host

But can I do better? (Yes)

I will always run hexo generate and hexo deploy after git push. Then why do I need to type them myself? I pay Amazon good money for Robot Computers in the Cloud™ (my buzzword game is on point), so let’s put those robots to good use and set up a git server-side hook to generate and deploy the site for us.

Git hooks

What are git hooks? Git hooks are scripts that you can tell git to run after certain events. There are many different flavors of git hooks, but we just need a server-side post-receive hook. (Btw, this won’t work with GitHub. But that’s okay, because setting up your own “private” GitHub is actually way easier than you probably think it is! As long as you have ssh access to a machine, you can create remote git repos on it. I’ll write a post about that soon, but you can follow the git book’s slightly overcomplicated setup for now.)

A post-receive server-side git hook is a hook that runs on your server after a push. git push won’t actually return until post-receive is finished running, so you can be sure that your site is completely generated/deployed after git push finishes.

THE ACTUAL HOOK (the moment you’ve all been waiting for)

First, some setup.

# BEFORE YOU START: Make sure you have npm and node set up correctly on
# your server.
$ ssh <username>@<your-server> # log into your server
$ cd <git-repo-for-site>/hooks # assuming your repo is a bare repository
$ touch post-receive # create post-receive
$ chmod +x post-receive # hook must be executable
$ nano post-receive # s/nano/your-favorite-text-editor/

And then paste this sucker in:

#!/bin/sh

# Hooks are executed with the top level git repository as their working
# directory, i.e. "/home/person/site", not "/home/person/site/hooks".

# This script assumes your remote repo is a "bare" repository, which
# it should be. More info:
# http://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server

# you can make arbitrary directories inside git repos
mkdir hexo-tmp
# check out the branch "master" into "hexo-tmp"
git --work-tree=hexo-tmp checkout master
# move to "hexo-tmp"
cd hexo-tmp
# install hexo modules into "hexo-tmp"
npm install
# generate your site (to "public" by default)
hexo generate
# copy your site (recursively, verbosely, preserving file metadata) from
# "public" to your website directory.
rsync -rva public/ <path-to-website, e.g. "~/www">
# clean up "hexo-tmp"
cd ..
rm -r hexo-tmp

(Make sure to change the path on the rsync ... line!)

And that’s it! The robots are doing your bidding, and git push is all you need to share your awesome blog posts with the world! You should see the output of all of those commands whenever you git push. (If you run into issues with the git hook, double check that you made post-receive executable. If it’s still broken, leave a comment.)

Now, there are some obvious ways to optimize this (like by installing the node modules globally once, instead of on every push), and I encourage you to optimize your own script yourself :D

happy hacking,
s

daily bread/thoughts

I had a great blog post half-finished when my ssh connection died (and Emacs didn’t save a back up–the one time I needed the feature it didn’t come through -_-), so ya’ll get a condensed version: things that I do without thought can fit into my life without burdening me, and I always make time for them, no matter how busy I am. So, I should fashion the things that I want to do but don’t have time for into daily, mindless, zero-decisions-needed activities.

I’m going to start with my social Emacs site idea. I haven’t been able to start writing code, so I’m setting my sights lower: every day, I will do five minutes of planning and thinking for the idea, and I will write my notes down.

I started today, and I have some notes that I’d like to share. I’m going to start posting them to my blog after connecting it to the Recurse Center feed and planet emacsen, and after setting up a commenting thing, so I can gather feedback on my notes.

-s

4knots music festival

Two weeks ago, I googled for Dinosaur Jr.’s tour to see if they were hitting NYC, and found out they were playing at a free festival here! I ended up going, and it was amazing. One of the best music experiences I’ve had so far.

Crazy Pills! Saw them on the side stage (which I thought was the main stage :3 ) and they rocked! I was blown away by how good they were. Hopefully they’ll be on the main stage next year. They play some crazy good garage pop, check out their bandcamp. I had left my crazy pills at home, but their show was a good substitute.

Mac Demarco! He has a set of lungs on him. I got to talk with him & the band. Got some signatures! In order: Pierce, Mac, and Peter.

J Mascis! My guitar hero. He’s like a tree person. Dinosaur Jr played a fantastic show. They were so loud. Everyone moshed around me, and I went up to the very front to escape it. Pro: I got to the front! Con: moshing is violent and kind of distracting ): I wasn’t super into that part. But! they played a rocking set. They also played two of my favorite songs, which they didn’t during the last two shows I saw them at.

The colors are washed out, everything is a lot more purple in real life. Also, you can’t appreciate how loud and in-your-face the bass was with that video. I swear to god I could barely hear J’s guitar at points. It was good.

I also got his signature! I snuck my way around the back after the show was over and asked if he would sign my notebook. I asked him if purple was his favorite color, and he was like, yeah, and I was like, me too, man. It was cool.

secure websockets through nginx

my snake game works again! It was my first significant effort in go. It’s a port of a python program which only handles two connections at any given time. I was able to trivially expand it to work with an arbitrary number of connections in go. That was my first “real” go program.

I used websockets to between the javascript client and the snake-mmo server. Everything broke when I switched to SSL, though, because Firefox refused to send data over a non-secured connection. When I tried upgrading the connection to secure websockets, it broke, and I wasn’t sure why. I went through my nginx config a hundred times, but I couldn’t understand why nginx wasn’t decoding the ssl connection correctly… until I talked to Max about my problem, and he showed me that I wasn’t going through nginx at all, and that my server was getting an SSL packet and writing junk in response. So I set up the following in my nginx config to make nginx act as an SSL proxy:

server {
        listen 4028 ssl;
        keepalive_timeout 70;
        ssl_protocols SSLv3 TLSv1;  
        ssl_ciphers AES1280SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
        ssl_certificate /*location of my ssl cert*/ ;
        ssl_certificate_key /*location of my ssl key*/ ;
        ssl_session_cache shared:SSL:10m;                                       
        ssl_session_timeout 10m;
        location / {
                proxy_pass http://localhost:4027/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }
}

So, my javascript client talks to port 4028, and my snake game talks to 4027. And it works! I’m not sure why the Gorilla websockets client didn’t work with ssl connections…

little green blocks

The only streak I’ve been able to keep up during my time at Hacker School is my blogging one: I’ve written a blog post for every day I’ve been here. Even though I’ve written a lot of trash posts (like this one!), I’ve become more comfortable with writing, and some of the discussions that have spurred from my posts have been a lot of fun.

I haven’t been conscious of my github commits, though. As a consequence of the work I’ve done at Hacker School, I’ve committed something almost every day, but I have missed a couple days. I’m going to commit (heh) myself to committing a non-trivial change to a public project on my github every single day, similar to John Resig’s experiment.

becoming productive

I’ve been super unproductive recently, and I’ve been gathering advice for how to consistently do work. The overwhelming response has been to make abstract goals more concrete. I gave the idea a test drive today by breaking my goal of actually starting on the semantic analysis phase into discrete steps, with a time estimate for the task as well. When I start something, I write it on a sticky note and stick it onto my laptop. It worked surprisingly well today; I was able to make significant progress, and I have a vision for how I want to complete the semantic analysis and IR generation phases. Woo.

steve klabnik: lessons learned

Steve Klabnik gave a fantastic talk for hacker school on his transition from applications, to library, to language developer. At its core, the talk was about the different kinds of software development, and how you should explore the field and find the kind of work that fits your personality. I thought it was super interesting, and I loved his lightning-paced delivery style and witty sense of humor.

The talk would be better summarized by someone with a better memory than me, but there was one thing Steve emphasized throughout the talk one thing throughout his talk that I thought was significant: he did not want anyone to feel bad for being different from him.

I’ve found that my default response when someone I look up to talks about something they’ve done is one of distance0: they’ve done this thing that makes them different and probably better than me. Sometimes I can come up with an analog that I’ve accomplished to compare myself to them, sometimes I use this difference as a point of inspiration, as something to achieve so I can move closer to my idols, and sometimes it just makes them seem super human, and makes me seem just-regular-human in contrast. None of this is deliberate on the side of the person talking about their achievements, but these are all feelings I’ve actually felt when people I look up to talk about the awesome things that they’ve done.

Steve made a conscious effort to be inclusive in his talk. When he talked about applications programming and why he didn’t like it, he emphasized that it was just his personality that didn’t match the work. When he described the work as pulling in lots of different pieces to build something, similar to playing with legos, he emphasized that playing with legos is awesome and that this kind of work was really cool. And he repeated the same patterns when he talked about his library- and language-level work.

Steve cared so much that we didn’t feel intimidated by the field of software development that he omitted his “origin” story from the talk, and didn’t tell it until it came up in the Q&A afterwards. He had an early start with GW-BASIC during his elementary school years, but he told us that he had a distaste for “baby hacker” stories because he felt like they were irrelevant to his maturation as a programmer, and that his later years were much more significant.

I was able to talk to Steve after the Q&A about how he deliberately tried to be inclusive. He told me that he believed that programming was not a matter of genes (which is good, because we were both wearing shorts!), but one of practice. With that perspective, any sort of grandstanding doesn’t really make sense, as it drives people away who would probably make awesome programmers.

That’s something I need to internalize. I’ve given some people the impression that I know what I’m doing or that I have all my shit together. If you know me, you know that’s the furthest thing from the truth. I am living proof that someone who doesn’t have their shit together can still get things done. So if you struggle with focus, or productivity, or breaking the reddit-facebook-hacker news cycle, feel free to ping me and we can collude on actually getting things done.

I also thought it was cool that Steve has a really strong grasp on where his motivation comes from: he likes making a difference for large groups of people. I asked him what he liked about rust because I wanted to hear him nerd out about the language. His answer surprised me, though: he said that he liked the fact that it was low level, as that was something he hadn’t done since he had left college, but he seemed more excited about how rust is on an upward trend and has a real chance of displacing C++. He was super excited about how a ton of people would be affected by his work. I thought it was really cool that the future popularity of the language was such a draw to him, and that he knew enough about himself to know that that’s partially why he was drawn to the language.

As I mature, I want to explore what fuels my internal drives. It seems like something important to know about yourself.

0 Lord, I was born a rambling man.