Rss

Archives for :

Docker on Windows 10 Anniversary – [updated]

So Windows 10 Anniversary is out and it brings with it Containers!

Most likely if you’re like me and already interested in docker, you’ll have installed the Docker App from docker.io and will be wondering why the instructions don’t work.

Basically the docker app for windows doesn’t currently support Windows containers.

If you run docker version you can see why:

The server is running linux. No hosting Windows containers in that.

Now I could uninstall the current docker app and then follow the instructions, but really I want to just quickly try out docker windows containers but also keep using my linux containers.

How I got it working was to tweak the instructions a bit:

  • From the System Tray, right-click on docker and select “Exit Docker”
  • In powershell stop the docker service  Stop-Service com.docker.service
  • Download the Windows container service (ensure you have a c:\temp folder):
  • CD into the c:\temp folder and extract this archive:
  • There are 3 files in the new “docker” folder: docker.exe (which is the same as in the Windows docker app), docker-proxy and dockerd.exe. We need dockerd.exe
  • Register this new dockerd service and start it:
  • Once you start the new docker service you’ll see:

Now your windows nanoserver container will happily install and as per the original instructions:

Unfortunately for me, it just hangs here, and does absolutely nothing. In the end I have to kill the docker.exe process and stop the service.

So still waiting on getting working containers on Windows.

To remove the Windows container service, and return to linux, stop the windows container service (optionally un-register it)

Then start the Docker app service again, the run “Docker for Windows” app again to start the Mobylinux host.

Resolved

Update to the latest version:

 

First Published PowerShell Module

Today I tidied up a PowerShell module that I’ve been using myself for ages and pushed it to PSGallery.

It’s a pretty simple module that scratches one of my big itches with powershell. It’s really hard to write coloured text with the tools provided.

Generally writing colours to the console for command line tools isn’t always simple. Libraries like chalk exist in the NPM world, but I’ve never yet found one for PowerShell. Now one exists 🙂

One of the issues with PowerShell is that the current terminal (really conhost, a process that hosts the shell) is notoriously (even infamously) bad at what it can do. Imagine a feature you’ve seen in a Linux terminal and there’s a very good chance that conhost doesn’t have it. Microsoft has started to finally address these deficiencies, and it’s about time, especially as Windows Core and Nano Server are likely to be very important platforms in the coming future, and all of those will be command-line only.

You can check out the my module on GitHub or simply install it and play with it.

 

Docker & PHP – on Windows

Deciding I needed to learn more about docker and finally start using it, I decided to give it a little try.

Docker on Windows… not so quick

A recent application I downloaded wanted to install an entire WAMP (Windows-Apache-MySQL-PHP) stack on my computer. There’s no way I’m having all of that installed and running.

I knew this was possible in docker, so I thought I’d start my foray into docker land with creating my own WAMP stack. It turned out to be more a VDLNMP stack; as you’ll see.

After much searching amid a very log signal-to-noise ratio, I finally found an excellent tutorial at a place called osteel’s blog.

I was merrily following along until the instruction came to mount the local dev folder into the docker container. Now I’m running on Windows, so I’m using docker machine, and after some searching discovered that docker machine just doesn’t work like that.

I’d have to somehow copy my dev folder to VM that’s hosting the docker containers and then mounting wherever that folder is into the running containers. Too much indirection for me.

Vagrant to the rescue

I then remembered that vagrant forwards local folders very nicely, and into a very predictable location. I also remembered that vagrant supports docker as a provisioner, even better a quick search turned up that there’s a docker-compose plugin for it as well.

I quickly built a very simple vagrant file:

Followed by vagrant up and, lo and behold, everything just worked.

What’s Happening?

  • The vagrantfile uses the basic ubunty box.
  • It then provisions by installing docker & docker-compose
  • The final two options on docker_compose are:
    • the docker-compose.yml to run (it allows multiples)
    • always run this provisioner, e.g. on vagrant reload

Finally to make my life easier I forward the ports on the vagrant box where my containers are running to my local machine.

The full project is available in GitHub.

VDLNMP: Vagrant-Docker-Linux-Nginx-MySQL-PHP

PowerShell which

One thing that quickly annoyed me was typing ‘which’ in my powershell console and getting an error:

Why would I even want that? Because sometimes it’s important to know exactly how the console resolves what you type, especially when some items are in the path multiple times, and some can be obscured by new or other definitions.

Take Ruby. Ruby comes with “ri”, the documentation browser. Turns out in powershell there’s also an alias “ri” for Remove-Item.

The good news is that Get-Command does basically what I want. So a quick addition to my profile:

and I now have my own ‘which’ command:

I can easily find out how to invoke the Ruby “ri” command, without it becoming Remove-Item:

 

Shocking

One of the things that winds me up about reporting of accidents in the news is the use of the word “shock”.

A recent example is a report that said “there were no serious injuries, and the driver is being treated for shock”. My first reaction is, “well that’s bloody serious for a start!”.

My perspective is somewhat different though. I’ve been a work-place first-aider / first-responder / BHV’er (as the Dutch call it) for quite a while. While I’ve luckily never had to use all that training, shock is one of the most serious conditions I am ever likely to have to face. When I hear or see the word used therefore it’s one of those things that make me cringe.

The reason why it winds me up when the news uses the word shock is because what they really mean is “Acute Stress Reaction”. Basically the person is freaked out and distraught.

The symptoms can be similar, some of them at least, like racing pulse, rapid, shallow breathing, anxiety. That’s though where the similarities end. If you don’t treat someone with acute stress reaction immediately they might start crying, or hyperventilate and pass out, but that’s it; that’s not to say they don’t need or deserve care, they just don’t need it right now. If you don’t treat someone with shock, then in a couple of minutes they’ll be dead.

The human body goes into shock when the brain and other vital organs are short of oxygen.  The body starts shutting everything else down, that’s why one of the major symptoms is cold and clammy hands and arms; the body stops sending blood to the extremities and you start sweating as the body loses control of the sweat glands.

Blood loss from injury  is the most common type of shock encountered by first-responders; there simply isn’t enough blood left to carry the oxygen the body needs. Others include some types of heart conditions (e.g. not pumping correctly) and also anaphylactic shock (i.e. an acute alergic reaction).

During my certification here in the Netherlands, the course tutor told us the Dutch emergency services response to someone in shock was to send two ambulances, police out-riders and a helicopter if they can. I’ve not reason to doubt this, and living quite close to a hospital I’ve actually myself seen police outriders twice clearing the junction in front of my house for ambulances.

If you so much as suspect shock, e.g. because of bleeding or internal injuries (shock can set in slowly, e.g. the day after an injury happens, when you’re bleeding internally), call the emergency services at once. If you’ve already called them once, call them again and tell them it’s shock. Get the person to lie down flat, raise their legs to increase blood flow to the brain, keep them warm.

Someone in shock will be very thirsty. Under no circumstances give them something to drink or to eat, no matter how much they beg. Their stomach has already shut down, they will just vomit it back up and may choke; especially once they stop breathing. Then keep them calm and keep them company; according to my trainer the person will already know they are dying. Keep a very close eye on them until the ambulance arrives, they can stop breathing any time, so be ready for it and try to send someone for an AED, so you have it there when you need it. Don’t be surprised, when the ambulance shows up, that the crew just run in, grab the patient, and run out again.

The reason the Dutch emergency services (and I presume those of other countries as well) make such an effort with shock is that if you can get someone to a hospital quickly then you can save them, and they can make a fairly full recovery. Every second counts, literally.

So maybe if the next time you read about “shock” in the papers and you remember this post and what shock really is and how to recognise and respond to it, this post will have done some good.

Games: Pre-Purchase, Early Access and Crowd-funding

The games industry is changing the way games are funded and released. There are not loads of new options for how you can get hold of the newest games, ensure the games you want to play are made and even take part in the development.

I’d like to talk about three of these and how I view them and what experiences I’ve had with them.

The first is Crowd-Funding

I’ve funded a number of things using Kickstarter. There’s Star Citizen, Elite: Dangerous and Godus to name some examples, not entirely at random. These examples are not at random because they highlight the differences between dangerously over-hyped, delivering as promised and failing miserably respectively. SC and ED have both done right by the community that supports and funds them; they provide regular updates, they deliver what they promised and they talk and engage with their community continuously and above all openly. Both SC and ED are running late and yet their communities still support them. Why is that? It’s because they were open and honest about what they were doing and why and in the end the sponsors want the game they were promised, and given they’ve already waited many years, a few more months won’t bother them.

