what tag is this commit in?

Thanks to jbowes for saving me time with git. I had a commit and wanted to find out what tag it was in. I tended to do the opposite, given a tag is this commit in it. And boy did I do it the hard way:

git checkout TAG
git checkout -b TAG # assuming there wasn't one already
tig # search for the commit in the list

That was cumbersome and a bit error prone. Now with a simple command I can find the tag more easily.

git describe --contains COMMIT_SHA

Setting primary display

When at home I hook up the laptop to an external monitor. For the most part it works great, plug it in and it works. I want the external monitor to be the primary. Pretty simple with xrandr --output DISPLAY --primary so I adapted my vij command to list out the monitors and present the list to me.

#!/bin/sh

monitors=$(xrandr | grep " connected " | awk '{print $1}')
matches=$(echo $monitors | gawk '{print NF}')

case "$matches" in
    0)
       echo "No matches found"
       show=""
       ;;
    1)
       show=$monitors
       ;;
    *)
       echo
       echo "Multiple matches found..."
       i=1
       for option in $monitors
       do
          echo "$i: $option"
          i=`expr $i + 1`
       done
       echo "q: Quit"
       echo
       read -p "? " ans
       if [ "q" == "$ans" ]; then
          show=""
       else
          show=$(echo $monitors | gawk '{print $'$ans'}')
       fi
       ;;
esac

if [ "" != "$show" ]; then
   xrandr --output $show --primary
fi

When you run the script this is what you see:

$ bin/prim 

Multiple matches found...
1: LVDS1
2: VGA1
q: Quit

? 

Gnome 3 why do you hate me?

So my Gnome 3 (gnome-shell, Fedora 18) went to screensaver. When I unlocked it this is what my desktop looks like.

lockup

How do I get out of this? My machine is running fine. I can ssh into it and it’s running normal but I can’t interact with the desktop. Quite annoying.

Gnome 3 and themes are a disappointment

Getting a nice dark theme on a Linux desktop is probably one of the most difficult things I’ve had to do on a computer. I can install a machine from scratch, get virtualized systems working, connect to a SAMBA share, even get my Linux desktop to talk to a network printer. But can I get a dark network theme across the board? No way!

I recently upgraded from Fedora 16 to Fedora 18. Well not really an upgrade, more of a fresh install of Fedora 18 but kept my existing home directory. I enabled dark themes using the Gnome Tweak Tool. I thought this would take care of it but it only seems to work for some applications: Evolution, Nautilus, Gnome Terminal all seem to look just fine. But anything not included with Gnome 3 looks like rubbish.

Here’s the Gnome Tweak Tool. It looks pretty nice in a dark theme.
theme-tweaktool

As does the Gnome Terminal, especially with the transparency on the window.
dark-terminal

But any other application is horrendous. Checkout Google Chrome on the same machine.

theme-chrome

And Thunderbird is also a mess, I was able to get the message window be white on black, but there is no easy way to change the look and feel of Thunderbird. All of the themes are ‘cutesy’ trying to add splash graphics and what not. See Thunderbird themes for examples.

theme-thunderbird

And XChat is unusable at the moment with the white text on white background in the text entry box.

xchat-white

I’ve gotten to the point where I gave up on Thunderbird and XChat and started using mutt and irssi since the terminal theme works. But I have to say mutt is ok but I prefer Thunderbird’s folders and notifications. irssi is actually quite workable so if I can’t get the themes fixed in XChat I can live with irssi.

But this really shouldn’t be that difficult, why do app designer think people want whitewashed apps, it’s 2013 and we still can’t get themes working.

</rant>

Apply github pull requests as patches

Our team uses Github’s pull requests as a code review process, which requires a fair number of requests that need to be tested. Github has a really cool feature where if you put the .patch extension to the url it will show you a diff that can be passed to git am.

So given a pull request 162 (
https://github.com/candlepin/candlepin/pull/162
) you can use curl to download the patch and then pipe it to git am. Once you’re done reviewing, simply revert your branch back using git reset --hard origin/master.

I added some functions to my .bashrc for the projects I review most often, here’s the snippet:

# apply the given pull request from the given project as a patch
# arg: project (i.e. candlepin/subscription-manager/etc
# arg: pull request number
__github ()
{
    curl https://github.com/candlepin/$1/pull/$2.patch | git am
}

