PHP projects, Arduino and work

New post!
It's been so long since I last posted here I've almost forgotten how!
You all have no idea how much nagging I've had from Kevin in the past couple of months to blog >.<
So, after all that time, here it is. The bumped blog post of doom!


Face Detection & Mandelbrot
A few weeks ago now Kevin was asking me how to do face detection.
This brought my old image filter script back to mind, as it was initially meant for the first part of a face detection script that used a mean filter to smudge up faces and make colour matching a lot easier. I never really got that far however, so my script remained just for filtering images.
Kevin had found an article on a much simpler method that just used plain colour detection methods but was having an awkward time implementing the concept into working PHP code that could cut out everything but skin tones. After asking me to take a look, and me putting it off for a day or two, I sat down and worked out a small and simple implementation of it.
I'd like to add better features, like using the result of this script to find individual faces, border them and then run feature detection on the original image to cut out false positives, try to get the whole face instead of cutting out eyes/mouths, and to get orientations and such, but that would require more free time than even I have!

The simple implementation is: http://sandbox.palmnet.me.uk/fd.php?face=http://www.centocor.com/centocor/images/people-1.jpg

I did have enough free time however to help Kevin with another PHP/image thing he wanted to try but couldn't get quite right.
He wanted to draw the Mandelbrot set with PHP/GD and so when it didn't quite work out and the maths got sticky he asked me what I knew about the Mandelbrot set and fractals.
Maths was never my strong point and I didn't even take it pas AS Level. Thankfully I know lots of mathsy people and still do my own learning from the webernets and books from the uni library when I get a chance.
So complex numbers were easy and the Mandelbrot set equally so.
After an hour or so of tinkering in Notepad++ I had something that roughly did what it was meant to:
mandlebrot set

Kevin wanted more though, so he tweaked my code to generate this wonderful looking image at an utterly ridiculous mammoth size, which can be viewed by clicking on the thumbnail:
fancy rainbow Mandelbrot set

Source code is available: http://sandbox.palmnet.me.uk/testbox/codebox/index.php?module=snippet&id=705

Arduino
I got my lovely Arduino through the post a month or so ago and have slowly been accumulating components that are either cheap or can be scrounged from companies as samples.
With what limited supplies I had, a potentiometer, MAX2221 and a simple 8x8 LED matrix, I was able to make a lovely version of pong however!

See it in action on Youtube: http://www.youtube.com/watch?v=7uOF9KcOp8g
Code for the arduino: http://sandbox.palmnet.me.uk/testbox/codebox/index.php?module=snippet&id=901

I have also started work on a version of the copter game for the arduino using LED matrices, but since starting work I haven't had much time to finish it off.

London & Work
As mentioned before, I'm a university student who has a placement year where I go and work in the industry that I hope to end up in. And that year is now!
I started work a couple of weeks or so ago and so far it's actually really good. The work seems to be about my level, the people are interesting and definitely know their stuff; And despite the fact everyone else there is from Surrey university I know almost every bodies name now and have fitted in well :)
London is a bit crap however. Busy, expensive, smelly and generally a bit lame so far. But the flat I have with Phil means that things are cheaper than commuting and more interesting.
I will post about what I'm actually doing at work when I get round to doing something. So far I'm stuck in training, and will be for a few weeks yet, and won't really be doing much apart from reading, testing things out and practicing. Lots of crazy XML stuff like you've never seen, Oracle database stuff which is new to a poor student like myself who's used to MySQL and SQLight, and some bespoke back-end server software which though utterly ridiculous and archaic is very good what it does, or so I hear anyway.
If I do anything fancy I might even post the code here as I'm not sure anyone outside the company and a couple of oracle conferences will have ever seen anything like this, I know I certainly haven't.

Uni results
I finally got my university results back for the second year last week. And while not great, I did pass with a 2:2 which is pretty good considering the sheer volume of rubbish business modules I had to do this year!

Project ENFRAME
Phil has enlisted me to code some stuff for a new project of his, currently under a codename of 'Enframe' which we took from a folded t-shirt and prefixed an E to.
Seems like a fairly reasonable idea, and I hope to crank out some code for it shortly to see how it would function, but until we decide exactly how it'll function and if people are interested I won't bother saying much.
But if I'm coding anything in the next few months that isn't for work then it's probably going to be this.

Status script
Another thing Phil has told me to do is my status script.
This should be a nice, feature rich, replacement for the Status2K script that he currently uses to monitor the server, which runs this site and served up this blog for you :)
The main advantage of my script would be the customisation as Status2K isn't free, and so has encrypted source with ionCube, meaning you can't fix any bugs that their lazy support guys can't be arsed to fix. And as the script will most likely just be for us we can make it very server specific and get some interesting stats :)




