Squashing Git Commits Is Great Code Etiquette

Whether you collaborate with a team of folks or just by yourself, having tidy git commits are useful in being able to search through your own git log.

Take this git log example:

[[email protected] tmp_blog]$ git log
commit eeb0dae575e2ce9f055625f367c802060838d584
Author: Adrian
Date: Mon Apr 6 15:50:06 2015 -0400

added comments for decorator

commit 12cb1bdb3278c410cc21842c95da1066b3386b21
Author: Adrian
Date: Mon Apr 6 15:49:25 2015 -0400

added working decorator

commit 690b9668ed0a2f205ac0a535c89f089c4e2cca7b
Author: Adrian
Date: Mon Apr 6 15:33:54 2015 -0400

WIP: testing a decorator

commit 34eeee492343aad2936d1b89eff92ee04b818aef
Author: Adrian
Date: Mon Apr 6 15:27:53 2015 -0400

initial commit with README

I want to tidy things up before I put in a pull request, because if I were the person reviewing my code, I wouldn't want to have all of those commits to look through. I also want to keep the git log clean so that when myself or any other engineer comes and looks to see the history, there will be a definitive point where I can say, "okay, this is the commit from this pull request".

The basic steps that I typically do are as follows git rebase -i {COMMIT_TO_REBASE_AFTER} and then edit the git commit during the interactive rebase.

So, for my example, I want to rebase after my initial commit: [[email protected] tmp_blog]$ git rebase -i 34eeee492343aad2936d1b89eff92ee04b818aef

A menu comes up similar to the following:

pick 690b966 WIP: testing a decorator
pick 12cb1bd added working decorator
pick eeb0dae added comments for decorator

# Rebase 34eeee4..eeb0dae onto 34eeee4
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#

It is hopefully self explanatory. I am going to reword one commit and fixup the rest so I can have one nice, detailed commit.

r 690b966 WIP: testing a decorator
f 12cb1bd added working decorator
f eeb0dae added comments for decorator

And now, my git log is nice and tidy!

[[email protected] tmp_blog]$ git log
commit 477232a042c308fff5e771757616130603207d85
Author: Adrian
Date: Mon Apr 6 15:33:54 2015 -0400

Added tmp.py with a decorator

decorator has awesome decorator-functionality


commit 34eeee492343aad2936d1b89eff92ee04b818aef
Author: Adrian
Date: Mon Apr 6 15:27:53 2015 -0400

initial commit with README

By Adrian Cruz | Published April 6, 2015, 7:56 p.m. | Permalink | tags: git, source control management

Fighting Procrastination With Time Management

The Time Is Now

Now is always the best time to get something done and out of the way. Obviously, this means if there are no blockers. Blockers here are major tasks that take priority over the task you are trying to schedule.

I used to find myself saying to myself, "I'm going to get {insert personal project here} done this year". And often times, I'll push it aside and not set aside enough time to even start working on it! I'm sure we're all good with our work projects because we have responsibilities to hold up to --at least, I hope you're all good with managing work projects! But, let's explore our productivity outside of the workplace.

Non-work-related Technical Projects

As any passionate technologist, I love exploring and learning new things. Obviously, one way to feed this fire is to pick up a personal project. Want to learn a new programming language? Want to see what all the fuss is about that database system that you heard about? Well, why don't you go ahead and start poking around with it? "Work is busy!" Yes, trust me I know! "My children take up a lot of my time!" Okay, that's a tough one, but not too difficult. "So, how", you ask? A bit of time management magic of course!

Cut Some Fat and Get Into a Routine

I hate to sound like one of those personal trainers selling 10-minute abs, but eh, whatever. Hopefully, you'll get the point!

Cutting the fat is cutting out those unwanted time killers. Does watching that re-run of {insert television show here} do anything for you? Outside of entertainment, probably not. The time you can pick up from cutting down on TV time is amazing. If you really need some of that TV time (we all do), you can reward yourself with it after you've done X amount of productive work.

Start a routine! Try and start a habit of slicing up parts of your day to work on your project. Take for example, I set aside roughly one hour after work, 2-3 times a week to get out of the office and find a cafe to cowork at. Yes, there are some weeks where work is horribly busy and I won't do as much personal work, but you get the point; you're slicing up your time to find an hour here and there to get in the groove of your project.

A small tip from me: coworking in a cafe works wonders. If you're like me and catch yourself getting out of focus at the privacy of your own home (Youtube playlists, online shopping, etc.), working in a cafe helps out because it gets you out of your comfort zone (literally) and makes you more aware of your surroundings. So for instance, I don't want to be that guy who is watching some cat video on Youtube in a public place (or maybe sometimes I do).

Make Small Attainable Goals

