Read my book

I wrote books about Webpack and React. Check them out!

Saturday, July 20, 2013

Linkdump 15 - Startups, Marketing, Software Development...

Yup, it's time to dump some links again. I know I dumped month and a half ago but this way it stays more manageable. I am sure you will understand.

Startups




Marketing



Business



Hardware




Software Development



Personal Development


Games


UX


Art

Build a Before/After Widget Using CSS and JS

On a recent assignment of mine I had to develop a widget that allows the user to preview effects applied on a photo using a split screen. It is possible to modify how much you can see of either image simply by moving cursor or finger over the viewport. The fiddle below illustrates the idea:



As you can see, the idea is quite simple. Our markup looks like this when simplified to Jade syntax:

  • div#container
    • img.photo
    • div.crop
      • img.overlay

The CSS portion is really minimal as well. We need to work around a certain limitation by setting vertical-align but otherwise it's nice and clear.

.crop {
    overflow: hidden;
    width: 50%;
}

.photo {
    vertical-align: bottom;
}

We simply make sure our cropping container acts as a viewport by setting overflow property to hidden and show only half of it by default. Adjust that to your liking. Without the latter hack the photo would be about four pixels off. Don't ask why as I didn't write the spec.

Finally there is a little bit of JavaScript to tie it all together. As I felt lazy I wrote it using jQuery. It gets to the point, though.

$(main);

function main() {
    var $e = $('#container');
    var $photo = $('.photo', $e);
    var $crop = $('.crop', $e);

    $e.css('width', $photo.width());    
    $crop.css('margin-top', -$photo.height());
    
    $e.on('mousemove touchmove', function(e) {
        $crop.css('width', e.pageX - this.offsetLeft);
    });
}

As you can see the trick is simply to position the crop container on top of the original image by using a negative margin. The container width is set to photo width so that the initial relative width given to the cropped functions as you might expect it to.

In case you wish to avoid that negative margin, you may get away with absolute positioning. I don't see any advantages in that approaches, though, except perhaps it is a bit less negative?

Conclusion

This little technique could be a starting point for some interesting development. Given it's based partly on CSS it is very easy to style. You can apply effects such as opacity. On the JS side you could animate it. You could even attach text to the elements and have some sort of captions there.

It would be possible to develop an entire slideshow or a carousel of top of the idea. I hope you have fun with it! Let me know if you get something cool done with the idea.

Tuesday, July 16, 2013

13 Ways to Get More Out of OS X and Terminal

It is amazing how small things make a big difference in the daily grind. I thought it might be fun to go through some of my favorites.

Manage Dotfiles Effectively

Files of dots by yago1.com
(CC BY-NC-ND)
This is something I've covered earlier briefly. As I stated in that post I like to use Dropbox to sync between my systems. Since then I've set up a git repository that contains the essential settings. When I need to use my dotfiles somewhere, I simply clone the repository there and set up symlinks and clone my favorite Vim plugins using a little script for that.

If you consider this approach, keep in mind that you cannot put anything in the repository. Keep your private stuff, like ssh keys and such, out of there and you will be just fine.

Show Active Git Branch

Branch by Kat...
(CC BY-NC-ND)
If you work with multiple Git based projects, it can be handy to show which branch you are currently in. In case you check out my dotfiles, you'll see I use something like this there. The script looks a bit weird but works alright if you are on bash environment. In addition I have configured mine to show a '*' character in case there is something in the stash.

Discover Creative Commons Photos

Finding good photos, especially Creative Commons ones, can be difficult. I like to use Creative Commons based photos as the licensing can be quite permissive and is absolutely perfect for blogging. In commercial usage you might need to be more careful due to that NC clause. Even then simply asking a permission is worth a try.

I like to use Compfight for finding these photos. It is a search frontend for Flickr. The clean interface is very utilitarian and gets straight to the point. Just remember to the filter correctly.

Get Screenshots Easily

As you might know, there are some cool shortcuts for taking screenshots in OS X. I like to use Command-Shift-4 a lot as it allows me to crop the shot instantly. By default it outputs the screenshot to the Desktop. In case you wish to output it elsewhere, execute defaults write com.apple.screencapture location ~/Pictures/ at terminal.

Position Your Windows Fast

The default window manager of OS X is a little bit disappointing. Sure, screens are fun and work fine after you configure them correctly (disable "Automatically rearrange spaces based on most recent use" at User Preferences, Mission Control). Managing the windows can be a bit tedious by default.

I like to use a small utility known as DoublePane. It simply provides configurable shortcuts that allow me to orient a window to left or right. There are also shortcuts for displaying a window in a full screen and restoring but I rarely use those. It's that orient left/right that's valuable for me.