Animated GIF captcha

Man, captchas suck.

I think we all agree that captchas are fairly useless and more often than not cause more annoyance than good.
Most captchas are easily broken if someone sets their mind to it. Especially the one that came with this blog script! And even if they do stop bots they also stop blind or visually impaired people from using your system too.

But they are an unfortunate necessity, especially on the high traffic parts of my site like the mini polls where there's currently a captcha I hand coded especially for the mini polls. And so far I'm shocked to say I've not had any spam on there except the usual human spam.
However, today I have constructed an uber-captcha, which I quite like. It is slightly hard to read though.

This new one uses just PHP, no separate app (not possible on this server) or anything like that, and it generates an animated GIF file where every frame is totally unreadable, but when animated together it becomes readable to the human eye.
That's the idea anyway. I might have gone a bit overboard with methods to try and stop people using image filters on layers to get readable text again and it's now fairly hard to read: (hit esc in Firefox to stop it looping and see how messed up a single frame is)

New captcha

Anyway, feedback would be great on this. Any ideas on what I could do to make it more readable, yet still being awkward to crack.
Also, anyone who cracks it with their own code (no script kiddies) wins a free sandwich :D Fancy code or code in an esoteric language gets you a coke to go with your sandwich!

To play around with it and see what percentage of them you get right go to http://sandbox.palmnet.me.uk/gifcaptcha/, let me know what scores you get in the comments.




Stats, Polls and other projects

Stats
The stats are in from last month and they're pretty good for such a small site like this.
As of 31 Mar 2009 - 23:59 I had:

  • 23, 332 uniques
  • 1, 317, 979 Hits
  • 908.78 MB Bandwidth used

Though that only sounds like a small amount of bandwidth, roughly 85% of hits were to the bar images from the mini polls, and they're only 200 bytes.
So to get over 900MB from that is fairly impressive!

I don't think I'll ever get stats as good as that again so I'll have to thank Rob Manuel, co founder of B3ta, who got me 99% of those stats for using my poll script and for crediting me on e4 where he used the results gathered by the mini polls.

If anyone else uses them for something interesting do let me know :)

Polls
Like I said before, if anyone uses them for random or cool things please let me know. And don't be shy to suggest a feature, let me know of a bug or even propose a whole new project to do if you think it'll help you or others.

I did do some updates to the mini polls since I last blogged about them, so don't forget to wander over and take a look at what's new. I really need to come up with more creator options, like specific colours and such. Also the create page won't let you add new options without javascript which is a pain. But as they aren't overly important I'm putting them off for now.

Other Projects
I've been carrying on with work for a new version of Palmnet. So far I've re-done all the work I had before to make things easier, play together nicer and to implement some of the things I've learned lately from reading online and hearing things in lectures.
Lots of work will have to be done on the way all my projects are handled though as currently it's a total free-for-all when I make a new project, with no set order, file placement or even links to it. All that will have to be changed to conform to a while heap of new rules I'm setting for myself. And a lot of projects might get some re-writes and updates so that they can be put in the new system and be presentable if open sourced :)

Somebody on a forum I go to the other day jogged my memory on the new shoutbox system. I did a little bit of work on it but am kind of stuck with how I can do plugins for the image rendering script. If anyone knows much about that kind of thing, mostly just theory of plugins and modularity, please get in contact!
I seem to just have functions that need to go everywhere, data that needs to get altered and all sorts of crazy things. So it might take a while yet. Other than that, there is an API that's almost done, the RSS is done, the basic image rendering script is done, the posting script is done, the filtering system is done...It's all coming along, slowly.

There are a few other things that I'm currently working on for uni too which are taking up quite a bit of time, especially team projects and the joys of ASP.Net... So I can't fully dedicate all my time to coding for myself like I used to. Which sucks, but priorities are priorities I guess.

The other random projects I'm working on in secret are coming along nicely though, and I thought of an amazing one to start today, though it requires C# skills...skills which I might not have yet. But if/when I do, prepare for massive amounts of blogging full of awesomeness icon_biggrin




Work, paid work! And a little project news

Work
A few people may know I finally got hired to code for a living. Clear Design are awesome people and are all equally awesome at what they do.
I've been set the task of making them a new intranet system, which sounds fairly easy and it is on paper. But I'm using CakePHP which though technically should make for 'Rapid Development' it has slowed me down a bit because I have to keep googling things and reading the API documentation. That coupled with bad documentation and me using an release candidate version make for some slightly slower coding time!
However, I'm starting to get the hang of Cake now and things are coming along nicely. If only the data validation part would play ball too.
I'll probably post some screenshots when I take it past the "it kinda works" phase so you can all see the wonderously fancy things I've been up to.
At work I also found out I'm not to shabby at table football either. At least 5 times as good as I am at real football anyway!

