Blog


SpaceEditor Released

(I’ve since released a newer version of this software, which you can find here)

Just a quick post about a project I’ve been working on over the weekend: SpaceEditor.

Capture

This is a basic savegame editor for the really rather excellent ‘Space Engineers’ (which you can find on steam here: http://store.steampowered.com/app/244850/?snr=1_7_15__13)

The game itself is a bit basic at the moment, it’s still in ‘early Alpha’ stage, so there’s not actually a great deal to do other than build ships and crash them into things. One thing that’s conspicuously missing at the moment is the ability to save / load your creations. You can save a whole ‘world’, but extracting your design from that world just isn’t enabled…yet.

That’s what this tool is aimed at. The current feature set is:

Load a save game (you need to browse to the ‘SANDBOX_0_0_0_.sbs file in your savegame folder)
Export any ships from that game into files (Make sure you have a ship entity selected in the tree before you press this!)
Import ship files back into a save game
clone a ship within the world (again, you have to have a ship entity selected!)

And it lets you do stuff like this:

SpaceEngineers_2013-10-27-11-10-33-550_FinalScreen

I’ll be open sourcing the project as soon as I’ve tidied it up, but for now you can grab the executable here:

*UPDATE* check here for the latest version: http://www.tall-paul.co.uk/category/coding/space-editor/

WARNING: this should be considered even more pre-alpha than the game itself. If it completely mangles that ship you just spent 3 days building, don’t say I didn’t warn you. Because I did. Just now.

Edit: New version released, this should be much quicker at loading…. I’ve updated the download link.




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




Category based shipping in magento

One of the things that’s always annoyed me about Magento is the dearth of decent, free shipping modules available for the system. Out of the box you can do a reasonable amount with regards shipping, setting a flat rate or using one of the built in shipping methods…but if you want to do anything fancy (and in my experience, people always do) then you need to pay out for one of the many customisable shipping modules available.

It’s been nearly a year since I last looked at Magento, but a recent freelance project has meant me getting back into it and as the client has some very specific shipping requirements, I thought I’d write my own shipping module. I spent a few hours fiddling with config files, before rememebering why Magento always annoyed me so much (hint, it’s the config files) and used the rather brilliant magento module generator to get me started.

Here’s what I wanted from a shipping module:

  • Different shipping rates for individual products
  • Different shipping rates to different countries
  • Easy assigning of shipping rates to products

So, to tackle these problems I came up with a module that uses Shipping rules defined through categories. This means you can setup your rules, and then use the standard product / category concept in Magento to assign your shipping rates.

Once you install the module (see below for a download) each category gets a new attribute under its ‘general’ tab, named ‘Shipping’. That’s where you enter your rules. Rules are extremely simple, and consist of a series of lines, each of which is made up of ‘country code’ = ‘price’

here’s an example of one ruleset:

Capture

This translates to ‘If the delivery address is in the UK, free shipping. If it’s in the European union, shipping is 3.00, for the rest of the world it’s 5.00’.

You can have as many lines as you want (they’re processed top to bottom) and if you have multiple items in your basket that produce different shipping rates, the most expensive rate is picked (there’s no option to sum the rates together yet, I might add that in at some point).

You can add these rules to your actual, published product categories or do what I’ve done for this client and set up a seperate tree of ‘Shipping categories’ like so:

Capture

So there you go. Bit basic, but does what I needed it to do.

Here’s the download link (upload the ‘app’ folder from the archive into the root of your magento installation):




Play spotify through a different sound device (windows)

Just a quick post today about how to solve a common (maybe) frustration…

My setup when I’m working is that I sit at my desk in the kitchen, with spotify open to have some nice background music going on. However, my nice amp with its decent bass levels and all the rest is sat in the living room. That’s not really a problem, since I have one of these which allows me to play music from my laptop via bluetooth to the amp. However, the standard setup in windows means that you have one ‘default’ sound device, and that’s the one that spotify uses. So if I want my system sounds to come out of my laptop speakers (rather than, for example, conducting skype conversations via my amp) it means I have to play music through the laptop speakers as well.

Until I found this:

http://www.equalify.me/

With the simple addition of this rather wonderful piece of (free update: equalify is no longer free according to comments from readers, it now costs $5) software I can happily play spotify through my amp via bluetooth while keeping everything else through my ‘default’ laptop speakers.

Here’s how it works. First, in windows select your default audio device. Remember, this should be the device you want everything except spotify to play through.

The easiest way to do this is to right click on the volume mixer icon in your taskbar and select ‘playback devices’. You should see a window like this:

Untitled

right click on the device you want to use as the default (if it isn’t already set as such) and select ‘set as default’. Again, remember this is the device you want to play everything except spotify through.

Now, download and install equalify from here: http://www.equalify.me/?page=download

Once it’s installed, fire up spotify and you should see a new icon next to your search bar, like this: 1

Click it, and the equalify window should open at the top left of your spotify window. Right click on the equalify window and wight click to activate the context menu. Select ‘options’ and then ‘change sound device’ like so:

Untitled

From the window that pops up, use the drop down to select the audio device you want to use and then click ‘Set New Output Device’:

Untitled

Now restart spotify.

And that’s pretty much it, spotify should now play through the device you selected.

As well as allowing playback through different audio devices, equalify also acts as an equaliser… if you like that sort of thing.




All grown up: Monsters inc

This is the first in what may (or may not) be a regular series, which takes the universe of a children’s classic and intersects it with the cynicism and harshness of reality…. I thought I’d start with monster’s inc, since the idea of monster’s being able to pass into our world whenever and wherever they like lends itself to some interesting ideas.

1: Monstropolis

Sulley lent back in his chair, letting out a sigh of relief as the tension drained from his shoulders. These last 5 years had been tough, changing the way an entire civilisation procured its energy, not to mention changing the direction and mindset of a huge corporate institution…it hadn’t been easy, but things had finally started to turn around. He glanced at a framed picture on his desk, ‘Boo’, the little girl who’d made it all possible… she’d shown that human laughter was a much stronger and more energetic source of power than the traditional fear, and in doing so had paved the way for everything that had happened since their last meeting. Sulley smiled wryly, now that the conservative old guard had finally been put down and their leaders exiled in one of the strange worlds on the other side of the barren doors he could really start to consolidate his powerbase. It was a pity about Mike, if anyone deserved to be a part of the shining future that lay ahead it was him… but at the last minute the cyclops had blinked, his nerve had broken and Sulley had to choose between their friendship and the greater good.

The intercom on Sulley’s desk flashed, interrupting his reverie. The display indicated it was Dr Hertzner in the research labs, his permanently worried face filling the small screen.

“What is it Doctor?” asked Sully, trying to keep the impatience out of his voice. The Dr’s research project had hit some stumbling blocks recently, the new doors opening onto strange universes filled with physical impossibilities. Some of the explorers had come back… changed. Some of them hadn’t come back at all.

“We’ve found her.” The doctor found himself talking to an empty screen. On hearing those 3 words, Sully had leaped from his chair and was already bounding through the complex towards the research labs.

Boo, the girl who had catapulted Sully into a position of power… her door had been lost, presumed destroyed during the civil war but now, after months of probing the human universe with exploratory doors the doctor had finally found her again.

“we have no way of knowing how old she is you understand” The doctor’s monotone voice, more attuned to the lecture hall than the halls of power he now moved in irritated Sully as he gazed at the door in front of him. “Time in their universe is… different than time here. Once a doorway is established the flow of time is synchronised between a specific pocket of space on the other side, traditionally a child’s room but as we’ve seen with our recent..”

“Yes yes Doctor” Sully cut him off impatiently “So she may be much older than I remember, I understand… now stand aside”

The Doctor sighed and moved to the control console next to the doorway. The Ancients, founders of the monster civilisation now lost in the mists of time, had passed down grave warnings about the kind of research he was now involved in. The master control mechanism threw up a set sequence of co-ordinates for the doors, using those co-ordinates invariably created doors that led to the rooms of children in the human universe. The Doctor’s use of unapproved co-ordinates and the realisation that other worlds, other people lay on the other side of those doors had led to the priesthood’s revolt and the blood strewn mess of the civil war.

“Open the door Doctor” Sully grunted “I’m ready”

The Doctor made a final adjustment on the control panel, overriding the warning lights that just a few short years ago would have meant this door was consigned to the ‘never use’ scraphead and made the connection…

2: The human world

Somewhere else a similar warning light flickered into life. Rather than override it though the man watching this light stared, almost disbelieving what his eyes were telling him. After an almost comical double take, he picked up the phone next to his desk and almost yelled down it “It’s…it’s happening, get the director… she needs to see this”

In another part of the complex the director was dragged from her recurring nightmare of a snake drilling into her skull, back into the land of the living by the insistent blaring of the red phone she kept next to her bed. After a brief moment of confusion, she snapped into alertness and grabbed the handset. Minutes later she was running down the hallways towards the lab, her mind racing. It had taken years of waiting, millions of dollars of funding but the moment she had waited for had finally arrived. She was going to finally get her own back on that blue bastard who had swanned into her life, taken her from her home and subjected her to an ordeal she’d never truly recovered from. If it hadn’t been for the institute, a group of shadowy figures who understood what she’d been through and, more importantly, believed her she’d probably still be rotting in St Genevieve’s now. The institute had existed for in one form or another for decades, and their sole purpose was to research and eventually destroy the strange world of ‘monsters’ that had been haunting humanity for centuries.

Her gaze flickered to the side as she passed the entrance to the vivisection labs. In recent years the incursion teams had made great strides in capturing specimens of exiled monsters, apparently there’d been some sort of power struggle on the other side of the doors and the losers had been dumped unceremoniously over here. Although they’d been scattered across time and space due to the strange quantum effects that surrounded the interdimensional portal technology several of them had ended up in the 20th century to be captured by the incursion teams, interrogated and finally dissected… their bodies giving up hints that had led to the construction of the laboratory she now raced towards.

She arrived in the observation room to a scene of tense anticipation, looking down into the replica of a child’s bedroom she had a brief pang of nostalgia…the bedroom below was based on her own memories of her childhood home. The ‘child’ in the bed was a lifelike dummy, but it was the glistening metal box next to the bed that her eyes were drawn to. It had been discovered very early on that the portals, the doors that the monsters used to make their raids into this world were drawn to children. Prolonged research had finally discovered the strange quantum vibration produced by a child’s mind, a unique vibration that each doorway was attuned to. The supercooled box below contained a piece of the Director’s own brain tissue, clone cultured to resemble that of a child. She’d hoped that this would be enough to fool the weird, poorly understood science of the other side… and it seemed her gamble had finally paid off.

Light filled the room below, creeping out from around the doorway that stood in the shell of a closet. The director held her breath as the handle started to turn..the door slowly opened and, silhouetted against the light flooding through from the other side stood a figure she recognised from her nightmares

“Boo?”

That one word, a hesitant question from the huge blue monster now creeping across the floor broke the strange paralysis that afflicted everyone in the room. The director blinked, and slammed her hand down on the red button next to her station. Below, Sulley froze as lights flared around him… and a few feet away, in another universe Dr Hertzner stared in horror at his control panel as the emergency shutdown failed, the doorway held open from the other side as blackclad troops poured into the laboratory.

Sulley looked up at the woman glaring at him from the observation room above… no longer the child he was expecting, but he’d finally found her.




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/




Mortix.net on indiegogo

So, today I announce a new project I’ve been working away on for the past few weeks in my spare time.

Mortix.net.

Still in the prototype stage (so the website isn’t up and running yet) this is a secure platform for developing apps that ensure your privacy on the internet.

Check out the indiegogo campaign here for more information.  And spread the word!

 




DIY security keypad

After my couple of hours of tinkering with python yesterday (see here) I started pondering how to expand on what I’d done.  Some sort of keypad would be handy, so I could just tap in a code and disable my cameras…. and then I’d need something to run the code on and connect the keypad to….Oh, and some way of indicating whether the cameras are currently enabled or disabled would be nice.

Luckily, I still had my trusty raspberry pi sat around doing nothing, so that solved the platform issue quite nicely.  The debian install for the pi already comes with python, so it was trivial to get my code up and running…. now I just needed a keypad.  I did look at something like this:

£10 from amazon might seem like a bargain, but I already had a spare usb keyboard sat around.  If only I could use that.  Well, that’s where some hacking came in handy:

2013-05-28 19.31.43

 

 

Somewhat astonishingly, the numpad bit of the keyboard still worked after my delicate surgery (I got lucky and happened to have a keyboard that responded well to being cut in half.  your mileage may vary).  So now we have a platform for the code to run on, and a number pad to enable or disable the cameras…it would be nice if we could determine whether the cameras are enabled or disabled though.  Handily, we can!  Pretty much every keyboard has a selection of LEDs on it to indicate the status of the ‘locking’ keys (caps lock, num lock and scroll lock) and my hastily hacked up masterpiece was no exception.  And it turns out it’s fairly straightforward to control these lights in python (although you do need to have root privileges to do so.  Why?  because linux that’s why) .

So, with a bit more googling and some slapping together of code here’s how it all works.

The pi is set to login automatically on boot (using the info here) and starts the python script (source below).  The script then queries motion for the current status, and sets the scroll lock LED accordingly, before waiting for the user to enter a passcode.  If the passcode is incorrect the lights on the keyboard flash on and off, before returning the user to the ‘enter passcode’ bit again.

Here’s a couple of images of the ‘mounted’ number pad (sellotape is brilliant!):

cameras off / cameras on.

 

2013-05-28 21.04.36 2013-05-28 21.04.43

As well as some tidying up, I want to do some more work on the python script (I’d quite like it to poll the cameras while waiting for input, and flash the capslock key as a ‘heartbeat’ indicator) but here’s what the code looks like so far:

 

#!/usr/bin/python
import getpass
import requests
import os
import fcntl
import time
import pwd
import grp

KDSETLED = 0x4B32
SCR_LED  = 0x01
NUM_LED  = 0x02
CAP_LED  = 0x04

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"
console_fd = os.open('/dev/console', os.O_NOCTTY)
enabled = SCR_LED | NUM_LED
disabled = NUM_LED
error = CAP_LED
all_off = 0
all_on = SCR_LED | NUM_LED | CAP_LED

while True:
        os.system('cls' if os.name=='nt' else 'clear')
        status = get_status()
        if status == 0:
                print "Motion detection disabled"
                fcntl.ioctl(console_fd, KDSETLED, disabled)
        else:
                if status == 1:
                        print "Motion detection enabled"
                        fcntl.ioctl(console_fd, KDSETLED, enabled)

                else:
                        print "Error determining status"
                        fcntl.ioctl(console_fd, KDSETLED, error)
        input = getpass.getpass("Enter the passcode: ")
        if input == password:
                toggle_status(status)
        else:
                fcntl.ioctl(console_fd, KDSETLED, all_on)
                time.sleep(2)
                fcntl.ioctl(console_fd, KDSETLED, all_off)
                time.sleep(2)



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?