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

Brick and Mortar stores

Usually I’m an online shopping kind of person, but there are times I need the item today. While Amazon Prime can get it to me next day,  that’s not always good enough. Here’s what I think every brick and mortar store needs to do to compete successfully with online retailers like Amazon.

I want to be able to buy *ANY* item you carry online and pick it up in the store, I’m not interested in WEB ONLY products or products you don’t even carry that are sold through other vendors. So far the best buy and pick up in store experience I’ve had has been with Sears. I take my receipt in, scan it and 2 minutes later a guy comes out with my goods to put them in my car. Unfortunately, Sears suffers from the WEB ONLY or products they don’t sell problem which sucks. One of the worst  in store pickup experiences comes from Lowes hardware. They take FOREVER to get the item. Sometimes having to call several times to get someone to go retrieve it. This summer I went in to pick up a range hood for the kitchen, it took 20+ minutes before they got the item. That’s just ridiculous, I even offered to go get it myself.

Another thing that brick and mortar stores suck at is SHIPPING items from their site. We recently orders some items from Kohls, let’s just say it’s been more than a week and I still haven’t gotten all of the items :) They take way too long to ship items or their shipping prices are more than the actual items, like IKEA. They charge $249 to ship in NC for a $170 desk, grant it they have an excuse furniture is heavy. Still we ordered a TV cabinet from Amazon and got FREE shipping on it, like this TechCraft credenza. That was one heavy box and yet it was FREE to ship. So between high priced shipping or slow shipping, brick and mortars have a long way to go.

I realize that brick and mortars make their money by having consumers wandering through the store so they buy more, but I’d argue you’d get more people to come in if they could see you have the item, and be able to purchase and pickup at the store. It’s a sale they probably wouldn’t have had anyway.

And yet another thing is INVENTORY. Why is it so hard in 2012 to have an accurate inventory accessible online? I went with a friend recently to Radio Shack to pickup an item that online showed In Stock only to have the store be out of stock. Really? have we made no advances in technology to keep track of inventory?

For now, unless I need the item TODAY, I’ll stick with shopping online at Amazon, Crutchfield, Newegg, and Monoprice. Maybe one day, hopefully before they go out of business, brick and mortar stores will figure out how to compete effectively with online retailers.  Happy online shopping folks!

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