git – How to list branches that contain a given commit?

Need to see which branch(es) contain a Git commit? Try these commands!

List local branches that contain a commit:

git branch --contains <commit>

List remote branches that contain a commit:

git branch -r --contains <commit>

List all (local & remote) branches that a commit:

git branch -a --contains <commit>

via git – How to list branches that contain a given commit? – Stack Overflow.

Advertisements

New Home Office & the IOGEAR Dual View Dual Link DVI

I just recently moved back into my house, and a lot’s changed since I was here. Perhaps the most notable difference is that home and work have combined. So, when it came time to configure my home office, I wanted to make sure I had everything I needed to adequately work and play in the same space while also keeping them sufficiently separate.

Let’s talk needs. Two monitors is a minimum for work. Some people like a third display, but it’s give-or-take for me. I find that I’ll be looking at the far-left monitor and not notice something important that’s happening on the far-right. I’m not anti-third display; it’s just not something that I particularly care about. I like two displays for home for some of the same reasons. If I’m learning something, I want to have a page up on one screen while I work on the other. Or, maybe I want to poke away at some code while watching some TV. Either way, two screens makes life better. The old home office had my home and work computers in different rooms because I didn’t have a proper office, but it was time for them to unite.

This union created a dilemma: two computers, three monitors, two keyboards, and two mice. Seems like a perfect job for a KVM, but I was surprised to find that multi-display KVMs aren’t cheap. After a night of research, I decided it would be worth it to splurge and get an IOGEAR 2-port MiniView Dual View Dual Link DVI. On paper, it’s just what I needed. Two monitors, a keyboard, and mouse could be shared between the two computers. The third monitor would be hooked up to a DVR for some entertainment on the side, but it could also be used as a third display for either computer if desired. (I’d change the third display manually using its built-in source selection.)

iogear-miniview

The MiniView is a cool piece of hardware. It’s got some decent weight to it, and the metal case and buttons look nice–essential for a desktop peripheral! I ran into some hiccups hooking everything up, but I think it may have been because I was hot-swapping everything instead of turning everything off like recommended in the user manual which, of course, was not read until after the fact. The functional shenanigans during setup caused the initial configuration to take the better part of 2 hours and was really frustrating. I was definitely feeling some buyer’s remorse and considering sending it back, but I got it working after a few reboots and do-overs.

Okay, initial setup was done. Displays were working; keyboard was working; mouse was funky. I’d read some reviews about issues with wireless mice, so I wasn’t entirely surprised by this. I had a nice gaming mouse, so I decided to just roll with that, but I couldn’t do it. I missed my Logitech Performance MX and had to go back. Fortunately, the MiniView has a USB port to share a single peripheral between computers. I plugged my Logitech universal receiver into it, and the mouse worked just fine. Boom, problem solved.

I was all done, or so I thought. I ran into another problem a day or two later, this time with the keyboard. The “t” got stuck, and even unplugging and re-plugging it in didn’t solve the issue. So, I grabbed a cheap 3-port USB hub that I had laying around, plugged it into the single shared port on the KVM, and plugged my mouse, keyboard, and wireless headphones receiver into it. Now I’m not using either of the KVM’s dedicated USB keyboard or mouse ports, but everything works perfectly. I lose out on the KVM-specific keyboard and mouse commands, but the KVM is front & center on my desk so I probably wouldn’t be learning or using those commands, anyway.

Everything’s been good for another day or two at this point, and so far, so good. I’m feeling good about this configuration and hope it keeps working!

Oh, and if you’re curious about the monitor/computer connections, my two monitors connect to the KVM via HDMI-to-DVI cables. Computer 1 is connected to the KVM using the KVM’s provided DVI+USB cable and a DVI-to-HDMI cable. Computer 2 uses the DVI+USB cable and an additional standard DVI cable. The third display connects to Computer 1 using a VGA cable (Computer 1 only supports 3 displays if one is VGA), Computer 2 using a standard HDMI cable, and the DVR using a standard HDMI cable. I’m generally keeping the third display disconnected from the computers (through their display control panels) and just using it as a TV, though.

