Uncategorized (20)


MVC Architecture 2

In my previous post, I explored the idea of introducing software development principles to the world of infrastructure, specifically the translation of the ‘MVC’ design pattern to logically divide infrastructure into 3 distinct layers.  Today I’m going to take a look at each of these layers in more depth, and examine how they fit together and what benefits this logical division offers.




piCraft source on github

Finally got round to releasing my (very rough / early) raspberry pi interface for minecraft on gitbhub.

It’s still in a pre-pre-pre-alpha state, it’s just the sourcecode (although it runs in the development environment fine) so feel free to do what you want with it.

You can see what picraft is / what you can do with it here:




Magento: Sort search results by newest first

I recently (well, a few months ago) started working for online retail company prettylittlething.com.  Since then I’ve been getting back into the Magento way of doing things (along with managing their IT infrastructure… but that’s a whole other set of posts) and decided I might as well publish some of the minor tips and bits of code I’ve worked on.

Today I have a module that ‘fixes’ the default search order in magento.

By default, when you do a search in magento the results are shown in ascending order of creation.  IE: older products are shown first.  Now, I’m sure there’s some obscure reason why this is so (although it could just be that with no search order defined they’re pulled out in the order they went into the database) but anyway, after some googling and a bit of tinkering I have a fix for it.




Space Editor 0.9.4

Pretty big update today, I’ve finally (after like…a weeks worth of struggling) managed to get modular building working. This means you can construct ‘modules’ (ie: parts of ships), export them, then import tham and attach them to other ships.

Here’s how it works:

I use the ‘White inverted corner block’ as an attachment point (this isn’t configurable at the moment, but I’m hoping to make a new blocktype soon and use that instead. For now though, don’t use that white inverted corner piece for anything else). So, make your ‘module’ and stick one of those blocks on it. Pay attention to its orientation!

Now, export that module in space editor.

Then, create the ship you want to attach the module to. Put a white inverted corner piece where you want the module to be attached. Again, pay attention to the orientation… your module will be rotated so its attachment block is orientated the same way as the one on your ship.

Load up your savegame in space editor, select your ship, select ‘Import module’ and navigate to the module file you exported earlier.

And that’s about it.

It’s been pointed out that to use the import module option (which relies on the space engineers library) this version needs to be installed in the same place as space engineers, which (for the steam version) is in:

c:\program files (x86)\steam\steamapps\common\spaceengineers\

I’ll work on creating a proper installer for the next version, but for now you’ll have to manually stick the space editor executable in there.

Download from github




Space Editor 0.9.3

Quick bugfix,

added warning about quick load stability

Download from github




ExtendedLife.co.uk

After a month or so of effort in my spare time, the new version of ‘Extended Life’ launches today. From an original site running joomla with the Hikashop plugin, I’ve migrated to a Magento based store with an integrated wordpress site. A responsive theme is used to enable a decent mobile experience, and the increased performance and sophistication of magento should ensure that sales increase as well!

Click the image below to go to the site.

Capture




Contact form snafu!

I’ve just realised that my contact form hasn’t been working… probably since I implemented it.

So if you’ve been trying to get in touch with me with offers of riches beyond compare, or just to say hello… try my new, improved (ie: actually working) contact form:

http://www.tall-paul.co.uk/contact-m/




Motion control with multiple cameras

I got a bit bored of playing with node.js over the weekend, so I dumped some time into my home security system (which is a grandiose title for what’s basically a couple of cameras and some software) and have now got it into a reasonable state, so I thought I’d write a quick post about it.

The idea of having some sort of security system in my house came about recently because I’m starting to spend more and more time away from home with my lovely fiancee so I wanted something to keep an eye on the house whenever I was away.  I did some googling and found this bargain basement IP camera on amazon:

 

 

