A Simple Guide to git : For Friends

I’m writing this post for friends that I work with on projects that need a simple guide to using git. The overall process consists of installing git on your system, generating ssh public and private keys, sending me your public key, cloning the git repository (repo), and working within the repo. Let’s get started!

Install git

For Windows / Mac OS X you can just download and install binaries: http://git-scm.com/downloads.

If you are using Ubuntu, open a terminal and enter:

$ sudo apt-get install git

If you are using Mac OS X and you would like a better package manager, you can install macports. Then install git with the command:

$ sudo port install git

Generate your ssh keys

Open a terminal, if you are using a Windows git binary, open the “git bash” program, and enter the following:

$ ssh-keygen -t rsa -C "yourmail@domain.com"

The ssh-keygen program will prompt with you several questions / options. You will need to provide the output location for the keys (should be the .ssh folder of your home directory) and a passphrase to lock your private key. Remember the passphrase because it will be used to unlock your private key when you clone, push, and pull from the repo server.

Generating public/private rsa key pair.
Enter file in which to save the key (/path_to_home/.ssh/id_rsa): [Hit Enter]
Enter passphrase (empty for no passphrase): [Enter a passphrase]
Enter same passphrase again: [Re-enter your passphrase]

The keygen program will generate your public key (id_rsa.pub) and your private key (id_rsa) in the .ssh directory that you specified above.

Open the id_rsa.pub file with a text editor, copy the contents of the file, and send them to me (your repo server administrator) in an e-mail. I will add your public key to the authorized_keys file on our git server.  If you want a quick way to print out the contents of the public key file to the terminal, you can use the concatenate command.

$ cat ~/.ssh/id_rsa.pub

Then just copy the string that was printed and paste it into your e-mail client. Remember, your private key is private! Don’t send it to me.

Clone the git Repo

I will provide you with a URL / directory location of the git repo in the form: git@syllo.com:/opt/git/myproject.git. Just use the git clone command to grab the git repo.

$ git clone git@syllo.com:/opt/git/myproject.git

Change into the git repo’s directory:

$ cd myproject

See what’s in the project (probably files and directories):

$ ls

The Workflow

The workflow consists of updating the git repo to the newest server version, modifying the files in then project, staging the files for commit, and then pushing your changes up to the server. Rinse. Repeat.

Get the updated server version / pull down new changes (assuming you are in the git project’s folder now – you already ran “cd myproject”):

$ git pull

Now you can do some actual work! Edit files, move files, delete files, add files. Remember that git doesn’t keep track of folders, just files. That means if you create an empty directory, it won’t be uploaded to the server. You need a file in that directory.

Take a look at what has changed:

$ git status

Include changed files in the next upload:

$ git add <filename>

Commit changes to your LOCAL repository:

$ git commit -m "enter some sort of meaningful message here about what you just did in the project"

Push your changes up to the server:

$ git push origin master

You need to include the “origin master” the first time you push your changes, but after the first time, you only need to enter the command:

$ git push

To recap, the command workflow is:

$ git pull
# edit files$ git status
$ git add <filename>
$ git commit -m "some sort of message"
$ git push

Misc. Notes

Best Practice

It is often a good idea to not include automatically generated or “build” files in the git repo. If it’s a file that is automatically generated when you run your build command, don’t include it! Try to keep your git repo lean, including just the minimum number of files that are needed to generate the final output.

Committing Multiple Files

You can add multiple files to the local commit by appending the git commit command with “-a”

$ git commit -a -m “some meaningful message”

Deleting Multiple Files

A useful command to remove files from the git repo that you deleted manually is:

$ git rm $(git ls-files --deleted)


Install / Compile pianobar on Mac OS X from Source Code with macports

A lot of people use homebrew to compile pianobar on the Mac. Here is how to compile pianobar using macports.

1.) Install macports: http://www.macports.org/install.php

2.) Open up a terminal and install system dependencies with macports:

$ sudo port install libgcrypt gnutls json-c ffmpeg libao wget

3.) Create a clone of the pianobar git repo. I prefer this method because it will allow you get updates as the pianobar / pandora folks fight each other.

$ git clone https://github.com/PromyLOPh/pianobar.git

4.) Build and install:

$ cd pianobar
$ make
$ sudo make install

5.) Setup configuration file.

$ mkdir -p ~/.config/pianobar
$ cd ~/.config/pianobar
$ wget https://raw.githubusercontent.com/PromyLOPh/pianobar/master/contrib/config-example
$ mv config-example config

Then, just open the config file with your favorite editor (probably emacs) and replace “your@user.name” with your Pandora user name and enter your password. Make sure to remove the pound-sign comments in front of the user name and password lines. Here is an example of what the lines should look like:

user = kevin@kevindemarco.com
password = mysupersecretpassword

6.) Test pianobar

$ pianobar


Building gnuplot 4.6.5 on Ubuntu 12.04 from Source

1. Install dependencies:

$ sudo apt-get install libgd2-xpm

2. Download source code from sourceforge: http://sourceforge.net/projects/gnuplot/files/gnuplot/4.6.5/

Download the tarball gnuplot-4.6.5.tar.gz

3. untar it:

$ tar xvf gnuplot-4.6.5.tar.gz

4. Configure, build, and install.

$ cd gnuplot-4.6.5
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

5. Test it.

$ gnuplot --version

should report:

"gnuplot 4.6 patchlevel 5"

Pallet Wood Chalkboard

Mira and Jenn are brewing kombucha in our kitchen, but they need a way to track the last time they filled it up with water / sugar. So, Mira asked me to make her a chalkboard for the kitchen.

Pallet Wood Chalkboard

Pallet Wood Chalkboard