Ultimate Guide to Speeding Up ReSharper (and Visual Studio) – JetBrains .NET Tools Library – Confluence

After a few months off, I’ve re-added ReSharper to my toolkit. It’s a little pokey with my current solutions, though. I found some good info from JetBrains on speeding it. up. Enjoy!

Ultimate Guide to Speeding Up ReSharper (and Visual Studio) – JetBrains .NET Tools Library – Confluence.

OCR in OneNote

OneNote is good for a lot of things–like taking notes–but did you know that you can also use it as a quick & dirty OCR? It’s a snap to use, too. Just copy an image from the clipboard onto a OneNote page, then right-click and choose Copy Text from Picture.

copy-text-from-picture

OneNote works its magic and copies the text it finds to the clipboard. Here’s what the image above produces:

File Edit Format View 
I love text! 
Texty, text, text! 
Untitled - 
Help 
Notepad 
Ln2, Col

You can see that it’s far from perfect. I’m not sure why “Untitled -” and “Notepad” aren’t together or why they’re not at the top. It also didn’t do a great job with the text in the status bar, reading Ln 2, Col 19 as Ln2, Col. But it did a good job with the meaty part that I’d actually care about.

Let’s try a more complicated example. Behold, a screen-grab of the lipsum.com Lorem Ipsum generator homepage!
lorem-ipsum

This image has a little bit of everything. There are letters, numbers, columns, different fonts and sizes, and even a background with words! Here’s what OneNote gives us:

Lorevn Ipsuvn 
"Neque porro quisquam est qui dolorem 'psum quia dolor sit amet, consectetur, adpsci vellt 
'There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain 
What is Lorem Ipsum? 
Lorem Ipsum IS simply dummy text of the printing and typesetting 
industry Lorem psum has been the industry's standard dummy text 
ever since the ISOOs, when an unknown printer took a galley of type 
scrambled t to make a type specimen boobc It has survwed not 
only fwe centuries, but also the leap into electronic typesetting, 
remaining essentially unchanged It was popularised in the 1960s with 
the release of Letraset sheets containing Lorem psum passages, and 
more recently with desktop publishing software like Aldus ageMaker 
including versions of Lorem 
Where Does it come from? 
Contrary to popular belief, Lorem psum is not simply random text It 
has roots in a piece of classical Latin literature from 45 BC, making it 
over 2000 years old Richard McClintock, a Latin professor at 
Hampden-Sydney College in V'rgnia, looked up one of the more 
obscure Latin words, consectetur from a Lorem psum passage, and 
gong through the cites of the word in classical literature, discovered the 
undoubtable source Lorem psum comes from sections UllY32 and 
IA1133 of "de Finibus aonorum et Malorum- (The Extremes of Good 
and Evil) by Cicero, written in 45 BC This book is a treatise on the 
theory of ethics, very popular during the Renaissance The first line of 
LÆrem psum, "Lorem ipsum dolor sit amet comes from a line in 
section 32 
The standard chunk of Lorem Ipsum used since the ISOOs is 
reproduced below for those interested Sections T1032 and IAIY33 
from "de Finibus aonorum et Malorum" by Cicero are also reproduced 
in their exact original form, accompanied by English versions from the 
1914 translation by Rackham 
Why Do we use it? 
It is a long established fact that a reader will be distracted by the 
readable content of a page when looking at its layout The point of using 
Lorem psum is that t has a more-or-less normal distribution of letters 
as opposed to using 'Content here, content here making it look like 
readable Many desktop publishing packages and web page 
editors now use Lorem psum as their default model text and a search 
for 'lorem ipsum' will uncover many web sites still 'n their infancy 
Various versions have evolved over the years, sometimes by accident, 
sometimes on purpose (injected humour and the like) 
Where can I get some? 
There are many variations of passages of Lorem Ipsum available, but 
the mayorty have suffered alteration In some form, by Injected humour, 
or randomised words which dom look even slightly believable If you 
are going to use a passage of Lorem psum, you need to be sure there 
ism anything embarrassing hidden n the middle of text All the Lorem 
Ipsum generators on the Internet tend to repeat predefined chunks as 
necessary, making this the first true generator on the Internet It uses a 
dictionary of over 200 Latin words, combined wth a handful of model 
sentence structures, to generate Lorem psum which looks reasonable 
The generated Lorem psum is therefore always free from repetition, 
injected humour, or non-characteristic words etc 
paragraphs 
by tes 
Start with 'Lorem 
ips um dolor sit 
Generate Lorem Ipsum 

