Serve Django HTTPS over localhost


The easiest way to do this is to use an app called django-sslserver.

It adds a new management command that serves content over SSL, and generates its own certificates.

I had tried things like stunnel… and ultimately this was the easiest solution.

I need it purely to test a Shopify app which must be served over HTTPS.

Django 400 Bad Request, even with Allowed Hosts


I just had to break down django itself to understand why I could not get rid of my error.

It turns out underscores in domain names is invalid according to the RFCs.

Make sure your domains do not have underscores. If they do, you’ll have to patch django’s host validation function:

host_validation_re = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9:]+\])(:\d+)?$")

Apple Bluetooth Keyboard – When All Else Doesn’t Work


NO bluetooth devices were working on my computer, suddenly (yosemite).

– Hold down the power button continuously. Check.
– Remove batteries, turn off bluetooth, add batteries, power up, turn on bluetooth. Check.
– Fresh batteries. Check.
– Distance / remove all other BT devices. Check.

A good old restart fixed my problem instantly. Instant pairing request / detection of my devices.

It looked to have installed an update on startup, so it was a much needed restart.

Watch a child property / array with AngularJS


Turns out you cant. You’ll find a lot of people jumping to $scope.$watchCollection, which triggers on inserts/removes/sorts, but not updates.

You can watch all changes on an array simply by passing it $scope.$watch(‘myarray’), but that triggers on any change and doesn’t target a particular array item.

The answer is really to generate a child controller with a child scope.

<div ng-repeat="item in items" ng-controller="ChildController"></div>

app.controller('ChildController', function($scope) {
$'itemProperty', function() {console.log("Child property changed")

Solution to sudden inertial scroll loss issues, and scrollTop() == 0 on mobile


The sudden loss of inertial scroll on one of my websites has had my head scratching for literally a year.

When I ran into it again, alongside issues with scrollTop() always returning 0, and being unable to move the viewport on mobile, I stumbled across the fix: html/body must NOT have a height set to 100%.

Sadly, the sticky footer solution I use requires 100% height (and no min-height will not work). Ultimately I have ended up repeatedly using both media queries, and JS based platform detection to target styles most effectively.

There it is though: if you have issues with inertial scroll loss or scrollTop not functioning, check if you have html/body set to 100% height.

HTML Tidy Sublime + Django Remove %20 Characters


The HTML Tidy plugin for Sublime is amazing when people like to code with no line breaks.. but by default breaks django tags by converting spaces in django statements to %20.

I found HTMLTidy has a suspicious option called "fix-uri". Disable that in your sublime package preferences (you’ll have to add the key/value yourself) and voila everything is clean!

Ultimately, I use HTML Tidy to indent, not modify my code.

"fix-uri": false