Categories
Computer Games Larp PHP Projects

Week 27 – A Blunderbuss For House Hunting

Last couple of weeks have been a little hectic, and the next couple seem to continue this trend. So:

Work

Shifted to a new primary project at work for the first time in quite a while. Enjoying new challenges, and a more modern codebase to work from. My side of Skute has wound down a bit while others fan the spark a bit, which gives me a chance to plan the next bits for the API.

Play

Still going though SWTOR, mostly. I’ve not had a lot of playtime.

Rest

Moving House

We have the keys to the new flat, big move is this weekend. We moved a few dozen boxes yesterday (Thanks Dan & Jenny for being awesome). Between that and Odyssey, I’m mildly dead now.

Odyssey

I’m a head ref for Odyssey, and work closely with the Story team to help everything go smoothly, and one of the things that didn’t go smoothly last time was our “Blessings” system – the system by which we add reactionary special statuses to characters (Blessings from their Gods, Curses, Long term effects of magic spells, transformation into bloodless monsters, Roleplay effects, Extra hitpoints, everything). Previously we worked with a somewhat Heath-Robinson contraption built of Excel and Access-based PDF generation.

Previously, I built a system called Mimir, which tracks the kudos priests and other characters can earn with their gods. We’re a more narrative-based than stats-based game, so the numbers get fudged a lot, but it’s a decent guideline. It’s also got a fairly fully-featured blogging engine, which is for debriefs.

Screenshot from 2015-08-12 15-45-00_croppedMy last couple of weeks not-working time has been spent extending and expanding that a lot. Folding in an Autocomplete library that linked to the current list of active players and the Blessing system (complete with three-stage approval process and player-facing PDF generation), and then a general once-over on the design has swallowed a lot of my coding time.

When I built it originally a few years ago, I built it in PHP (because I wanted to be able to make quick changes on the fly during an event) using a custom lightweight microframework, and Idiorm/Paris as the database/ORM model. I’m slightly surprised how well that’s held up. I didn’t need to edit the framework at all for this major revision, and Idiorm & Paris worked really well for me. The frontend’s built in Bootstrap, which gives me style without much effort – though I do need to bite the bullet and shift up to v3 – and I’ll be releasing it as Open Source once Odyssey is over, alongside graphs and statistics generated from the actual dataset.

I should put up another post later on about how well Odyssey went, but now I should be getting ready for work.

(Header photo: A Greek Shield Wall, at Odyssey. Photo by Charlotte Moss for Profound Decisions)

Categories
Imported From Epistula PHP

Uh-oh

php.net syntax error

Categories
Apple Imported From Epistula PHP

Debugging Ajax

One of the problems with Ajax is that the server side of it becomes invisible. You send a request to the server with an ajax request object, and you can get output from the JS by firebug, or alert boxes, or whatever, but for the script running on the other side, there’s no visible place for the output.

There are many ways around it, but my current favourite is Growl.

Growl is a notification system for OS X, where programs send messages to the central demon, and it pops up a little dialog message that eventually fades away. They’re nice for debug, so I have this:


<?PHP
require_once 'Net/Growl.php';

$growl =& Net_Growl::singleton('Net_Growl'array('Messages'), '[Password]');
$growl->_options['host'] = '[MyIP]';

$GLOBALS['growl'] = $growl;

function debug($message){
    $backtrace = debug_backtrace();
    
    array_shift($backtrace);
    
    if (is_array($message) || is_object($message)){
        $message = print_r($message,1);
    }
    
    $title = sprintf("Debug - %s - %d"$backtrace[0]['function'], $backtrace[0]['line']);
    

    $GLOBALS['growl']->notify('Messages'$title$message);
}




With network notification enabled on Growl on my local machine, I get a little debug message without interrupting the application flow.

Of course, I could use log files, but that wouldn’t be quite as pretty.

Categories
Imported From Epistula PHP

Textile

For the last couple of hours, Aquarionics has been using Jim and Lissa’s TexilePHP system, which is a conversion to PHP of Brad Choate’s conversion to Movable Type of Dean Allen’s textile system (Once relased on its own, now part of Textpattern).

It’s the same system as AqWiki uses for text formating, and I used the Jim and Lissa version because it supports multiple paragraph blockquotes. (I actually installed the Jim and Lissa version for the last entry about City of Villains, because it needed a multiple paragraph blockquote).

I’ve removed it entirely from every single project I have.

Why?

Because it pushed the memory usage up by over megabytes.

Six!

The server has a limit of eight for PHP connections. Epistula, which is reasonably complicated, clocks in at 3.5 (Far less when visiting a cached page), AqWiki without textile is 1.9 – mostly due to the Pear stuff. But good grief. Textile was taking up more memory than the entire Epistula system, doubled.

Categories
Imported From Epistula PHP

T Paamayim Nekudotayim

Lesson of the day, PHP calls the ”::” – used to identify an uninstantiated class function – a Paamayim Nekudotayim.

A day when you learn something is a day not wasted.

Categories
Imported From Epistula linux PHP

PHP sessions in Debian Sarge

