reword commit message in git

Every once in a while, I’ll make a mistake in my Git commit message and will need to go back and fix it. You would think rewording your message would be more intuitive, but nay.

Assuming your most recent commit was the problem (otherwise you would change the number to indicate how far back the commit goes):

git rebase -i HEAD~1

You’ll see something similar to the following:

Git Rebase Example
Example of a git rebase for rewording a commit message. NOTE: I am using vim here, but your default editor should come up.

The next thing you would do is change the word pick to the word reword or even r would work, and touch nothing else. Save and exit.

Again you’ll be presented with your editor screen, this time with the commit message to be changed:

Git Reword Commit Example
Example of a Git Commit Reword editor. Here, you’d change the commit message to reflect whatever changes happened for the commit.

Update the commit message here, then save and exit.

That’s it for a local repo. If you’ve already pushed this upstream, you’ll have to force push your changes or the remote repo will reject them:

git push origin [branch-name-here] --force

And that should be it. Of course, you should always be extremely careful when rebasing and then force-pushing to origin as you can easily overwrite new changes, and wipe out proper git commit history.

i am replacing evernote with vim + markdown

Back at the beginning of March, I was discussing Vim with a couple of friends and realized I’d stopped pushing myself with it. I read around and apparently this is a known thing — people dabble in Vim, but get to a certain level and just sort of stop learning but still internally consider themselves wizards, despite being far from it. So I decided to jump back in.

Honestly, there wasn’t much thought or planning behind it. I’d tried switching away from Evernote to other apps that never seemed to cut it. There was always something lacking, or maybe they were even too similar (Bear is amazing, BTW). I actually can’t quite put my finger on quite what was wrong, but even writing in Sublime felt off.

So I combined my need to become better at Vim with my need to replace Evernote 1, and it’s been working quite well.

Evernote, of course, is just awesome. I’m sure you could use it for a lot more but I personally use it for notebook functionality, tagging, search, backups, image support and most importantly, my very verbose notes. As it turns out, it’s not easy to replace all that functionality with just another app and running some kind of huge import/migration is a real pain in the ass — one that I’ll have to take care of at some point for Markdown. While I haven’t nailed down the exact steps to perform the migration, the rest has really fallen into place with my current flow:

– Notebooks = Folders (nested as much as you please).
– Tagging = File system tags (macOS supports this natively).
– Search = ag2/grep (all from within Vim, mind you).
– Backups = I keep everything under ~/Documents/Writing/ (macOS backs this up automagically, but you could do the same with Dropbox).
– Image support = Markdown supports images just fine and dandy.
– Notes = Markdown files, of course.

Time will tell if it continues, but so far, this has worked extremely well for 95% of my use cases3. Fringe benefits such as being visually pleasing while minimally distracting are also of note!

Moving forward, I might be inclined to move beyond just using Vim as my primary note taking app and even try to use Vim as my primary IDE, but I still have my doubts about replacing PHPStorm. There is so much I love about it that I’d need a good reason to do away with it besides it just being a memory hog.

1At one point, Evernote changed its privacy policy to allow employees to read users’ notes and such. Basically a complete privacy violation, and then they went back on it. But who knows what other crap they’re trying to sneak past us?

2I could probably write another post about how awesome Ag (“The Silver Searcher”) is, but I’ll just leave you with this: on a huge project folder with lots of huge files and subfolders, a recursive grep for the word “backup” took about 16.5 seconds. The same search in Ag? 0.21 seconds (recursive/case-insensitive). I don’t know what kind of black magic it uses, but I’m on board.

3I don’t foresee it being a huge problem, but my last unsolved mystery is really the final export from Evernote to Markdown (while maintaining folder/tag structure);
could be a pain but we shall see.

a few great shows

Note: the following post discusses Hannibal, Rick & Morty and The Path. I don’t believe there are any real spoilers in here, but just a fair warning.

