Home > Blog > 2016 > 01

All Posts From : January 2016

Staying Positive

In a departure from the usual techy stuff, I'm going to post about something quite close to my heart. Staying positive. I'm quite an upbeat and positive person, but that wasn't always the case. It took borderline work burnout and serious illness to get me to sort my shit out.

So, a bit of background. Back in early 2005, I'd pretty much burnt myself out working myself to the bone as the lead programmer at an ambitious startup, for an extremely demanding boss. I was so miserable, that I seriously considered sacking off web development entirely, and retraining to do something completely different (top of my list was touring road crew, but the missus vetoed that one).

Several of my self employed friends (none of whom work in web) inspired me to try my hand at freelance, it was something that I'd always fancied, but I didn't think I was good enough. After a couple of months, I'd fallen back in live with web dev, and I realised it was the toxic working environment that burnt me out, not the industry. All was good, until I got ill. I had a wracking cough that just wouldn't quit, and I had no energy. For almost a year, I was a complete medical mystery, until in 2006, after some surgical exploration, I was diagnosed with Stage IVB Hodgkins Lymphoma (an immune system Cancer). As bad new goes, that's up there with "yup, your house is built on a spooky burial ground".

It was at this point, I started my journey to being more positive. 12 months of being a medical mystery is RUBBISH. Had I been any good at music, I'd have written some killer blues songs. As I led in bed with the Oncologist explaining my diagnosis, I was actually happy, I think he thought I'd lost the plot. But actually finding out that my illness had a name, and could be fought was enormously liberating. From that point on, I focused on the positives. Throughout the six months of chemo I had, I remained positive and upbeat, much more so than I would have imagined possible. Having a health scare like that really made me focus on what was actually important. I've learnt a lot from the experience, and some of the inspiring people that I met along the way.

Right, enough background! Staying positive is all about realising what's important, what you do and don't have control over, and looking for the opportunity when things go bad.

Realising What's Important

We live in extremely information rich times. Most of us carry devices around in our pockets that are more powerful than the first 7/8 computers I owned, COMBINED. The entirety of the internet is at our fingertips, and it's easy to get overloaded with information, making it hard to focus on what really matters. It works for work as well as personal stuff. Learn to filter out the stuff that doesn't matter and focus on the things that do. Stop spending all your time reading about other people's lives, and concentrate on your own.

With work it's easy to get caught up in the bigger picture and get sidetracked. Break your project down into smaller parts so you can concentrate on the individual pieces and it gets simpler. Also, learn to filter the important stuff from a client brief. It's sometimes easy to get really caught up on a feature that's actually pretty inconsequential.

Control

People have a tendency to stress about things they have absolutely no control over, and worry about some nebulous future event. I find the trick is to focus on what you're doing now. It's also important to realise that there are some things you have very little control over and just accept it and take charge of the things that you can.

One example of this would be me worrying about relapse. I know people who have literally lost their mind worrying about getting ill again after recovering from Cancer. They constantly fret about every little thing they do, terrified that they're making it more likely they'll get sick again. I look at it this way, as long as I avoid anything too stupid (smoking, hanging out in chemical plants without a mask, swimming in Benzene), I'm probably good. I'd rather enjoy the extra time I have, than lock myself up an be paralyzed with fear about being ill again.

You can plan for some eventualities, but accept that sometimes things happen for no real reason!

Look for the Opportunity

One of the things I learnt early on was to look for the positives in the bad. I got diagnosed with Cancer, I could easily have collapsed in a weeping heap and spent the next 6 months rocking backwards and forwards. I admit, I cried a bit, but I also saw my diagnosis as a positive step on the way to recovery.

Been laid off? Take it as a sign that it's time to move on. Upskill and move on to better things, don't waste your energy being bitter and focusing on the past. Project didn't work out as well as hoped? Look for the bits that DID work and take those away as something you can use next time.

Perspective

Finally, one thing that really helps is to have some perspective. For the majority of us, what we do isn't life and death. If a menu doesn't line up perfectly in IE8, no one is going to die (except maybe the IE devs, as they get hunted down by disgruntled web devs, one by one). Sure, you should fix it, but it's not worth getting super stressed over.