Godus is a miserable failure. It’s delivered very little and what it has delivered is nothing like what was promised. Their communication with the community is attrocious and they have zero ability to set expectations correctly. They call their last release a “beta”, despite it being nowhere near feature complete and something a lot more akin to an alpha. What’s worse is the total lack of engagement and communication with the community. At the end of last year the company just went silent, for months. People started wondering if they’d gone under. In fairness to 22cans, they are now trying to salvage this, but it’s probably too little too late.

I like crowd-funding as a mechanism for getting things made. I’m not a fool though and realise that it’s basically just a new form of venture capital, and as most venture capitalists will tell you, most of the things you fund will fail. I’ve been really lucky in that of the six or so things I’ve funded, only one so far seems to be in danger of failing or strongly disappointing me. The others are doing well. The other thing to keep in mind is that as a crowd funder I have even less control and oversight of the project than a venture capitalist might. I’m at the mercy of the person I funded, and have no way of compelling them to do anything. Most projects take their sponsors seriously and give them as much oversight as they might a traditional publisher some, like Godus, don’t.

The next is Early-Access

This is a strange one. There are potential benefits here all round. The developer can get extra funding during the development cycle. The developer can start getting feedback and incorporating it into their work. This is pretty much the essence of SCRUM and Agile development. Get feedback from stakeholders early and often and act on it. The other good thing is that players can get their hands on something early and most importantly, for me at least, the chance to shape the direction of a game to help it become all it can be. It’s also an opportunity for people to start providing feedback on the game and reviews and this allows a game to be judged early and allows those potentially interested to start seeing game footage, player comments and even reviews for a game. The danger here are those games that don’t seem to have a clear end date for their early access, and you start wondering if they’ll ever release. Then there’s developers that listen too much to the crowd and end up doing development by committee, which is never a good thing. Finally there’s people getting access to the game and expecting that what they see will be playable and fun, when actually it might be nothing of the kind.

The final one is pre-order

This is one which I have done myself a number of times and I’ve been burnt enough times now that I refuse to do it any more. What makes this nasty is the industry practice of embargoing reviews until a games has been released. Therefore if you buy a game based on trailers, or marketing material, it might end up being totally crap (X-Rebirth, Colonial Marines) and there’s no way to get your money back. There’s also the nasty habit developers have of slicing up their content and offering zero-day DLC or different areas/benefits depending on which retailer you pre-order from. Aside form splitting up developer resources, it means that us poor blighters that want to play the game will never be able to see all of it, unless we buy the same game from lots of different retailers on pre-order. It’s a nasty practice and one I refuse to take part in any more.

Conclusion

How then is pre-purchase different from crowd-funding? I suppose, in reality, it’s not different. In some ways crowd-funding is almost worse than pre-order, as all you have are promises. Where the two differ for me is that with crowd-funding I know I’m buying into a promise, into a dream, I’m providing the opportunity for something to be made which might otherwise never even exist. With pre-order I’m buying a supposedly finished game, which is so good that they had to prevent all the reviews from being released before I buy it.

ICS Cards – Export Statements

As part of my banking with ABN Amro I get a credit card managed by ICS Cards.

The single most annoying thing about ICS Cards is that they don’t provide any means of exporting my statements. The next most annoying thing is that they haven’t responded to any of my emails request that feature.

Time to help myself then, in true developer fashion, I’ll write my own.

I’ve used loads of languages over the years and different languages suit different tasks. Python turns out to be my go-to language for scraping web-pages and pulling out information from them. Mostly because it’s really easy to knock up a script and because there are loads of great libraries already available to do most of the grunt work.

So here it is. A quick and dirty script to log into my account, parse the monthly statement page, fix the formatting and write it out as CSV.

This is by no means a finished script (have you seen how messy it is!!) and it’s kinda hard-coded what it will download.

Here’s an example output once the script is done with it:

Fixing my %PATH%

After a while working with a computer it’s not unusual for my %PATH% environment variable to become messy.

It tends to contain wrongly formatted paths, or paths that no longer exist from programs that have been uninstalled.