Okay, pretty good. It did an admirable job of detecting the paragraphs and columns. Most of the words came out fine, but there were problems with numbers (1500s read as ISOOs) like we saw with the simple Notepad example. There were a lot of small typos (reados?), like dropped periods or a missing letter here and there. The takeaway here is that any decent amount of text that you care about should be proofread. If you’re too lazy for proofreading, you might be able to clean it up a bit by pasting into Word and using its spelling and grammar checking.

Despite its flaws, it’s a really fast, really easy way to OCR just about anything you can get on your computer screen. Take a screenshot using Snipping Tool or something better, paste it into OneNote, and OCR that mamma jamma!

JIRA Plug-In for Greenshot

A couple weeks, I wrote about Greenshot–a wonderful free & open-source screenshot utility. During the installation, there were a number of optional plug-ins that I didn’t select because I was skeptical of the application, one of which was for JIRA. I was intrigued and, after my trust was earned, I re-ran the installation and selected to include the plug-in.

The plug-in is pretty cool. I have Greenshot configured to always open the image editor, and the plug-in adds a little JIRA button to the toolbar. When I click it, a dialog pops up that allows me to pick a JIRA issue from a saved filter or enter the JIRA number manually. Click the Upload button, and the image is attached to the specified issue in JIRA. I actually prefer this to JIRA’s attach file process. Quick & easy!

While the plug-in itself is slick, the configuration was not. The first time I clicked the button, it straight-up crashed. I figured out where to enter my JIRA URL, clicked it again, and it crashed. I restarted Greenshot, clicked again, and it crashed. Finally, I ran as administrator, and it worked. Jeesh!

It’s pretty easy to configure once you know what’s up, but knowing what’s up is tricky. So, without further ado…

Configuring the Plug-In

I haven’t taken any time to figure out how to add the plug-in if you didn’t select to include it during installation. So, if you were like me and didn’t install it, go re-run the installer and include it. Once installed, the plug-in is configured in Greenshot’s Settings dialog. Right-click the task tray icon and choose Preferences, then go to the Plugins tab.

configure-plugins

Click to highlight the JIRA plug-in and click the Configure button. Another dialog is displayed, prompting you for a URL. Enter the following:

https://YOURJIRAURL/rpc/soap/jirasoapservice-v2?wsdl

configure-jira-plugin

You can test the URL you’ve entered by browsing to it in your favorite browser. If it’s good, you’ll get the WSDL XML. (The plug-in works by generating a class at runtime using the WSDL, so it’s not going to work if you can’t get to the WSDL.) Click Ok to save your changes and Ok to close the Settings window. You need to restart Greenshot for the changes to go into effect. Right-click the task tray icon and choose Exit, then start it back up.

Now you should be good to go. Click the JIRA button in the Greenshot image editor, and you’ll be prompted for your credentials. If you elect to save your credentials, you’ll only be prompted once. If the credentials work, you’ll get the upload-to-JIRA dialog.

jira-button-in-greenshot

upload-to-jira

In the upload dialog, you can pick a saved filter to see a list of issues. Picking from the list populates the issue number text box at the bottom. You can also manually enter the issue number into the textbox. When a valid issue is entered, the Upload button enables, and clicking it uploads the image to the specified JIRA issue. Good stuff!

Got UAC?

As mentioned previously, the plugin works by dynamically generating a proxy class from the JIRA service WSDL. It saves the generated assembly to disk and then uses it to interact with the JIRA web service. Since it’s generating and saving an assembly to disk, it needs to have administrative priveleges. If you click the JIRA button and receive a crash message that says it can’t find an assembly with a seemingly-random name, try running Greenshot as Administrator.

Visual Studio Online and SourceTree

I really like Visual Studio Online, and I tend to use it for my various pet projects. It’s free for up to 5 users, and you get issue/backlog tracking and source control all in one spot. Perfect for my needs!