The price seems to go up and down on a daily basis, and there’s a few variations on the same basic model but I got mine for £33 and it offers wifi, pan and tilt support (it has little motors that you can move the camera orientation with) and motion capture support.  All sounds rather spiffy.  And indeed the camera itself is pretty good.  The fact it actually has infra red illuminators on it means it can see in the dark remarkably well for such a cheap device, and I had hours of fun messing around with the motorised movement.However after a bit of playing with the motion capture I decided it was a rubbish (it can only send still images over ftp or via email, not very useful) so I decided to have a bit of a play with the rather awesome motion.

After some teething issues I discovered you can set these IP cameras up quite easily using a url like ‘http://HOST/videostream.cgi?loginuse=USER&loginpas=PASS and from there it was pretty straightforward to get motion detection configured (although there was some fine tuning needed to the parameters).  I set up motion to save any captured images / videos into a dropbox folder and voila… DIY motion capturing security system with offsite backup.  I’ll be buying another couple of these cameras in the near future and adding them to my setup.

One problem with this setup is motion’s interface.  There’s a basic web server built in, but if you have multiple cameras it launches a new thread for each camera, and you control motion detection for each thread independantly.  So with two cameras you have to go to 2 urls to enable or disable the motion detection.  Fear not though, I’ve written a little python script that prompts for a password, and then enables or disables all your cameras at once if you enter the correct password.  It shouldn’t be taken to be anything like secure (I don’t even have a username / password set on my motion install since it’s only accessible on my internal network) and you can ctrl-c out of the script at any time…… but the long term plan is to setup a raspberry pi with a little lcd screen and a numpad and use that as the controller…. maybe rig it up to play sound files when activating / deactivating the motion detection.  Anyway, here’s what I have so far, enjoy! (also, this is my first attempt at a python script that actually does something useful, so please excuse any stupid errors in here)

#!/usr/bin/python
import getpass
import requests
import os

#we always assume that all cameras have the same status
def get_status():
        response = requests.get(url= host+"/1/detection/status")
        if response.status_code == 200:
                if "PAUSE" in response.text:
                        return 0
                else:
                        return 1
        else:
                return -1

def toggle_status(current_status):
        if current_status == -1:
                return
        if current_status == 0:
                path = "/detection/start"
                out = " started"
        else:
                path = "/detection/pause"
                out = " stopped"
        for x in range(1,camCount+1):
                response = requests.get(url= host+"/"+str(x)+path)
                if response.status_code == 200:
                        print "Camera "+str(x)+out
                else:
                        print "Error with camera "+str(x)



camCount = 2
password = "PASSWORD"
host = "http://HOST:PORT"

while True:
        os.system('cls' if os.name=='nt' else 'clear')
        status = get_status()
        if status == 0:
                print "Motion detection disabled"
        else:
                if status == 1:
                        print "Motion detection enabled"
                else:
                        print "Error determining status"
        input = getpass.getpass("Enter the passcode: ")
        if input == password:
                toggle_status(status)



Random idea: Password storage in the event of an untimely incident

So, I sometimes get random ideas and then never develop them… I thought I might as well write them down somewhere so next time someone makes millions from an idea I had ages ago I at least have something to back me up 😀

Anyway, here’s the idea: A service that provides encrypted data storage that can be unlocked by trusted people in the event of your death.  You’d encrypt anything you like (credentials for websites, documents etc) using a public key in an asymmetrical encryption scheme (like pgp for example), upload it to the site and then give the private key to someone you trust, or a few people.  To guard against them looking at your data willy nilly, you could require data requests to come from multiple people, or have a 2 day waiting period for data and email the account holder with a notification…

So yeah, that’s what just came to me while I was doing the washing up.  If you implement this and make fat stacks of cash, be nice and kick some back my way, ‘kay?




Node framework: login authentication

My simple node framework now supports password protected areas, with a username / password authentication scheme based on passport.js.

You can see this in action here

Next on the to-do list is an automatically generated admin framework, to enable simple manipulation of the database backend based on the models your app defines.

I’m also going to integrate the Aloha editor for front end content management.

The end goal is going to a be fully functioning content management / blogging platform that also has the capacity to be extended into…well, just about anything you can imagine.