This was causing me problems when I ran a tool that relied on the path and was having trouble with it. Turns out this tool was pretty primitive and a touch too over-sensitive.

I had no idea which path it was choking on, and there are a lot of entries in my %PATH%, and many of them use environment variables, the I thought I’d quickly write a powershell script to fix what’s in there.

There are a couple of simple rules for %PATH%

  • It’s a semi-colon separated list
  • Don’t use quotes (“) in paths
  • Spaces are permitted
  • Environment variables of the form %NAME% are permitted.

The script simply checks each path isn’t surrounded by quotes, ensures the path exists (it has to resolve the environment variables first) and then returns a new string in the correct format for the %PATH% environment.

It returns the script to give you a chance to verify it yourself. But if you just want to update the %PATH% without that step, you can do this:

Where “Fix-Path.ps1” is just a saved copy of the script above.

UML Diagrams the Simple Way

There is a great engineering aphorism to “Keep It Simple Stupid!”, the KISS principle.

Many developers often confuse easy and simple; I’ve done it in the past, and will probably again in the future. Where you stand can a big difference to your perspective.

Take UML Diagrams and particularly drawing and collaborating with them. There are dozens of editors out there that allow you to easily drag/drop/link etc. all your different diagrams and classes. They’ll remember relationships and properties and other funky things. This can make it very easy to draw a diagram, or many diagrams. Unfortunately it can also make life everything other than simple for those you need to collaborate with, updating the diagrams when you lose the tool (e.g. out of business, or license expired) or you don’t have the tool, or it doesn’t run on your computer.

One reason I’m a big fan of the TodoTxt format (and even have my own TodoTxtJs tool) is that it makes life very simple. It’s not the easiest tool to work with, it’s not always easy to do every task, but it is an extremely simple format, and the big advantage of that is compatibility and portability. I don’t need anything more than Notepad to read and manage my Todos, and there’s no way I’ll ever not be able to edit or read them. Tools can make me more productive, but I don’t need them.

Wouldn’t it be great if the same applied to UML diagrams? Interestingly it does. Enter plantUML.

Take this example definition:

Even if you’d never seen the diagram and never seen the syntax before, using a bit of effort, and some knowledge of UML, you’d be able to figure out what it’s describing. That is one aspect of what makes this simple.

In case you’re curious, this is the actual sequence diagram, and that’s just one of the many formats it understands:

UML Sequence Diagram

 

It also makes it a really elegant solution for collaborating with people. You don’t need to send huge binary files around in proprietary formats, just send simple text. You don’t even need the same “compiler” or “renderer”. Just knowing the syntax you could write your own, just as you’re able to understand what it’s showing by reading the text. A more complex diagram might require a paper and pencil 🙂

It also means that if you need to render it in a different way (e.g. colours, shapes, style) just use a different renderer. You have, coincidentally, gone a long way to separate content from presentation, and that’s almost always a good thing.

As an added bonus, if you’re storing your designs and documentation in a source control system, then you can diff a text file much more easily than complex binary file.

The good news is that plantUML is open-source and free, so there’s no likelihood of it ever going away, although it does have some dependencies (GraphViz and Java) but those are also open-source. There are loads of ways to use it, even from within your IDE. My only disappointment is that there’s no VisualStudio plugin yet.

Of course, it’s much easier to drag & drop stuff with a mouse and have lots of funky tools do things for you auto-magically. Where those “easy” tools fall down is that you need to get the software, make sure it works and runs on your set-up, have it available and understand how to use it and, most importantly, that everyone else does too. What makes this text based syntax simple is that anyone can just open the file and work with it using any text editor.

If you can ensure that everyone you will ever work with, and have to collaborate with, will have the same tools; you have the tools and infrastructure to collaborate easily using that tool and you’re sure you’ll keep access to those tools for the entire life of your project/product, then using the “easy” tools might be your best choice.

If you cannot ensure that, then you’re probably much better off looking for a simpler solution like plantUML.

 

 

 

 

Powershell CmdLet Function by Example

One of the big issues I have when writing Powershell functions is that there’s all these little structures and patterns to do things.

So I thought I’d write myself a quick guide in the form of a heavily commented function that does most of what I need. It has support for Pipelining, CmdLetBinding, ShouldProcess and comment based help.

Continue Reading >>