Projects
Webserver
I wrote a little webserver many years ago in VB6. It totally sucked and could barely do 1 get request for a html file.
I found the code for it the other day and started to give it an overhaul. It now handles multiple requests at the same time, does all sorts of fancy logging, supports any file now, not just html and it's also got a half done PHP CGI going on. Still no use for it, but it might be handier to have on my USB key than the mammoth yet almighty apache. So not that interesting but still a nice little project I revived to re-live the good old days :)

GifCaptcha
I was getting a bit of spam on the minipoll system and considered using a captcha system. I don't use captchas anywhere normally for the same reason I don't have adverts: I hate having them myself, why make others have to do them?
Anyway, normal captchas are boring, and kittenauth is a bit overkill despite its awsomeness so why not be interesting myself, thinks I. I'll make a captcha in animated gif format, so that each frame is really badly distorted to stop captcha cracking bots, but when all the frames are put together it becomes visible to humans due to POV.
It's not the greatest bit of code ever and still fairly easy to beat too, but it's different :) Unfortunately I'll never be able to use it on Palmnet as it uses a third party program to convert the still images to the animation, and I can't run that here. But it was a good little script I wrote so I thought I'd mention it anyway.

MNAH
Still living up to it's acronym I'm afriad, but perhaps once work dies down a bit I'll have more time, but plans are still there, don't worry.




Mini Polls updates

Just done some little updates to the minipolls script which I thought I'd share. Mostly to try and stop any vote rigging but I also added a couple of optimisations and such behind the curtain of code:

  • Security
    1. Vote page button to stop making people auto-vote
    2. Store voter referrer to help identify vote riggers
    3. Store amount of times one user votes on a poll ro help identify vote riggers
  • Optimisations
    1. Cut out a large and messy SQL statement while voting
    2. Slightly improved bar rendering
  • Improvements
    1. Added vote count on popular polls / options
    2. Shorter wait time between votes

Anyway, if you have any suggestions then I'll always try my best to make them work. Future plans are to have custom vote times and an easier way for me to ban certain people.

Oh, and I'm about to start work on tidying up the syntax highlighter too, so prepare to be amazed! Or at least mildly bemused...




Mini Polls

Palmnet Mini Polls are here! The thing you've been hearing about and waiting years for!

Well, ok. Maybe not. But they are here that's for sure.
What are they? What do they do? Why do I want them? Well, all can be answered by clicking this wonderful little link here: http://www.palmnet.me.uk/polls/

And here they are in action:
Mini Polls
Mini poll bar
Mini poll bar
Mini poll bar
Mini poll bar

Bug reports, feature requests and any general comments are welcome as always.




FlashHacker 2.0 released

FlashHacker v2.0!

FlashHacker 2 screenshot

Yup, that's right, the new version of FlashHacker that I know at least 2 people have been waiting for is as done as it'll ever be.
New features come in the form of decompiling actionscripty goodness with Flare, floating panels with all the bells and whistles (pointless yet kinda nifty), updated help, bug fix or two, main app layout update and such.
Nothing too big except the ActionScript hacks panel. Download it now and try it out, all the info on Palmnet Software: http://software.palmnet.me.uk/module/flashhacker

Just in case you didn't already know, FlashHacker is a little program for hacking flash files, like games for example, at runtime.
This gets you round many tactics flash developers have to stop you cheating to get that uber highscore and lets you play with all sorts like changing health values to removing functions that may report your naughty deeds back to the server.
you can also use it for good stuff too! If you're a flash developer you might want to check that things are running ok at runtime. Normally you'd use trace in the ActionScript but if you don't have the code open then FlashHacker gives you plenty of debugging options. Check variables at runtime to see if they are what they should be and set variables to all sorts of values to check your code can cope. But honestly, this app has gone from that to being geared more towards the evilness of game hacking. Sad but true.




PHP Raycaster!

Recently I started a new project: Learning 3D stuffs!
However, rather than dive right in I thought I might start off by going retro and simple, then working my way up and learning about all things raytracer'y .

A raycaster is a very simple Pseudo-3D engine. It was used in '93 to make DOOM, so that shows the level of sophistication when compared to games today. 15 years later.