A few months back, we made the switch from TFS to Git at work. The Git integration with Visual Studio 2012 has proven suspect, so I’ve taken to using SourceTree for all of my source control needs, and I really like it. So, when it came time to create my next team project, I decided to go stick with Git/SourceTree in Visual Studio Online. Setup was pretty easy but not entirely intuitive, and you know what that means. Yep, we’re gettin’ bloggy wit it. I’m going to walk you through the steps of creating a new Visual Studio Online team project and connecting to it with SourceTree.

Create a Visual Studio Online Account

In order to create a new project, you’ll need a Visual Studio Online account. It’s free to get one, and it links to your Microsoft Live account. Head on over to visualstudio.com and sign up!

create-new-account

You’ll be prompted for an account URL, which will be whateveryouwant.visualstudio.com. Remember this, you’ll need it later.

Create a Team Project

Now that you’ve got your account, the next step is to create a new team project. If you browse to your account URL (whateveryouwant.visualstudio.com), you should see a link to create a new project. Click that and a dialog pops up to collect details about the new project. Note that you’ll want to change the version control option to Git.

create-new-project

Enable Alternate Credentials

Here’s the trickiest part of the setup: you need to enable alternate credentials in order for SourceTree to access the repository. Go to your user profile by clicking your name in the upper-right corner, then click My Profile.

click-my-profile

The User Profile dialog will be displayed. Click to the Credentials tab to enable alternate credentials, then enter a secondary user name and password.

enable-alternate-creds

Make note of these values, too. They’ll also be needed when you configure SourceTree.

Configure SourceTree

Okay, Visual Studio Online’s all ready to go at this point, and now it’s time to put it all together! Download and install SourceTree, if you haven’t already. Open it up and click the Clone/New button. For the source path/URL, enter the following:

https://USERNAME:PASSWORD@ACCOUNT.visualstudio.com/defaultcollection/_git/PROJECT

Note that USERNAME and PASSWORD will be the secondary user name and password you created in your Visual Studio Online profile. ACCOUNT will be the value entered for your Account URL when creating your Visual Studio Online account, and PROJECT will be the name of the Visual Studio Online team project.

clone-new-repository

With the URL entered correctly, SourceTree should recognize it as a Git repository and display a message. Change the destination path if you’d like, then click the Clone button and you’re done!

Mountek nGroove Snap 3

Back before everybody’s cell phone had built-in GPS, I had a TomTom GPS. It came with a suction cup so you could stick it to the window, but that never really worked that well for me. It would constantly fall off the window, and it drove me nuts. So, I bought a beanbag friction mount that I could stick it to, and it would sit nicely on the dashboard whenever I was driving somewhere that I needed directions.

Fast forward to present day. I use my cell phone for directions when I need them, but I prop it up in a little groove below my car’s instrument panel. If I turn too fast, it goes flying, and it’s low enough that I’m constantly looking down for the next turn. The solution is a cell phone mount, and I’ve been shopping for the perfect one for a long time.

I didn’t want something that used a suction cup because of my previous bad experience, and I didn’t want something that used an adhesive because I worry about it doing permanent damage or failing over time. The vents in my car are not in a good location, so any clip-on mount’s not so great. I was considering going for a suction cup to re-use with my beanbag, but I was turned off by storing it. I wouldn’t want to leave it out all the time because the rubber could melt on a really hot day, it’s too big to store with the base & mount assembled, and the idea of disassembling & reassembling with each use is less than ideal, too.

Enter the Mountek nGroove Snap 3 magnetic car mount.

mountek_ngroove_snap3

This thing is great. First, it attaches to the CD slot in my car which is perfect. It’s right where I want it in the middle of the instrument panel, and I don’t think I’ll ever put another CD in there, anyway. The mount is small and reasonably unobtrusive, so I won’t have some big, bulky bracket that’s either out all the time or being stored with each use. It’s magnetic, so I just stick a metal badge under my phone’s case and it just sticks–super easy to mount and remove with one hand. There are no brackets, so I can put it in any orientation with whatever cables I might need (charging, stereo). It’s universal, so it’ll work with phones or tablets or anything else that’s light enough to be held by the magnet (which is pretty strong). It can also be used as a desktop stand for your phone, if you’re into that kind of thing, too.