So I just finished breezing through three really decent (in my opinion) shows I can’t believe I didn’t see previously: Hannibal, Rick & Morty, and The Path. Mainly, I was blown away that no one had really made a big stink over me seeing either Hannibal or Rick & Morty. The Path, I tried on my own but I haven’t heard anyone really talking about it. I find that pretty strange. Of course, these shows aren’t exactly “Lost” in both their build-up, intensity and mystery, but they do each possess a very engaging characteristic.

Take Hannibal, for example. It’s easy to think of a murderous sociopath as sort of one dimensional — in The Silence of the Lambs, Lecter seems almost like a cat who has found a new plaything in Clarice Starling. It seems like he’s just toying with her for the sake of the game itself, only trading little bits of what she’s after in exchange for personal details. Sure, that’s interesting and Lecter is terrifying as a character because he seems to be able to smell where someone has been before his lizard brain even detects whether they’re lying about a particular question. That’s already an interesting character. A cat-like creature wearing human skin that will bare his fangs the moment someone he has distaste for drops their guard.

The Hannibal Lecter of the Hannibal TV series, on the other hand, seems purely lizard like. The things hinted at in other movies on the character are shown in more vivid detail in the series. We get to see what Hannibal’s love interests are like. Yes, he’s a cannibal — unacceptable — but putting that aside for the sake of good television, just watching the way the character goes through his “process” in everything from his therapy sessions, to the meticulous way he prepares all his food, down to the ease with which he plays people. Again, to Hannibal, everything is still a game but there is such a style to him that it almost makes you question who the real hero is at times. You can almost begin to see the world through his eyes and he really, really hates rude people and is endlessly fascinated by human monsters. In a sense, he is their savior. And again, putting aside the eating of folks, it’s hard not to want to emulate the way Hannibal lives his home life. I don’t know who they’re consulting to dress these sets, but they’re doing a fine job.

Anyway, I’m late to the Hannibal train but I really do hope they carry on with another season. I’ve read rumors saying it’s possible, but there’s nothing set in stone yet. If you catch wind, please let me know.

Moving on to Rick and Morty, a friend of mine mentioned it in passing a while back and I kind of put it in the back of my mind but then decided to dive in after reading a Reddit post on the subject. Actually giving it a chance was a great decision, mainly because — despite the show being crude and aiming for funny most of the time — a lot of the plots are just very interesting and I find myself having a lot of, “Why didn’t I think of that?” moments, which is great. I can’t wait to see what else these guys come up with.

Next is The Path. Sure, it’s a drama. And yes, I may have used the gateway of Hugh Dancy from Hannibal as a sort of divining rod for what to watch next, but I actually got really interested in where this show would go. Cynically, I know the show isn’t going to really shock me with anything I haven’t seen before, but who cares? To me, the really interesting part is that it seems to be show that’s not taking a side on cults (movements?); it doesn’t seem to be a tongue-in-cheek message about people in Scientology or whatever. For me, it seems to be showing the ugly and the beautiful along with it. That being said, am I thinking of ever joining something similar? Nope. Not even close. But that doesn’t mean I don’t find it interesting.

It’s so easy to sort of blanket everyone in a “movement” as sheep who refuse to accept reality as it is and choose a better version to believe in just because life is easier when all the answers are provided, but obviously there’s more to it than that. Within the movement, everyone remains human and they don’t want to kill everyone else, but they definitely consider themselves otherly or separate. In fact, people in the movement want to help the people in society that no one else wants to look out for and that society just sort of sweeps under the rug. I think that’s the really interesting part. In helping the weak, they become strong. That echoes some truth about other religions/movements in reality as well: people operate within the framework of the movement, but can’t run from all it means to be human. Particularly when they’re living right alongside their trangressing counterparts.

There are some emotional moments along the way with this show, too. People dealing with losing their faith, or in outsiders being introduced to the weirdness of anything vaguely resembling a cult. It doesn’t hurt that it has Aaron Paul (Jesse Pinkman from Breaking Bad!) and Hugh Dancy in it either.