However, as easy as it sounds...it is not. Well, at least not for me anyway.
The main problem with me is maths. As many people who have known me from school know: I suck at maths.
3D graphics and such is a fairly maths intensive zone, so I knew it'd be awkward for me to learn much. But after about 2 days things started to click. And a brief brushing up on my trig helped me along a bunch and soon I had gone from (all images rendered on the fly!)
Messed up code
to this
Looks like it works!
However, also this
Oh, no, wait...it doesnt.

As you can see, not everything is working. As is often the case with me. More so when maths is involved.
As you can see there's still some fairly annoying issues to fix before moving on to adding the floor/ceiling and thinking about texturing things.

Anyway, I've been asking about and will post more when/if things start looking presentable any time soon.
In the mean time, enjoy the continued silliness of me+PHP+GD




Project update status

Frequent updates? Not taking months to post anything new? Shocking isn't it!

Anyway, I've mostly been working on updating my old projects and trying my hardest not to start new things.

Shoutbox
Still in active development, as ever. Though starting to feel more like Duke Nukem Forever each day.
I recently had some issues with the shoutboxes I host for other people, and while sorting that out I asked for some feedback on what they'd want for new versions.
So far I have quite a bit done, and today I moved the code for getting/setting data into it's own file so that data is now abstracted from the normal functions. Meaning that you can change the code in just one file and the rest of the code will work the same way as before. Making it easy for MySQL support, or SQLight, plain text, JSON or any other data storage format you can think of! Which is nifty.
I also updated some of the previously written functions to comply with the new data layer, and also started to document the functions too. That way when documentation for it has to be done, I'll already have some comments and docs that will be mostly written to start with.
The new RSS feed is coming along well too. Not done yet, but it should be a good improvement on the old one which was mostly hacks stuck together with bugs!
Next bit to work on after that is the admin backend. People want maximum customisability with no security flaws...and they want it easy to use. Gah!
To show you how much I've done already, take a gander at the folder structure fo far:
File list

FlashHacker
This has to be one of the most useful programs I have written since NetTester.
It also has to be the most updated thing I've ever done too, aside from this site or the shoutboxes.
Since it's release I've already had some ideas flow in and have added a few of my own. The next version has a far cleaner GUI as the old one was pretty much the same as when I first checked it worked.
It also has a new panel (both can now be hidden) for poking around in the source code to the flash file. This uses Flare, a very cool very small and very free, flash decompiler. Not finished yet, but it should be able to list classes, functions, variables and all sorts of things you may want to play with at runtime, which is what the other panel is for.
Here's a look at the little layout for the new ActionScript hacks panel:
AS Hacks panel

PIntEd
Not too much to talk about here. I could release it now as it works fine, but there's some speed issues that really should be fixed first, mostly to do with the syntax highlighter.
Will post more if/when I fix it. If I can;t seem to fix it I'll open up the source and ask those clever webernet elves to try it for me icon_smile

PHP + GD + Maths = Oooh
I've never been fond of maths. It never seems to click with me and the only time I ever manage to get by is when my calculator does it for me.
However, I might be finding a new love for maths as I started plying round with it in PHP and using the GD library to draw all sorts of pretty things. Firstly was a little thing I tend to draw when I have a ruler and some paper about while bored. Then it moved on to a spiral, which was some tough maths for me! And to make it look better I used all sorts of maths wizardry to colour it.
straight lines make a curve
Funky Swirl
Then yesterday I got reminded of what we dubbed "The flying Pringle" in Physics and Electronics lessons when we got to play with oscilloscopes and signal generators.
If you set it up on an XY trace (If I remember rightly, it was a few years ago), and get the right frequencies on both sine waves, you get a 3D looking rotating Pringle. Changing the frequencies gives it more peaks and troughs and you get an armband looking thing to a square criss cross thing. All sorts of fun.
So I made a computer version of this, and discovered it's real name is shockingly nothing to do with tasty crisps from a tube, but it's a "Lissajous curve", simple harmonic motion of the two sine waves.
Here are some made with my script: (Check the image URLs for syntax (A hint though: i is the amount of times to shift the phase by 1) )
Flying Pringle! A bit stretched though. Lissajous curve
Lissajous curve Lissajous curve
Lissajous curve Lissajous curve




FlashHacker Uploaded

FlashHacker, my nifty little tool in VB for fiddling with Flash on the fly, is out in shiny version 1'ness.

Mainly done for Windpower as he asked me when I mentioned it to him. FOSS too icon_smile

To read more and give it a whirl, see the software page, which has also had a bit of a fix up recently: http://software.palmnet.me.uk/module/flashhacker




Page :  1 2