Smaller, means greater chance of feeling productive. Take for example a goal of, "building a web app". That can be thought of as a pretty big task and you may lose focus along the way. Let's still keep that goal in mind, but when you find a slice of time, have a smaller attainable goal in mind. So, you're taking one hour after work; in that hour, a simple goal for me would be something like, testing out a framework you think you'd like to use. It's as simple as that as long as you're heading towards your ultimate goal.

Do What Works For YOU

I'm sure you've found yourself saying, "this won't work for me, because of X". Well, see what does work for you. This isn't a static formula that you can use out of the box. Working at a cafe works for me because well, they're pretty much everywhere close to my work; maybe the library is what works for you. All I'm saying is that with a little bit of self-motivation and time management you can be more productive with work, personal work, et cetera.

Cheers!

By Adrian Cruz | Published Nov. 3, 2014, 5:05 a.m. | Permalink | tags: time management

Julython 2014 Recap

Julython 2014 has come and gone. I hope everyone had a blast, I know I did!

A Month of Hacking In a Nutshell

Let's take a quick look into what was worked on in July:

An Opportunity to Learn, Build

I like to use Julython as a very good excuse to learn something new or learn something more about. In this passed July's case, I have been toying with the idea of learning SQLAlchemy, and this was a perfect excuse to do so.

Take a look at my Slidedecker repository and you will see that I added SQLAlchemy to it. Obviously, I wanted to learn more about it first, so I also added the tutorial to my Julython projects. But I really wanted to learn by example, so obviously working on your own personal project is the way to go!

PyPI Contributions

Both bump and MPPyResponse are packages available on PyPI.

bump is a fork of the original that I use to do version bumping. I had a need to do version bumping for release candidates or beta candidates and that functionality was missing, so I added that in.

MPPyResponse was created out of sheer humor. A friend of mine jokingly asked me to create an application that responded with a random Monty Python quote; no problem!

Obviously, with it still being Julython, I wanted to learn something new while still having fun, so with MPPyResponse, I started that project off with cookiecutter. It is truly a fantastic little package for starting off your own little package. I highly recommend it if you need a little boilerplate to get your projects going!

Summary

In summation, Julython for me is really just an excuse to learn something new in Python while having a little fun. Yes, sharing code and watching myself on the leader board are awesome too, but all in all, contributing to a month-long event of hacking is really just a wonderful thing!

Until next time! Cheers!

By Adrian Cruz | Published Aug. 6, 2014, 1:51 a.m. | Permalink | tags: julython, opensource, python

Stand-ups and Bikesheds

I've been hearing far too many stories about folks having their daily stand-ups take too long. So, I feel compelled to write about stand-ups and how to keep them brief.

Full disclosure: I am not a PM nor a Scrum Master; I am an engineer and my stance on stand-ups is viewed as an engineer solely.

Timebox Your Stand-ups to 15 Minutes

If 15 minutes is not enough time for you to get through your stand-up, then something is wrong. As an engineer, you have three main questions you will need to answer:

  • What did I do yesterday?
  • What will I do today?
  • Is there anything blocking me?
That's it. Done. Go!

If you are having lengthy discussions about every little thing you mention during your update, then that is why your stand-up is taking too long. Stop that. Just remember to stick to those three questions and anything more than that should be discussed outside of the stand-up. Try and be respectful of other people's time. If you are discussing something at length, that is time taken away from another person's updates, which will make you go over your allotted time, which means everyone at that stand-up now has less time away from doing actual work!

Painting the Bikeshed

"Painting the bikeshed" is a phrase that comes from the BSD mailing list and it could possibly be why your stand-ups are running too long. If you have folks that give their feedback for every little detail of someone else's update, then send them that bikeshed link. Once again, I cannot stress this more, discussions that are thought of as quick, add up after time.

By Adrian Cruz | Published July 18, 2014, 3:48 a.m. | Permalink | tags: agile, scrum

Py-Closure: A Python Client for Closure

I made a little command line utility to assist in minifying javascript files. It uses Closure Compiler to compile. I've been using the web app and needed a way to automate the minification process; this command line utility is just the beginning of that process.

What can I do with it?

Well, if you use Closure Compiler already I'm sure you have always wanted a way to streamline your minification process. This is really just a piece of that. For example, you can probably add this to your build process in Jenkins to minify all javascript files within your code repositiory.

But, there are a bunch of other asset minifiers I can use!

There are, and I actually was looking into using Grunt. Well, I have been busy with this new project and just want to keep the ball rolling. So, I'm sure that I will revisit this minifying process again in due time.

So, where's the code?

Sure, it's here on my GitHub. It's short and sweet and super simple. I'm actually going to fork this off and use it similarly at work. Anyhow, I just thought I'd share. Cheers!

By Adrian Cruz | Published May 7, 2014, 2:35 a.m. | Permalink | tags: javascript, opensource, python