Make sure that you take a step back every now and again and have some you time. As an industry, web dev is close to game dev for the amount of crazy overtime that's expected, often down to poor planning or lack of resources. Take a step back every now and again and do something you want to do for you. Since I hit remission, I've tried to do at least one thing a year that I've always wanted to do, and man does it recharge my batteries. I learnt to snowboard at 30 (and I love it), I taught myself SLR photography and I even climbed Mount Fuji in Japan (something I've wanted to do since forever). When I come back from a week on the slopes, my creative batteries are fully recharged, and I feel amazing. It doesn't even have to be that exciting, go for regular walks in the countryside, take up cycling, it all helps :)

I realise that a lot of this is probably obvious to most people, but it's surprising how many people I come across in  web dev who get burnt out, often for the same reasons each time. I hope this helps someone, or at least gives them some food for thought!

Running Umbraco Over Reverse Proxy

Recently I had to get Umbraco working over a reverse proxy, and I thought I'd share how I did it, as there's actually a pretty painless way to get it working!

First up, what is a reverse proxy? A reverse proxy is like a virtual folder, except that the contents of the virtual folder resides on another server. Why would you need to do this? Well, usually, if you need to run Umbraco in a virtual folder in a .Net site, you could use a normal virtual folder. However, security considerations might prevent installing the Umbraco site on the same box as the main site, or the main site might be written in PHP and hosted on a *nix box for example.

Out of the box, platforms like Apache support reverse proxying natively through Mod Rewrite. In IIS, you have to use something called Application Request Routing (ARR), combined with URL Rewritiung to make it work. These are optional add ons for IIS. If you're interested, here's some information on how to do it with Mod Rewrite, and here's how to set up ARR in IIS.

One of the things that you often have to do with reverse proxied stuff is to rewrite the content as it's sent back to correct image paths and links etc. Normally you'd do this with outbound rewrite rules. It's not too painful for simple sites, but for something like Umbraco, which is a very complex system, it can be quite difficult to do without accidentally breaking stuff (you also need to heavily rewrite the contents of JS and CSS files, which can be quite slow, and each extra plugin increases the work usually).

So I figured out a much easier way of getting it all to work. Lets say you have www.mysite.com and you want to reverse proxy the URL www.mysite.com/blog/ to blog.mysite.com, which is an Umbraco site on another server. All you need to do is set up the Umbraco site on blog.mysite.com to run in a virtual folder that matches the name that you want to use for the reverse proxy, e.g. blog.mysite.com/blog/. As Virtual folder setups work pretty well out of the box, this means that you only need an outbound rule for the blog.mysite.com domain, everything else should just work out of the box, as it already thinks it's in the /blog/ folder!

Making Your Packages Work in a Virtual Directory

Just before Christmas I worked on a couple of projects where we needed to have Umbraco running in a virtual directory. Out of the box, Umbraco itself works very well in a virtual directory these days. The main issue that I ran into was packages that didn't work correctly when Umbrco was in a virtual folder.

From going through all the affected packages in the projects, I've compiled a list of things that you can do in your packages to help ensure that it will run correctly when your site is running in a virtual folder. So without further ado, here are the top five things to be aware of:

1. Paths in your package manifest

In your package manifest, ensure that your paths start with a ~. E.g. instead of referencing a script as "/app_plugins/my_plugin/script.js" use "~/app_plugins/my_plugin/script.js". Umbraco will then work out the correct path when it loads in all of the manifests.

2. Paths in your CSS

You often see people make their image paths in the CSS relative to the root of the site. This won't work in a virtual folder, so make sure all of your image paths are relative to the location of your CSS file. That way the paths will work, regardless of where the Umbraco site lives.

3. Paths in your JS

Again, it's common to see links to things in the JS file be rleative to the root, e.g. "/umbraco/surface/mysurface/get". Your JS will be executing from the /umbraco/ path, so code your paths accordingly. E.g. in the previous example, you could use "../umbraco/surface/mysurface/get".

4. Paths in your templates

As with paths in your JS, code the paths to images and other resources in your templates/views as if they're in the /umbraco/ folder. So instead of "/app_plugins/myplugin/images/", use "../app_plugins/myplugin/images/".

5. Paths inside your code

If you're mapping paths inside your code for things like Controllers and other compiled resources, don't forget the ~ at the start of the URL! this will then map the path to include the virtual folder as well.

And that's about it. If you follow those five guidelines, your package should work on an Umbrco site that's running in a virtual folder!