I’ll be looking forward to the next seasons of each of these shows, particularly Hannibal and Rick & Morty.

raspberry pi door bell project: part 3

The good news: I have everything wired up outside and it works (mostly) well, even in rain!

The bad news: Pi stopped detecting the doorbell button press, it’s been raining and I haven’t cleaned up the wiring yet.

Luckily, today looks pretty clear so I feel pretty good about going outside to do some re-wiring on the door bell part of the project. In effect, this means I’m going to have to remove electrical tape and then re-apply it (ugh, so time consuming). But at least I didn’t solder it (yet!).

As for what does work:

  • Open/close sensor
    • Open events:
      • Sonos speaker says, “The gate is now open”
      • Push event via Prowl to our phones: “The gate is now open”
      • Gate plays random sound through 3.5mm audio jack (not yet hooked up but confirmed through headphones!)
    • Close events
      • Sonos speaker says, “The gate is now closed”
      • Push event via Prowl to our phones: “The gate is now closed”

So all of this is off to a great start and will be in an even better place once I get the SkyBell working fully. To do that, I not only have to fix the wiring that detects the doorbell button press again but I also have to improve the WiFi signal that reaches it because it’s slightly spotty out there to the point where it just refuses to connect. That’s okay though, because I’ve been planning on adjusting the wireless signal I get around the house anyway.

This weekend, I attempted it with the Linksys RE1000 repeater, but with little success. For some reason, the devices that connect to it only have local network access and can not see the Internet despite all my efforts. I’m not shocked though; I’ve had problems with the N-network portion of my Linksys E3200 router for a long time, so I’m guessing there’s something amiss with the hardware of the actual router.

I’m thinking I might replace the whole setup with the ASUS RT-AC68U. I found it a while back and recommended it to a friend. He recently purchased it and has nothing but positive things to say about it, so I’m heavily considering it. I figure I don’t need much of an excuse as my work fully depends on a healthy Internet ecosystem in the house. Plus, we have more and more devices that are talking to each other now.

— Update 4/26/2016 —

So I left off on this post on the 11th and unfortunately, I still haven’t made actual progress on this project. The problem turned out to be with the Pi not detecting the right voltage from the SkyBell; since I am using a simple photocoupler, this meant I wasn’t able to read the door bell button push. After spending an afternoon diagnosing the problem outside, it turned out that instead of dropping the voltage to 12V like it had been doing inside the house, outside it was dropping it to only 4V! In other words, the photocoupler LED would never turn off, even with added resistors.

Figuring I had just wired everything wrong, I decided to bring the unit back inside to test and finally get right. I was able to get it working again but then as soon as I introduced a length of CAT5 cable in between the SkyBell and the Pi, the problem resurfaced. Apparently it wasn’t bad wiring but the cable itself was acting like a big resistor (most likely because the individual wires are so thin).

So now the plan is to somehow detect voltage on button press. I can do this either by soldering said wires directly to the corresponding places directly on the PCB of the SkyBell or by adding an analog to digital converter (ADC) onto the Pi so I can literally read the drop from 10v to 4V. That has its own problems that I am currently investigating, but of course I’ll update once I figure it out.

Concurrently, I have been researching other Wi-Fi Door Bells and have found that the SkyBell HD supports IFTTT (which would allow me to get around this whole mess), but that would mean selling off the 2.0 version or keeping it and just eating the $150. Either way, I can’t believe the company would shaft everyone who bought the 2.0 version, but whatever. I’m now investigating SkyBell alternatives for my smart setup. I mean, I want to eventually build my Home API which would mean interfacing the door bell with smart locks and the way things are going with this particular unit, I am not too hopeful about the future.

I’ll update once I figure out my next step.

raspberry pi door bell project: part 2

