Docker Windows Tips and Tricks

Docker container technology makes it easy to replicate environments across different systems and platforms. There are a few differences in commands when running on Windows which you may not realize when following Docker tutorials. This post is meant to be a quick reference for Windows users as to how they should convert their commands.

Mounting Volumes in MINGW

MINGW Posix Conversion shows how MINGW converts filepaths when typed into the terminal. When mounting a volume in MINGW you should put a double forward slash in front of the entire filepath section of the command like this:

You must also make sure that the filepath you use is set up as a shared folder in VirtualBox. Docker automatically sets c:/Users as a shared folder. You can add others in the VirtualBox interface.

Using Powershell

The Docker quick start terminal in MINGW has the default environment variables pre-loaded for you. If you prefer to use another terminal, like Powershell, you need to set the environment variables yourself. Full documentation is available on Docker’s site.

First, get the environment variables in MINGW:

It will output something like this:

Then, open Powershell and past the last line from the above output (slightly modified to not return errors):

Alternatively, you can copy/paste the individual environment variables into Powershell.

Confirm it worked by checking for docker containers:

Using Bash in Powershell

MINGW does not work properly with the -t (TTY) option. Right now it seems the best workaround is to use Powershell instead. In a Powershell terminal type:

Getting Started with WAMP – Windows Development Environment

A few tips to get going with WAMP (Windows, Apache, MySQL, PHP stack)

Before you begin, download and install WAMP according to instructions. This tutorial picks up after WAMP is installed.

Fix 403 Forbidden Error

If you are getting a 403 forbidden error when you try to view an alias or directory you probably need to edit your .htaccess. For Apache 2.4.2 or greater change it like so (this is not secure and only intended for a local environment behind a firewall):

Set up vhost

1. Edit httpd.conf to uncomment this line:

2. Edit your hosts.conf file to point your desired name to your local IP

C:\Windows\System32\Drivers\etc\hosts (you may need to open as administrator)

3. Add the vhost config to apache


Restart all services and you’re done.

WordPress .maintenance mode

When WordPress performs an upgrade it puts the website into maintenance mode. This displays a message:
Briefly unavailable for scheduled maintenance. Check back in a minute.

It does this by creating a file in the root wordpress directory called .maintenance

If your site ever gets stuck in maintenance mode you can fix it by deleting this file.

If you want to put your site into maintenance mode you can create the .maintenance file using this code:

Clear form inputs with jQuery

The new(ish) placeholder attribute for form inputs is nice.. and helps get rid of the need for scripting like I’m about to show. However, it makes styling the values a bit more tricky and is not supported in some older but still used browsers (lookin at you IE9). If you choose to use value=”” to prefill a form input you can use this script to make the values disappear and reappear as the user interacts with the form.

This would go with an html form that looks something like this:

Read an MLS RETS feed with PHP

RETS is a data format for retrieving real estate listings from an MLS. It is updated in real-time and uses its own query language to retrieve just the listings you want from the server. This article will walk you through connecting to a RETS server and retrieving listings using PHRETS.

Step 1: Get Credentials

You need to get access to the MLS feed. Apply for access with the MLS provider in the relevant area. There is usually a fee involved as well as contracts to sign and rules to read. At the end of this process  you’ll have an access URL, username and password.

Step 2: Test Ports

You need to be able to connect from your server to the RETS server. This may be on a non-standard port. An easy way to test whether your firewall might be blocking access is to try to connect from your server to the RETS server using Lynx. For this example let’s say our RETS server is accessed via port 6666.

In the terminal from your server (or via SSH or Telnet) try:

If lynx can’t connect at all the firewall is a likely culprit. If it returns an error about not being able to login you’re good. That means it got through the firewall.

These instructions will help you open up a port on a Linux server using iptables. You can skip to the next section if you successfully connected with Lynx.

Allow access from the terminal

Note that iptables get reset whenever you reboot the server. You’ll probably want to set them more permanently, but that is outside the scope of this article.

Allow access from WHM

Plugins -> Config Server Security & Firewall -> Firewall Configuration

Scroll down to the TCP ports allow/deny section and add your port.

WHM CSF Firewall Configuration

Step 3: Data Structure

Ok now that you are successfully connected you can take a look at the data structure. I very slightly modified the basic connection script that comes with PHRETS.

What I get back is a dump that looks similar to this (I didn’t include everything for the sake of brevity):

To access residential properties on this feed the resource name is Property and the class name is ResidentialProperty

Now if I want to get meta data from that table I can use:

If I var_dump($table) I get an array of available fields and related info. . Here’s a small sample:

I can loop through these and spit out the SystemName to get a list like this (just a partial list to show an example of the fields you’ll have to work with):

  • AgentStatus
  • OfficeStatus
  • AssociationFee
  • AvailableForLeaseYN
  • AverageMonthlyUtilities
  • BasementArea
  • BasementSqFtFinished
  • BasementPresent
  • Bath1Size
  • BathsTotal
  • Bedroom1Flooring
  • Bedroom1Level
  • Bedroom1Size
  • Bedroom2Flooring
  • Bedroom2Level
  • Bedroom2Size
  • Bedrooms
  • DateChange
  • ListDate
  • DatePhoto
  • DatePriceChange
  • ModificationTimestamp

Step 4: Search Listings

Now that I know my resource, class and fields names I can perform a search. The following code would return all listings for 2013. I set the optional limit to 20 since we’re just testing right now. Here are more details on PHRETS SearchQuery and how to format a query.

Step 5: Images

We’ll be using GetObject and GetMetadataObject to get images.

First GetMetadataObject so we know the type of object to get.

I used the PHRETS example code to get the object type.

This returned 2 object types: Photo and HQPhoto. Again, using an almost exact copy of the PHRETS example I grab all the images for property ID 12345.

Some points to note:

  • I got the property ID from a listing in the last step (a result of SearchQuery)
  • The directory where you write the images must have permissions to be writeable by the webserver

Step 6: Practical Use

One of the nice things about RETS is the query language. This allows you to get only the results you want from the server. The RETS feed is also updated in real time as opposed to others which are updated nightly. Still, it seems more practical to me to populate a database with the info for my web app. I plan to use CodeIgniter  to both search and populate the db. I’ll create a cron job for the population and run it 1-4 times per day depending on what the client wants. The data is hand-entered by realtors (as mentioned in Drew’s tutorial) so I’ll probably do some clean-up on the data as it gets imported. That will be covered next time.

Resources and References

Node.js and Nginx Configuration

Today I configured node.js and nginx in the most basic way to get a functioning site. I’m sure I’ll have some tweaks to add later.

I started with the default nginx config and added a line at the bottom to include vhost configurations. The default config file is in /etc/nginx/conf.d/default.conf

Then in my vhost file I put this:

I’ll run my node.js server on port 8989. Using the simple example from the node.js website:

Remember to start the server by running the script.


Node.js and Nginx on CentOS 5.8

I’m using this gist as a guide for my setup. Nginx will listen on port 80 and serve static files, it will pass other requests to node.js on another port.

Install Nginx

Nginx has binaries for CentOS. I grabbed their rpm to configure yum so I can use it to install nginx.

Update Python

My box came with CentOS 5.8 32 bit. This version of CentOS comes with Python 2.4. This is a problem if you want to install node.js which requires Python 2.7. I’ve read that CentOS relies on its specific version of Python for other parts of the OS to work. This was starting to sound complicated. Then I discovered Pythonbrew. It allows you to easily switch between python versions. Hooray!

Pythonbrew and node.js have some dependencies so you may first need to install these. Be sure to get the right package for your OS. (32 or 64bit)

Finally, install pythonbrew

Add lines to the end of .bashrc

Install Python 2.7.2 and switch to use it.

 Install Node.js

We’re finally ready! We’re just going to grab the source from node.js and compile it. (Use whatever is the current version at the time you are doing this)

Yay!! We are done. Next we’ll configure nginx and start a node.js app.


HTML5 Game With My 4 Year Old Daughter

I made this (hysterical) game with my 4 year old daughter. It took us a couple hours. We used Scirra’s game making software Construct 2, starting with their template for “top down shooter”. Overall I was impressed with the ease of use. It had a mild learning curve. My children wouldn’t be able to use it on their own at first… but with a little instruction I think they could manage. We have more experience with Microsoft’s Kodu which is a little easier to use.

The neat thing about Construct 2 is that it can output the game as javascript and html5 to be played on any browser. They use the jQuery library. They also have options to export to Phone Gap, Chrome Web Store, node.js and many more.

I think next we’ll try out Game Maker Studio by Yoyogames.

I’d also like to try out these.

About the game

My daughter wanted the main character to be a ballerina, and she wanted her to dance. So, we did a quick image search and found this poster which I cropped and turned into an animated gif.



Then we needed a monster.


We made the game so the monsters can bump into each other. This is called having a “solid” behavior in Construct2. If they bump the ballerina enough she dies and the game is lost. If she shoots all the monsters the game is won (or she can go onto level 2 which we haven’t made yet)

The controls are spacebar to shoot and arrows to move.

We used the royalty free song “Local Forecast” from

Play the game.

SimpleXML Element Missing

Doing a var_dump of a simpleXml object will not show namespace elements. You need to grab them using $xml->children();

Here is an example.

Using var_dump($xml) or print_r($xml) would only show the name. To get the georss do this:

To get the type of name