This is how debian Woody (and all sane systems) clean up PHP disk based (the default) sessions:

  1. Every x (default: 1000) requests, PHP will delete all outdated sessions.

    This is how Debian Sarge does it:

  2. Every half hour (at 9 and 39 past) run a script
  3. This script runs a second shell script that parses the PHP config file with a regex to get the value for how long sessions should last (Which is odd, because a PHP script will get this automatically)
  4. The first script will then find all session files older than that value
  1. Delete them.

    WHY? WHY WHY WHY?

    This is the kind of braindead overcomplication stuff I’d expect from Gentoo, but the whole point of Debian is that it’s /sane/.

Categories
aqcom epistula Imported From Epistula PHP web development

Handing 404s over to Google

This site once won an award from a perl web hackers site – now defunct – for the 404 system.

The system was really simple. If you hit a 404 on this site it would apologise, then redirect you to a google search of Aquarionics for whatever you were looking for. This has worked for a while now, with the apologies getting ever more extravagant and the redirections being turned into google links (Because I hate being redirected places without a chance to stop it).

The latest iteration of this has just been finished (Yay the lunch break). It uses the Google API to display the first ten results alongside the apology. Finally a real use for the thing 🙂

The next stage is to automatically wander though the mysql table of my access logs and automagically reply with 410 Gone if it used to exist but doesn’t anymore

Categories
aqcom epistula Imported From Epistula PHP programming

Instant Cat Pictures

Since I’ve had my new camera-phone, I’ve been taking random shots occasionally. After a fairly brief stint using Gallery and moblog.co.uk I’ve done my usual thing of writing an Epistula Module to do it a) the way I want it, and b) within my own site. (I started off adapting the webcam module, but that’s bitrotted slightly and was never very good, so I rewrote a whole new thing that uses EXIF data – which my mobile doesn’t do, but my full camera does – and pretty CSS effects.

Anyway, the upshots of this are that to the left on the front page is “That Which Is Seen”, the latest moblog picture, and clicking on it will take you to /moblog, an archive of everything. I need to make the archiving better and make it generate thumbnails properly, but for now this end is working. Next end is the python script to take a piped email and send the graphic and caption to the right places, then I’ll fix the front end properly. Meanwhile, it’s half one and I have work in the morning…

Categories
Imported From Epistula PHP programming

Errands and the End Of PHP

Got stuff done.

In this case, the stuff was of a many and varied nature and involved:

  • Sorting out bank accounts
  • Joining Blockbuster
  • Joining Library
  • Posting Stuff

    But also:

  • Resolving that I will never again begin a personal project written in PHP.

    Yesterday, you see, I managed to get PHP5 working on Atoll, my local server. It works fine, from a technical standpoint, it installed straight into the right place, it works, it access the databases and everything.

    Epistula, however, doesn’t. Neither did AqWiki, Aquaintances, Klind or Pareidol. Why?

    Because somewhere in the PHP5 development process, somebody wrote a function to return the contents of a directory back as an array, and called it scandir() which, co-incidentally, is the name of my stock function for returning the contents of a directory as an array. It means that, as of PHP5’s full release, my code is broken. This is, in fact, wrong.

    One of the great benefits of PHP is it’s integration. Everything available was in the manual, which was searchable and contained the wit and wisdom of several years of PHP developers who had been where you are before you were there.

    The greatest flaw PHP has is it’s integration. Functions have been added haphazardly over the five major revisions to the point where, given a two word function, it’s equal odds to be firstSecond() as first_second() depending on who coded it when. Also, the willingness of the development team to break every previous PHP tutorial in a minor revision (Witness the whole REGISTER GLOBALS debacle), Perl – the language with the most established collection of modules on the market – has a namespace system for added on functionality which works so well even Python copied it. PHP, however, is no longer a stable platform to develop releasable code on, since your code may stop working at any point. Worst, this will manifest itself as a PHP syntax error, and you cannot guard against new internal functions unless you check the existence of every function before you use it.

    So, PHP, it’s been nice using you, but until you stop fucking around with the namespaces, it’s time to try something new.

    Suggestions, anyone?

Categories
epistula Imported From Epistula Metablog PHP

Comment as mucked

So, whilst other people have been attacked by comment spammers, I – in my Epistula fortified ivory tower – have recieved two, which I have then deleted. More of a problem for me is that Google has placed my review of Broken Sword III in the top of it’s rankings for that phrase, meaning I’ve had a couple of people saying how much it sucks.

This full and frank exchange of views (If they ever come back to the site I’d be suprised) is exactly why I have comments, but both of them decided to put forth their views in CAPS-LOCK FOR EMPHASIS.

Grr. Just reading the comments makes my ears hurt.

So, given that this is a social problem, there must be a technical solution to it, mustn’t there? This is, after all, a weblog. And yes, of course there is. A couple of quick regexes later, and I have checkCaps to do this fun job for me.

Also, since I’ve got a couple of reports that my comments validation thing was a little odd, I’ve recoded it a bit so it highlights if there’s been a problem submiting your comment (Originally it just changed the status message, but this is apparently not obvious enough, so now it colours it red)

Next trick is going to make the “Email me when someone replies” thing actually work…