Success! As of last night, I officially got the doorbell detector working. I can’t tell you what a great feeling that is. Ah, to see your weird ideas come to life.

If you haven’t read part 1 of the series on this project, I suggest you do that just to see where I’m coming from here. Just to recap, the idea is this:

I want to install the SkyBell on the front gate (which we lock sometimes) so we get all the features of the SkyBell, but also tap into the signal from the doorbell so that I can fire events when it happens. Like playing a sound/song/voice inside the house on the SONOS, for example.

To do that, I did a ton of reading and what ended up being the most simple solution was using a little device called an optocoupler. Oh the things I’ve learned on my first Pi project.

What an optocoupler is, put simply, is a way to keep electrical signals separate while still allowing them to communicate. Sort of like that plexiglass barrier they use in prisons to separate the probably dangerous people from the presumably less dangerous people. Inside the optocoupler is a simple setup. On one side — the “dangerous” side you’re signaling from — you’ve got your LED. On the other side, you’ve got your photoresistor (a device that increases resistance with brighter light). All of this is sort of glued together with an epoxy and put inside of an opaque casing with some leads sticking out on either side to provide power and ground.

Credit: WikipediaThis diagram (left) shows all of this happening. On the left side is the LED sending light when there is signal over to the reader/collector on the right side. In my use case, I was able to wire the 12-volt “hot” (non-dashed) input to the LED side (12 volts resisted down to 1.2 volts via three 220-ohm resistors), then attach “ground” (dashed).

On the other side, I wired pin 3 to 3.3 volts from the Pi with another 220-ohm resistor in-between. Then wired pin 4 for GPIO 17 on the Pi. Now one thing you might notice here is that I didn’t wire anything to ground on the Pi, and that’s because I learned about a magical thing called a pull-down/pull-up resistor. Effectively, there are built-in resistors on GPIO ports that you can activate through code.

The reason for the existence of these things is, apparently, because physical connections aren’t either “off” (0) or at varying degrees of “on”; they float! So it’s hard to get a solid reading without assuming an on-state (pull-down resistor) or assuming an off-state (pull-up resistor). Any way you want to think of it, these built-in resistors are a huge space saver and allow for much simpler set-ups.

Oh, and I ended up going with the Sharp PC817 optocoupler/opto-isolator:

Sharp PC817 Optocoupler/Opto-isolator

Optocoupler Diagram, Credit: Wikipedia

To make a long (and very boring) story short, it means I can “read” a 12 volt signal safely into a 3.3 volt input. And that’s exactly what I did:

ASCII Raspberry Pi Doorbell Design

This is a crappy diagram and actually does not match the final “masterpiece,” but it certainly conveys the general idea. I’ve got a 12 volt DC power supply that provides current at 1 amp. Originally, it had a barrel connector (the round kind you stick into all kinds of devices), but I cut that bit off and was left with two wires — one hot and one neutral. As the people at SkyBell recommended, I spliced a 10-ohm/10-watt resistor onto the end of the non-dashed adapter wire and, as you saw in the previous post, hooked that up to the SkyBell (the left portion of the above diagram). I tested this setup with my multimeter and it worked fine, even though I had the positive/negative leads switched. Ultimately, I knew I was seeing the remaining 11-volt output drop to around 0 volts for about 8 seconds when the doorbell was pushed1.

Once I got my Raspberry Pi delivered, I had it set up and hooked up to a break-out board within an hour. I didn’t have a ton of time to play with it, but I was able to set up a simple push-button setup to light up a single LED (just to test it).

The next step was to hook the doorbell up using the photocoupler to actually read the voltage as I’d seen in bits and pieces around the web, but the trouble is that I was freaking out internally. I really did not want to break the SkyBell after forking over $100 for it, and I knew just enough about circuits to be dangerous but not effective. So I bothered my buddy Justin a lot, then to mix things up, I started bothering the people of #raspberrypi on FreeNode (great bunch of people, by the way). After running through the same scenario a number of times, it started to dawn on me that I didn’t need the SkyBell in the mix at all to test whether the drop from 11 volts to 0 volts was readable on GPIO.

