Get Into This

All the cool things.

Git Grep and Blame Bash Function

| Comments

Git has two very useful commands, git grep and git blame. The first one will find and print lines matching a certain pattern. The second one, given a file and line number, will tell you what revision and author last modified that line.

I was looking for a command that do both, but it seems that git is lacking such a command. Luckily, you can achieve this by using a simple bash function.

Simply add that function to your ~/.bashrc file (or where ever you keep your aliases and functions), and you will be able to do:

>ggb "Some string"

And this will grep your entire repository for “Some string” and print out the blame information for the file containing that pattern.

Fix Blurry Images in Emails Viewed on Retina Devices

| Comments

This is a super simple and easy fix for the blurry image problem you may have noticed when reading emails on your retina capable device. Images and logos appear all blurry and nobody likes that.

The trick is to create a 2x version of your image, but to set the width and height values to the smaller version. For non-retina devices, you will get a higher res image that is resampled down, which should look good in most cases. For retina capable devices, the image is resampled up to its original higher resolution, but still remains crisp.

I recommend doing this for just important images in your email, like your logo and other icons that may have text in them, like share buttons, etc. Using this technique on complex photos may result in less than desirable anti aliasing effects.

Triggering Zepto Tap Event Using Click

| Comments

This one will come in handy if you are testing/debugging your mobile website on a Desktop browser (i.e. Safari, Chrome) with a custom User-Agent set and are utilizing the tap event provided by Zepto JS.

The issue with binding the tap event is that you cannot trigger them with a mouse click. And we all know that debugging on simulator and emulators is a pain in the ass, so hopefully this little code snippet will save you some time.

1
2
3
4
5
6
7
8
(function($) {
    // only do this if not on a touch device
    if (!('ontouchend' in window)) {
        $(document).delegate('body', 'click', function(e) {
            $(e.target).trigger('tap');
        });
    }
})(window.Zepto);

You can use the same technique to trigger touchstart and touchend events using mousedown and mouseup.

Fixing HTML Label Tapping on iOS

| Comments

This one should be filed under the WTF category. Apparently, clicking/tapping on HTML <label> in current versions (5.0 or older) of iOS Mobile Safari does not focus the corresponding form element. Not sure if this a bug or done intentionally, but not only is it annoying, but also an accessibility issue.

There is a simple CSS “fix” for this, and it is seems to work pretty well across all form elements:

1
label { cursor: pointer; }

Yeah, that’s it. Go figure.