The surrounding wood is made from pallet wood I found in the trash. The back plate is thin plywood that I also found in the trash. I put a layer of natural wood stain and two layers of polyurethane finish on the frame. The chalkboard was created with spray paint chalkboard.

Wall Mounted Bottle Cap Opener

I bought a bottle cap opener from the Sweetwater Brewing Company a few months ago and finally got around to mounting it on a nice piece of wood. I routed the edges, routed the back to install hidden magnets, sanded it, and finished it. It looks nice in our hallway.

Wall Mounted Bottle Cap Opener

Wall Mounted Bottle Cap Opener

Photos of Recent Woodworking Projects

I finally got around to taking photos of a couple of projects off of my DSLR and uploading them onto my computer.

This is a bandsaw box I made for my niece for her birthday.

Second Bandsaw Box

Niece’s Bandsaw Box

I’ve had this 4′ x 1′ mirror for years since my friend left it at my apartment when he joined the army. It’s had a permanently broken frame, so I decided to finally make a nice frame for it and gift it to my girlfriend for her birthday. I was able to use my new Bosch router to add nice curves to the edge of the mirror as well as the drop in area in the back where the mirror rests on the frame.

Mirror Frame

Mirror Frame


Arduino Uno as a USB HID Interface

I was recently involved with a simple project that involved emulating the functionality of some basic keyboard commands. I decided to try out the Arduino Uno board for the task since I’ve read posts where people used the Arduino for keyboard, mouse, and MIDI device emulation. Unfortunately, many of those posts are very old and aren’t quite right any more. Here are some links to the sites I used to piece together the information in the rest of this post.


These instructions should work for the Arduino Uno R2 and R3. I’m running Ubuntu Linux 12.04. If you are using Windoze or Mac OSX, you can download precompiled versions of whatever programs you need from the previously mentioned links.

1.) Place the Arduino Uno’s ATMega16U2 chip into reset.
This is done by shorting the RESET pin to the GROUND pin on the ATMega16U2’s ICSP header. These are the two pins that are closest to the USB header, as shown in the following image and the video. In some previous posts, it was stated that you have to solder a resistor between two pads on the back of the Arduino, but this isn’t true for the R2 and R3 Arduino Uno version.

The Arduino should be plugged into the computer’s USB port (so that the ATMega16U2 is powered on), then the pins should be shorted for a second or two, and then you need to disconnect the short, so that it can be programmed from the computer.

ATMega16U2's Reset pin shorted to ground.

ATMega16U2’s Reset pin shorted to ground.

2.) Install prerequisites
If you are using Ubuntu Linux, you first need some prerequisites:

$ sudo apt-get install dfu-programmer dfu-util libusb-dev

Download the Atmel USB DFU Programmer (get the tar.gz file) from Source force: http://sourceforge.net/projects/dfu-programmer/files/dfu-programmer/0.6.2/
Untar the downloaded file and build it:
$ tar xvf dfu-programmer-0.6.2.tar.gz
$ cd dfu-programmer-0.6.2
$ ./bootstrap
$ ./configure
$ make
$ sudo make install

With this newer version of the dfu-programmer, you don’t have to worry about patching it for the ATMega16U2, it has already been applied to the newer source code.

3.) Program the ATMega16U2 chip with dfu-programmer
$ sudo dfu-programmer atmega16u2 erase
$ sudo dfu-programmer atmega16u2 flash --debug 1 Arduino-usbserial-uno.hex
$ sudo dfu-programmer atmega16u2 reset

Notice, the main difference in these commands from those mentioned in the previously referenced posts was that I used “atmega16u2” instead of “at90usb82.” To simplify this process, I created a simple bash script that calls these three commands in order and takes a path to the hex file as an argument. You can download this script as well as the usb-serial and usb-keyboard hex files from my github project at: https://github.com/SyllogismRXS/syllo-arduino/tree/master/scripts/dfu

You would call the program script by cd’ing to the scripts directory and executing the program.sh script with a single argument that consists of the path to the hex file to be programed. For example:
$ cd /path/to/scripts/
$ sudo ./program.sh Arduino-usbserial-uno.hex

If the commands return the error string, “no device present,” that means you either didn’t reset the ATMega16U2 correctly, or you are using an old version of dfu-programmer (install it using step 2 above).

4.) Work flow
Now that you can program the ATMega16U2 chip, you can get to work on that USB HID interface. Your work flow will consist of:

  1. Program the ATMega16U2 with Arduino-usbserial-uno.hex. (reset ATMega16U2, then, sudo ./program.sh Arduino-usbserial-uno.hex).
  2. Plug cycle the Arduino.
  3. Program the Arduino’s main Atmel chip with the standard Arduino IDE.
  4. Plug cycle the Arduino.
  5. Program the ATMega16U2 with Arduino-keyboard-0.3.hex. (reset ATMega16U2, then, sudo ./program.sh Arduino-keyboard-0.3.hex).
  6. Test, then go to step 1.

5.) Simple Arduino HID USB Program
The following sketch will simply send the USB keyboard scan code for “R” from the Arduino (acting as an HID USB device) to the computer every five seconds.

/* Arduino USB HID Keyboard Demo
* Random Key/Random Delay
uint8_t buf[8] = {
0 }; /* Keyboard report buffer */

void setup()

void loop()

buf[0] = 0;
buf[2] = 0x15; // letter R
Serial.write(buf, 8);

void releaseKey()
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Release key

If you want to add the ability to send key strokes that make use of the CTRL or ALT keys, you modify the character at buf[0]. For example, to send the keystroke, CTRL+R, you would set buf[0] to 0x01 and buf[2] to 0x15. You can find out more about the USB HID scan codes in the following table: http://www.mindrunway.ru/IgorPlHex/USBKeyScan.pdf

Here is a quick video of me testing the CTRL+R functionality with an attached push button.