Make CapsLock Do Something Useful

Are you ready to unleash the fury?
by John C Bullas
(CC BY-NC-ND)
CapsLock is my nominee for the most useless key in the keyboard. Fortunately it is very easy to make it do something useful. I have remapped it to Escape. If you are a vimist, you understand why.

This can be achieved in two steps. First of all you will need to rebind it via User Preferences, Keyboard, Modifier Keys... . I've set it to ^ Control myself.

We're halfway there now. We still need to rebind that key to something useful. I've achieved this by using KeyRemap4MacBook. It is one of those applications that allows to you do some fairly crazy things. Despite the name it works on iMac and co.

In order to remap the ^ Control key, I've activated Change Key, Change Control_L Key (Left Control), Control_L to Control_L (+ When you type Control_L only, send Escape). As that sounded more awful than it is in reality, consider the screenshot below:

KeyRemap4MacBook

Adjust Display and Audio by Quarter

Wouldn't it be neat if it was possible to adjust display brightness or audio loudness by quarter? As it happens, Apple engineers have made that possible. Simply press Alt and Shift while adjusting. If nothing else, this is a sure way to impress your hipster friends at café.

Paste Without Formatting

Isn't it awful when you paste some text only to realize it pasted the formatting too? Fortunately there's an easy remedy for this. Simply keep Shift pressed while pasting. So Command, Shift, V stands for victory in this case.

Copy and Paste File Contents

OS X comes with a pair of amazing utilities known as pbcopy and pbpaste. They allow you to copy and paste within terminal. If you have something in the clipboard, simply pbpaste > file.txt to extract it to a file. pbcopy < file.txt to copy file contents into clipboard.

Navigate File System Effectively

Navigating file system is very slow and boring by default. It is easy to supercharge your navigational capabilities simply by using autojump. It keeps track of where you have visited and builds an index based on that. Then you simply j name around.

I know I have covered the utility before. It is so good it is worth mentioning again.

Search Code Effectively

Even though grep is great and all that, I've found myself using The Silver Searcher as a replacement lately. It is fast and comes with sensible defaults. Definitely worth giving a go.

Replace Terminal with Something Better

The default terminal of OS X isn't that great. If you are looking for something better looking and robust, consider iTerm 2. The default font is not quite ideal and I recommend replacing it with something else. You can do this through iTerm, Preferences, Profiles, Text. The screenshot at the left should help.

As you can see from the screenshot, I like to use inconsolata-dz. It is a version of the famous inconsolata with straightened quotes.

Installing the font is quite easy. Simply download and extract it. Open Font Book and then File, Add Fonts... .

Manage Credentials Effectively

As the amount of services you use increases, the amount of credentials you must remember simply keeps on increasing. This leads easily to some bad behavior. You might use the same password for multiple services for instance. That's not a very good idea as in case some of the services gets compromised, you have a lot of work ahead of you.

Because I don't like having to remember too many passwords, I use 1Password. It acts as a proxy for the services and provides simple means to manage and create them on demand. It is a definite time saver. I've set it up so that it uses Dropbox to sync between my systems.

Conclusion

I hope you found some of these tips useful. Feel free to share your favorite tips and tricks below in the comments!

Wednesday, July 10, 2013

Software Estimation - How to Mitigate Risks Involved?

I had to participate in a software estimation project a while ago. Let's just say it taught me how difficult software estimation really is. Hats off to those who master it!

It can be difficult for me to estimate even small tasks accurately. To give you an example I wanted to write a small album generator during the last weekend. I thought it might take a couple of hours. I ended up working most of the weekend on it and it is still missing a couple of cool features to make it truly useful. And documentation requires work as usual.

Getting the core functionality done was quite fast. As usual you get some cool ideas during development and learn about new requirements. That made my initial estimate so wrong. It's acceptable in this case as this is just a hobby project at the moment. There is no commercial pressure and the hours are on me.
The project, stalbum, is available at GitHub. There's also a little starter thinger that helps you to build your own photo album.
The situation becomes much different in a business setting, though. In this case you'll be making potentially a huge financial, and temporal, commitment. If possible, you should avoid too big deals and rather aim to cut them into separate parts treated individually. If estimating even small wholes can be difficult, can you imagine how hard it gets for something a magnitude or two larger?

The Risks of Software Estimation

Homerun by Jeff Kramer
(CC BY)
The risk is pretty much on your side on this. If you make a lowball offer and commit to that, you could be stuck with it quite a while. There are some ways to minimize the risk in case you are forced to leave a big offer. Sometimes there is no way to avoid this due to the way some funding instruments work. They are not very agile by definition.

