Code Reviews: Before You Even Run The Code

I do a lot of code reviewing, both in my day job as principal developer and also as an open source maintainer. Sometimes it seems like I read more code than I write! Is that a problem? I'm tempted to say that it isn't. To be a good writer, you must be well-read; I believe that to be a good developer, you need to be code-omnivorous and read as much of other people's code as possible. Code reviews are like little chapters of someone else's code to dip into.

Over time I've developed some particular processes that I find helpful when reviewing code. In particular, I often surprise people at how much review I do before I run the code. Sometimes I grab the branch so that I can use my local diff tools, but I don't actually execute code until I've established some basic facts. This post is a little insight into what's happening in this not-running-the-code-yet zone. Continue reading

Count Changed Lines in Git

I have a favourite set of switches to git log, but today I wanted to answer the question "You deleted how much code today?" so I thought I'd share how I did that

git log --numstat will show you how many lines were added (first column) and removed (next column) per file, kind of a more scientific version of the --stat switch. And if you're thinking of scripting this to gather stats, try it with --oneline as well, it's easier to parse.

Scaling and Sizing with PDFJam

I find myself needing to take a PDF, output it at a specific size, and have the result offset to the top right hand side of the screen. To achieve it, I needed a few new switches to my good friend PDFJam, so I thought I'd share my command!

pdfjam --suffix converted --papersize '{1920px,1080px}' --scale 0.4 --trim "-6cm -1cm 13cm 8cm" slides.pdf

The --suffix is instead of giving an output filename, whatever you feed in ends up with the suffix in its filename. This is very handy because I use this command in a script and only need to pass in one variable. The --papersize isn't a switch I have used before either but you can set exact sizes for the final output which is nice. The --trim switch can also be used to set --clip=true to remove the trimmed space from the document if desired.

I find PDFJam a very handy tool but with not nearly enough blog posts and code snippets around, so I'm dropping my command for future reference (yours as well as mine!).

Vimdiff and Vim to Compare Files

At the moment I'm working on a tricky project where two similar projects diverged. Very similar things happened to them both, but not quite the same things - and now we're merging the codebases to give us as much common code as possible. All this simply serves to set the scene of exactly what I was doing spending a whole day with large code diffs - I had to look up a few things so I thought I'd capture them while I can remember. Continue reading

Test Incoming Webhooks Locally with Ngrok

I'm enjoying working with hubot; I have a few different instances running for different groups. One of the things that I use hubot for is to echo activities from the source control repo, the bug tracker, the CI system, the (you get the idea) into the channel for a project. This is achieved via webhooks; a feature offered by many providers to POST information about an event to your endpoint as soon as it happens. Continue reading

Organising Inclusive Events

I've been thinking a lot lately about what makes an inclusive event. Not gender-inclusive, necessarily (I commonly find myself as the only woman developer at both my local user groups), just approachable, maybe for newcomers but mostly for everyone. What happens at the event itself is really important, whether people greet you, whether the speakers introduce themselves, and so on. That's only half the story though, because often we've excluded people from our events before the event begins. Every conversation I have about this topic comes back to information. Continue reading

Hubot with Git Submodules

I love hubot and use one in a few different places. One thing I do find though is that I often want to edit or evolve those plugins, and it seems somehow unethical to just hardcode my changes into my own repo. Once I figured out how to wire together a forked repo as a submodule, it became much easier to work with hubots with external plugins, so I thought I'd share my recipe for that. Continue reading

Git: upstream is gone

I came across a git repo recently that output this message with every operation I did:

Your branch is based on 'origin/master', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

I was delivering a workshop at the time so I kinda snarled at it and carried on with what I was doing, but later I looked up what is happening. This occurs when a branch is tracking a branch that the git repo doesn't have any information about - the branches to be tracked aren't in the local repo metadata.

In my case, it happened because I had created and then cloned an empty repo for training purposes - so origin/master didn't actually exist yet! I added a quick commit-and-push to my script and hope that I won't be upstaged by this change that came in with git 1.8.5.

Hopefully this post will help someone else to avoid being upstaged or irritated by this as well!