So I removed the SkyBell and started hooking the DC wires (with 10-ohm/10-watt resistor) straight onto my breadboard, through the optocoupler, and on the other side, I hooked up 3.3 volts of power to the third pin of the optocoupler, and GPIO pin 17 to the fourth pin.

After some careful adjustments and clamping connections together using paperclips and tiny binder clips, then plugging some code into the Pi to test for high/low signal on the port, I actually saw some success! At that point, I plugged my SkyBell back in and gave it another test. After some more futzing with bad connections (these are all temporary), I had it ready and you can see for yourself what happens:

I actually let this program run overnight and left everything connected as sort of a burn-in test. When I woke up, everything still worked perfectly. Oh, and I will post the current code for but first, let me show you an overview of the (really crappy/ramshackle) setup:

As promised, here is the code in all its glory. Please note two things. One, the pull_up_down bit; this is something I may switch back over to use gpiozero since it looks so much cleaner. Two, the gist (which will be versioned as I make updates) is available here.


import urllib2
import time
import RPi.GPIO as GPIO
from time import sleep

PIN = 17
GPIO.setup(PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
coupler = True
couplerLast = True
startTime = time.time()
elapsedTime = 0

sonosPath = urllib2.quote('/sayall/there is someone at the door')
sonosUrl = '' % sonosPath

print sonosUrl

        while True:
                if GPIO.input(PIN):
                        coupler = True
                        coupler = False

                if coupler != couplerLast:
                        if coupler:
                                elapsedTime = time.time() - startTime
                                print "Elapsed time: %01.2f" % elapsedTime
                                startTime = time.time()
                                print "DingDong! Sending to SONOS..."
                                req = urllib2.Request(sonosUrl)
                                try: urllib2.urlopen(req)
                                except urllib2.URLError as e:
                                        print e.reason
                        couplerLast = coupler

After all this was set up, I had to move on to the next step (which, if you’ve looked over the code is already present).

To get that going, I installed an excellent library that is still in beta but worked AMAZINGLY well once I had the right configuration: node-sonos-http-api. More or less, this is all I had to do in order to get it installed:

cd ~/Desktop/
git clone
cd node-sonos-http-api/
curl | bash
source ~/.bashrc
nvm install 4.0.0
nvm alias default 4.0.0
npm install

Then, to configure it for text-to-voice, I had to set up an account at VoiceRSS, then create a settings.json file and put my VoiceRSS API key in like so:


Once I did that, I was able to start it up and leave it running even if I log out:

nohup npm start > node-sonos.log &

Assuming your SONOS network is discoverable on the same WiFi network your Pi is connected to, what you’ll notice (or at least, what I saw) from the output of the node-sonos-http-api server was that it immediately detected the SONOS, found my “rooms” (living room), and was ready for use right away. If you have any issues with this setup, I suggest you read over the documentation provided on the repo. In fact, since the repo is changing all the time, I suggest you keep an eye on it either way if you plan to use it!

Now that I have it set up to work off of the SkyBell button press, the script above basically tells the SONOS to say, “There is someone at the door” in a British accent and it does so while temporarily pausing the music that’s playing. How cool is that?

What I have in store next is a magnetic sensor for the gate itself. When that opens/closes, I plan to play wav/mp3 files out of the audio-out jack of the Pi. What will it play, you wonder? Halloween sounds on Halloween, Christmas sounds around Christmas, and random other stuff the rest of the year! That’s the idea anyway. I’ll keep brainstorming.


  1. The 8 seconds is intentional from SkyBell’s end when the “Digital Door Chime” setting is enabled from the SkyBell app. If that’s turned off, the “low” (0-volt) happens for a fraction of a second.