# apply the given pull request for candlepin
# arg: pull request number
cppull ()
{
    __github "candlepin" $1
}

# apply the given pull request for subscription-manager
# arg: pull request number
submanpull ()
{
    __github "subscription-manager" $1
}

Summary

Cleaning up failed system delete in Katello

Some how I got my CloudForms SystemEngine into a weird state. I unregistered a consumer while simultaneously removing it from the Katello UI. This caused a race condition because the UI got a 410 GONE error from Candlepin and it didn’t remove it from its database. Clearly a bug but still that left me in a state where the Systems page would show the 410 ERROR and leave me with a spinning cursor.

As this was simply a test setup I could’ve just reinstalled. But I wanted to know how this works. As you know Katello is made of many parts: Pulp, Candlepin, and Foreman.

My particular installation didn’t have Foreman, so that left: Pulp, Candlepin, Katello proper, and Elasticsearch. Since we were getting a 410 from Candlepin that means the consumer was already gone from that database

cp_consumer

table.

First, I removed the system from Katello’s database.

# psql -U katellouser katelloschema
katelloschema=> delete from systems where id = 1;
katelloschema=> commit;
katelloschema=> \q

Then I removed the consumer from Pulp:

# mongo
MongoDB shell version: 1.8.2
connecting to: test
> show dbs
admin	(empty)
local	(empty)
pulp_database	0.203125GB
> use pulp_database
switched to db pulp_database
> show collections
...
consumers
...
> db.consumers.remove()
> 

What in the world did you just do? :) We can see that pulp uses the

pulp_database

. And that one of the collections was

consumers

. Running

db.consumers.help()

revealed there was a remove method. In my case I only had one system so I just did

db.consumers.remove()

. But if you have more you’ll want to specify the key:

db.consumers.remove({"_id":"62d61426-3cf9-4afb-bc3b-e0f696950adc"})

. Ok we’re done. Let’s go checkout Katello again.

UGH Still shows spinning cursor. So what else could be pointing to the fact that we had a system? Elasticsearch which is the search engine for Katello. That just needs reindexing.

# cd /usr/share/katello
# rake reindex
Search Indices cleared.
Re-indexing ActivationKey
Re-indexing Changeset
Re-indexing Filter
Re-indexing GpgKey
Re-indexing Notice
Re-indexing Organization
Re-indexing Provider
Re-indexing Role
Re-indexing SyncPlan
Re-indexing System
Re-indexing TaskStatus
Re-indexing User
Re-indexing Repositories
# 

Ok let’s try one more time. Visit your systems page in Katello and now you should see that there is no longer a spinning cursor, but a blank list of systems. This is what I expected. YAY!

TRENDnet Powerline Adapter configuration

Since we’re selling our house, we kind of had to reorganize the network equipment. I had a place where I didn’t have a network port. I got the TRENDnet 200 Mbps Powerline Ethernet AV Adapter Kit TPL-303E2K.

They are SUPER FINICKY to install. Requiring a damn Windows utility to configure. I tried using the documentation and TRENDnet support site. None were helpful. But thanks to this Amazon shopper was able to get them configured. Click here for full comment.

Basically, if you followed the documentation you probably hit the RESET button. That means you will have to make them both local adapters and reset them using the utility.

In my experience, after the reset, neither unit could be recognized as the remote unit. What seemed to fix that was connecting each unit as the local, and using the privacy tab in the software to configure each to the local network. Perhaps the “factory default” network name is not the default software network name? I don’t know. But finally, the remote unit was again recognized. At that point, I had to use the password-within-seconds trick to get the remote unit recognized again. And at that point, things worked. Sheesh.

Once I did that, I was able to see the remote adapter. YAY! Entered the password. Not accepted. BOO! Back to the Amazon review, I saw that you have just a few seconds to enter the password.

I realized that the unit had only a few seconds in which the power light wasn’t blinking. So, I had the password entered in the software’s dialog box, and plugged the remote unit in, and hit enter to try the password ASAP. Finally! Password accepted. Once the password is accepted, you can pretty easily move the unit to other outlets

Had one of my kids go to the other room to unplug it and yell when they saw a light. :) Works great now. Printer has now been relocated to the bonus room. Thanks for Amazon reviews to help solve technical issues :D