There are a couple of factors working against us when we are doing our estimates. First of all there are cognitive biases. We might estimate that implementing a feature takes around an hour but forget that getting to that point requires some extra wiring.

It is also easy to forget about qualitative requirements. You probably want to maintain the quality of your codebase for instance. Development practices can make a huge difference. You could be reaching your goals early in the project but as technical debt catches up with you, you keep slowing down. If you are working on an existing project this can be a real risk. The quality of the codebase affects your productivity in a very concrete way.

Then there's the fact that there can be big differences in developer productivity. What might feel like an hour task to you could be three or more for someone else. This applies particularly if domain expertise is required. A domain expert might know exactly the thing that is required whereas a less experienced developer might have some research to do.

As you might know, there are three kind of knowns. Those we know, those we know we don't know and those we don't know we don't know. Yes, I know that sounded very rumsfeldian. It is the last one of these that kills estimates, though. A small new requirement might snowball through your project and cause additional work here and there. It all adds up to the overall effort required. Even the best estimate cannot take unknown unknowns in count reliably.

How to Mitigate Risks Related to Software Estimation?

So we have established there is a lot of risk involved in this sort of work. How can we mitigate some of that risk? Are software estimates worth it even? I guess this must depend highly on domain and the clients you are dealing with. It doesn't just feel right to build a business relationship based on contracts like this. Maybe there are better ways that rely on something intangible like trust and success by iteration?

If the client won't budge and you don't have an alternative, there are some ways to de-risk your estimates. The most natural ways to me seem to be prototyping and chunking it up. Working on requirements in text format can be somewhat mind numbing. Once their amount reaches a certain limit, it becomes difficult to understand the whole. You might very well be missing some vital features. You will always miss a couple no matter what.

Start with a Prototype

Wright Flyer by Tom Wigley
(CC BY-NC-SA)
By its nature software development tends to be dynamic. There are feedback loops that affect development while you are actually performing it. As the clients or users see a user interface and can actually use it, they might come up with new ideas and improvement suggestions. These are exactly the kind of things you cannot estimate beforehand and represent those unknown unknowns.

So what if rather than working on requirements in just their text form you developed a prototype to complement them? This can be a viable approach especially in web development. There is a set of design and prototyping tools that allow you to achieve this quite fast. One benefit in working this way is that it bridges the estimation and development process in a nice way.

Of course after you do this it meanders into the realm of development but that might not be a bad thing. You'll get a better feel of things and their potential complexity after you have studied them technically a little bit. You will become aware of existing solutions and will understand how much custom work is required.

Speaking of prototyping it would be even better if you could involve client and users at this point. At this point it is very cheap to make changes so why not to make them? This will avoid some rework later on and you will be able to gain better results. The worst case scenario I can think of is that you agree with some set of requirements with your client and notice after the project that the users don't like the product and avoid using it. Technical success does not always mean you have reached business objectives.

Chunk It Up

Cake by Alex
(CC BY-NC)
Generally the larger your estimate is, the more room there is for error. If you have an individual requirement that takes let's say five hours to implement or more, you could consider chunking it up into smaller pieces. This forces you to think their relationships and how they relate to the whole system. You might open a can of worms accidentally this way but that is a good thing. You definitely don't want to open it during development.

There are some intangible tasks like user interface design that are difficult to estimate. It may be cleanest just to allocate some fixed amount of hours for that and hope it is enough. Prototyping can alleviate this risk as it forces you to make some decisions required.

Use the Right Tools

Hammer by Ian Baker
(CC BY)
Even though it might feel like a good idea initially to gather your requirements in Word, Google Docs or something, try to avoid that. Things get very messy once you have to perform calculations. And they get messier when you start splitting up the work in iterations. Even a spreadsheet is better. There are tools for project management and estimation, use them.

In ideal case you should be able to import the requirements into your issue tracker and refer to them in commits. If you use a time tracking system, it would be excellent if you were able to hook that into the whole. This way you could actually see how close to the truth your estimates were. If you go beyond your estimates consistently, you know you are in trouble.

Leave Some Slack in the Schedule

Sloth by Pierre Pouliquin
(CC BY-NC)
Padding is one of those classic techniques that applies even today. It can be applied to the whole as a multiplier. The purpose of that is to counter those "unknown unknowns". 

There may be some better practices available but having some slack seems like a good idea given things don't always go as in the ideal scenario. Software developers tend to be optimists. It is better to try to estimate a median scenario rather than minimal one.