The only thing that I can even think to complain about is that my phone blocks the clock a bit when it’s mounted, but I can still see the time by leaning a little to my left. (So be sure to think about what controls or displays it might be blocking.) Other than that, it’s amazing. Even my wife was impressed, which is really saying something. Best mount ever.

Greenshot for Screenshots

I used to knock on Snagit from TechSmith. I didn’t get why somebody would pay for a screenshot utility when Windows comes with one built-in. Then I got a license, and I was converted. I loved not having to hand-draw crappy arrows, boxes, and highlights. It upped my screenshot game, big-time!

snipping_tool

But, like all good things, my time with Snagit came to an end. I left the job that brought us together, and with it, my license. I was back to living in the screenshot dark ages with Snipping Tool and Paint. After a few months, I’d had enough. I was ready to put down $50 for a personal Snagit license so that I’d never be without it again. I’m pretty sure I even went as far as putting it into my cart on the TechSmith website, but I never quite pulled the trigger.

I don’t know why it took me so long to think of this, but I finally headed over to Google and searched for Snagit alternatives. And that’s where I met one of my new best friends: Greenshot.

Greenshot has all the features that I’d grown to love about Snagit, but it’s free & open-source. Here’s a quick list of what I love most:

  • PrtSc to select a region (Ctrl+PrtSc for entire desktop, Alt+PrtSc for current window)
  • Screen grabs open in editor with drawing tools like rectangles, ellipses, arrows, highlighter, textboxes, and speechbubbles
  • Obfuscation tool to draw a box around & blur sensitive data
  • Auto-incrementing counter circles — perfect for giving directions!

greenshot

The only thing I didn’t love right out of the gate is that the default keybinding for copying the image from the editor to the clipboard is Ctrl+Shift+S instead of just Ctrl+C. But I’ve gotten used to it, and it’s nice being able to use Ctrl+C/Ctrl+V to copy/paste elements in the editor. It lets me do things like have arrows that are the exact same size and parallel, which is great since I’m super anal about stuff like that!

So, if you’re stilling using Snipping Tool and/or Paint or looking for a great alternative to Snagit, give Greenshot a try. You won’t be disappointed! Unless you want something that also takes videos. Then you’d be disappointed and would probably want to go get Snagit. But for screenshot editing, go Greenshot!

Broadcast Changes to Angular Factory Properties

I was making a little website with Angular the other day, and I wanted to have a search box in my nav bar that could be used from any page. When the search control is used, the user is sent to a search page that displays results but also lets users run additional searches. Both search functions use the same angular factory to execute their searches. Unfortunately, I was finding that the nav bar search control wouldn’t update search results when used from the search page.

I was able to solve the problem by using $broadcast and $on. It’s pretty simple, and it looks a lot cleaner than a lot of $watch solutions that I ran into while looking for a solution.

Here’s what my factory looks like:

app.factory('searchService', ['$rootScope', '$http', function ($rootScope, $http) {
    var factory = {
        search: search,
        getResults: getResults
    };
    
    var _results = [];
    
    function search(criteria) {
        return $http.post(_serviceBase + 'api/search', criteria).then(function (results) {
            _results = results.data;
            $rootScope.$broadcast('searchCompleted', _results);
            return results;
        });
    };

    function getResults() {
        return _results;
    }

    return factory;
}]);

And here’s my searchController that handles the broadcast event with $on:

app.controller('searchController', ['$scope', 'searchService', function ($scope, searchService) {
    $scope.criteria = {};
    $scope.results = searchService.getResults();

    $scope.search = function () {
        searchService.search($scope.criteria).then(function (results) {
            $scope.results = results.data;
        }, function (error) {
            console.error(error.data.message);
        });
    };

    $scope.$on('searchCompleted', function (results) {
        $scope.results = searchService.getResults();
    });
}]);

Note the use of $rootScope in the factory. Broadcasting the change is a single line of code, and handling the event in relevant controllers is pretty simple, too. Nice!

%d bloggers like this: