Archives For code

One ASP.NET Sneak Peek: Elegant Web Forms and Snowballs in Hell – Scott Hanselman

Get involved in Open Source today – How to contribute a patch to a GitHub hosted Open Source project like Code 52 – Scott Hanselman

Funkatron / The MicroPHP Manifesto

Plans for Next Year

Chris McLeod —  Dec 23 2011 — 3 Comments

The last few days have seen me thinking about some of the things I want to do next year. Not so much New Years’ Resolutions as much as a kind of master “to-do” list.

Travel Somewhere New

Even if it’s not very far away, or for more than a long weekend, I hope to see somewhere new next year. Ideal places would be New York, Paris or Florence/Rome, but I suspect I’m more likely going to have to stick to somewhere in the UK.

Start Writing A Book

I’ve put off starting any of the novels I’ve had bouncing around in my head for years. That needs to stop. There’s nothing really stopping me, really, other than procrastination. With it being so easy to self-publish now (especially as an eBook), there’s no longer any real reason for me not to.

Release More Projects

I used to write and release a lot of code; the first XML-RPC interface for Textpattern was mine; plugins and themes for various blogging and CMS systems; CSS/HTML experiments… and then, at some point, for some reason I stopped. Hopefully I can turn this around again.

Model and Paint At Least One (small) Warhammer 40,000 Collection

Yeah, this is the nerdiest item on the list. Before starting university I had a huge W40K collection which I was quite proud of. Then Girls and Booze got in the way (oh, and some studying too), and I stopped the hobby. I’ve kind of kept in touch with things over the years since; the Dawn of War series of games provided some connection, while the Horus Heresy series of books fleshed out what was always my favourite part of the hobby: the background “fluff”. I picked up a couple of the new codex books this year, along with the latest rulebook – not that I plan on playing any games – and I’ve been inspired by several things over the last few months such as Armies on Parade and some of the cool stuff available from Forge World. So my plan is to build at least one small, well modeled and painted collection in a similar style to AoP. After a 12 year break, how hard could it be??

Miscellaneous

Other plans include the usual suspects of [continue to] lose weight/get fit, and be smarter with money. I’m thinking of getting a couple more tattoos as well…

So what’s everyone else got planned for 2012?

Rawkets | A multiplayer game built using HTML5 canvas and WebSockets

Scalable and Modular Architecture for CSS

The Five Megabyte Web Developer | Benjamin Atkin

Replicating a stack of paper is a common design found on the web; it’s an easy way to make a design a little less harsh and digital by giving it an “analog” look. For a quick example, take a look at the “Chapters” WooThemes WordPress theme.

screenshot of the chapters theme, showing the stack of paper effect done using images

In the past I would have used a couple of wrapper divs in HTML, and some background-image CSS to get a vertically expandable (but probably fixed-width without a lot more work) content box. However, with the improvements in CSS3, along with rapidly improving browser support, I wondered if it would be possible to make a similar – and more flexible – effect without images. Continue Reading…

I fell for a trick question today when demonstrating my technical ability. I don’t feel too bad about it – it was all in good spirit, and it was designed to catch people out (and it was first thing on Monday morning…). The question was deceptively simple.

“What’s your most efficient way of printing out all the odd numbers between 1 and 1000?”

Immediately I gave the same answer as – according to the Askee – everyone else: with a loop and the mod operator. Pseudo code:

for(int i = 0; i <= 1000; i++)
{
	if(i % 2 != 0) Console.WriteLine(i);
}

Simple, obvious, and pretty efficient, no? With a grin the Askee wrote “i+2″ on the piece of paper, and left it at that. After a moment my eyes went wide and I’m sure I physically slapped my forehead when the realisation hit. While the answer above is how 99.99% of developers would answer the question, it’s over-engineered. This would have been a much simpler solution:

for(int i = 1; i <= 1000; i = i + 2)
{
	Console.WriteLine(i);
}

Each odd number is two more than the last one. Duh…

In the follow-up discussion we talked about how most developers tend to over-complicate things almost on instinct. Our solutions may be correct and (usually) robust, but often if we step back a moment there would be a much more straightforward way to solve the problem. So I may have felt stupid for a moment, but it led to an interesting discussion about the nature of programmers, where hopefully I saved face!

One of the cool things released earlier today by Microsoft was IIS Express – A lightweight but fully-featured and self-contained version of IIS 7.5. It runs on Windows XP and above, even if you already have IIS or another web server installed.

What’s really cool (I think) is it can be run a) from the command line, and b) from any directory. This makes it incredibly flexible. That said, I don’t want to have to fire up a command prompt every time I want to start a server instance in a particular directory… Wouldn’t it be much easier to have a right-click “IIS Express Website Here” context menu option in Windows Explorer? Of course it would :-)

I’ve thrown together a shell extension using some registry edits, adapted from original work here and here, so all due credit to Phil Haack and Tuna Toksoz. What it does is add an option to your Windows Explorer context menu to start IIS Express in the selected directory, using a random port number. You can then use the handy System Tray icon to launch the site in your favourite web browser.

There are two versions of the .reg file in the Zip file – one for 64bit Windows, and one for 32bit. Only the 64bit version has been tested (certified working on my machine), using a standard WPI installation of IIS Express. Only run the .reg file suitable for your platform. Use at your own risk – I am not responsible for anything which breaks!

Download IISExpressHere.zip

UPDATE 18-Nov-2012: I’ve made a copy of the source over at GitHub, for those of you who can’t access the Dropbox link, or want to fork the code for Windows 8, etc. You can access the repository here: IIS Express Here on GitHub