Prioritize

Are you sure all of those features are actually needed? Try to come up with a sensible set of minimal requirements with your client and leave as much as possible optional. If there is time and money for it, those can be dealt with later after the completion of the main project. This way you avoid a death by thousand cuts. Small features add up quite quickly.

Conclusion

Software estimation is easily the hardest part of software engineering for me. It gets particularly hard when there's a lot of uncertainty involved. Even when you get to use your favorite tools and know the domain, your estimates can still go wrong. The margin for error is a magnitude or two larger when you don't have control over these factors.

If you look up the subject, you will find a lot of literature and techniques on it. The ones I covered here are something you likely come by intuitively. If you are working on a team setting, you could try to get multiple estimates from separate developers and have them justify them. That way you should be able to avoid some blunders and reach more realistic results.

Remember that time spent estimating is time that could have been spent developing. Perhaps you are better off developing a prototype which you can showcase to your client and users and then snowball the project from there.

If possible, try to avoid offers that feel too big as they come with a lot of risk. Of course if you are willing to accept the risk, go ahead. But do your best to mitigate it. Unless it might be a death march time for you.

I am very curious to know what sort of techniques and tools you use for software estimation. Do you consider software estimation necessary? How do you apply it in practice?

Monday, July 8, 2013

The Triad of Success - Vision, Process, Execution

Dungeon by David Barnas
(CC BY-NC)
A loud roar awakens you. You wake up in a dusty, old dungeon. It was supposed to be a casual night out and you have no idea how you got there. You remember meeting an attractive stranger but after that it is all blurry.

You hear that roar again. As you are not keen on discovering its source, you pick up your backpack and head for the open door. It must be your lucky day. What's the point of a dungeon if the door is left open?

Vision

You can either follow the stairs up or go through the corridor right. As you were disoriented before, you are not entirely sure where the sound came from. All you know is that you must get out somehow.

You have no idea how big the complex is. Maybe you will find your way out within a couple of hours. In the worst case you never find your way out. It is not even certain that there is an exit available. Perhaps it is all just a cruel joke concocted by your captors.

As it really doesn't make much of a difference to you yet, you decide to enter the corridor. Not long after entering it you can hear something whizzing by and hear metallic clanking on the floor. To your horror you discover that you were almost hit by a dart. This dungeon is trapped!

Execution

Compass by gwgs
(CC BY-NC-ND)
Since you want to avoid a grisly fate, you decide to be more careful. If there are dart traps, who knows what else? After regaining your courage and resuming the corridor you come by bony remains of previous captives. They left behind a rusty old compass, a spool of yarn and a sword. You decide to take them as their previous owners likely won't need them anymore.

The labyrinth seems endless but you carry on. Every once in a while you come by new dangers. At times you can see rats and cockroaches scurrying around. Strangely you start to become accustomed to your new environment. You start to pick up new skills and learn to forage. Even though thirst and hunger are constant threats, you learn to follow the signs and know where to look for. Lichen doesn't taste that bad after all.

The roars seem more distant. It looks like you may have escaped that fate. You still have no idea when you are going to see home again, though, but doggedly you keep on progressing, hopefully in the right direction.

Process

As you pick up skills and get used to dungeon life, you start to develop ways of doing things. You will always look for traps in the same way. The same goes for charting new areas. You always go right till you can no more and trace back. That way you can be certain that you have gone through each area and avoid getting lost.

Your past experience helps you to understand which plants to avoid. It also gives you idea of warning signs. If there is a large area without any lichen on the wall, you know something is amiss. Perhaps there is a nasty trap or a hidden door even. On longer term you are able to optimize your dungeon crawling skills and they way you use them. Perhaps there is hope after all.

The End?

Knight, horse and word by Hartwig HKD
(CC BY-ND)
You may or may not discover the exit. I will leave this story purposefully open ended. In practice each startup/project/person/younameit has a story of its own. The dungeon was just a metaphor that describes the struggle and challenges. That roar was caused by the fear of failure. It was the impetus that forced you on the move.

I borrowed the triad - vision, execution, process - from Chuck Blakeman's "Making Money Is Killing Your Business". You will require each of these to be successful. You might for instance dream to get out of the dungeon but fail in execution. Or you might have the skills but for some reason you might want to make friends with the monster. I have heard minotaurs make bad friends though maybe you could get lucky.

I hope this brief post gave you something to think about. The more I think about my past projects against this framework, the better I understand why something worked and why something didn't. The nice thing about it is that you can apply the three concepts on some current project of yours and think it through. Is there something you can improve?