Files, and the editing thereof.

2009 September 21
by mcgrue
2009-09-22

The most pedestrian screenshot ever. To what depths has this once-mighty work-journal fallen?

My gruedorf showings are shameful of late, and so are all of yours. The only one holding the line at this moment is Ustor. Perhaps this should be called “UstorUstor”. Or “TorUs”.

At any rate, my small token to personal projects this week is the file management section’s edit page. Woo, now you can edit your files once they exist. Necessary, and very quotidian to a web developer.

Up next on this mystical journey is the upload section’s frontpage, featuring most downloaded recently, newest files, and staff picks (aka, Demo Alarms). After that, we’re a docs section from release. At this point, I think I should screen-scrape my old site’s documentation and import all of that into a wiki. Anyone have objections?

vrpg beta work continues…

2009 September 7
tags: ,
by mcgrue

I’ve mainly been dealing with code concerning the files section.  I’ve improved the quality of the upload process, corrected the file lineage graph and made strides towards a saner system, have made it so you can comment upon file entries, and made it so anyone can upload screenshots of any file.

Also I made an schema-application tool to keep track of which .sql files have been applied in what environment.  Trust me, this is useful.

So where did I go for two months, far, far away from Gruedorf?  I honestly can say I was shocked to crack open this dev folder to find the last svn log from July 10.  So wherever I went, it didn’t seem as long as it was. :(

PHP, Language of Mystery

2009 July 21
by mcgrue

PHP seems so arbitrary sometimes.

function test_nine() {
	$$"9" = 22;
}

fails to parse.
(which is good, I suppose)

This passes:

function test_nine() {
	$n = 9;
	$$n = 22;
	$this->assertEqual($$n, 22);
}

-Andy Friesen,
of giant-communist-robots.com.

Gruedorf: the Swampening

2009 July 15
by mcgrue

Between putting in incredible hours at work, and a few Magic: the Gathering pre-release events in the last week, I haven’t had much time for gruedorfing.

However, I still got 14 commits in.  (All of them Friday morning.)

The work done was all in finalizing the /downloads/complete-new-os/ page, and tracking down and fixing errors that had cropped up in the upload process.

The second item distresses me, presently, since a solid upload system was the main impetus for the rewrite.  finding out that uploads are still fragile and very prone to breaking with forward development, combined with the fact that I don’t have a testing strategy for roundtrip uploads, means I’m kinda nervous.

So, anyone out there have a good solution for a round-trip integration test where you upload, via flash and javascript, a unique file, and then verify that the file exists on a unix filesystem, and then verify that a corresponding database entry and further corresponding webpage works?

Moving forward, I’ll be working on an administrative page to allow file owners/admins to associate file instances as older/newer versions of the same file.

Uploads, Downloads, and the Management Thereof.

2009 July 8

After some prodding, I managed to get the dorf back into gruedorf. Let the games resume.

Since last I posted about beta.vrpg, 58 revisions have occurred. In that time:

  • I got file submissions up.
  • I got (simple, title-based) file searches up.
  • I got most of the file details page up (thread spawning, screenshot uploading pending).
  • I did a lot of database reworking and massaging, mainly to get to a point where…
  • …single file entries can have multiple physical files attached, so one game can have file links to every OS it’s released on

Oh, and I made a Silly 500 Internal Service Error page.

Definitely the most important part of this work.

Going forward will be finishing the file management side of things (letting you deprecate old versions of files in favor of new ones, showing a browsable history, letting you edit and delete files you own), and cranking out the community-based side of things (ie, image uploading and talkback threads on file pages.) After that, advanced search options and a browsable file index, and the section should be complete.

I’m mainly excited to see a upload system that hasn’t seen a failure yet. This was one of the major failures of the current vrpg that prompted the rewrite. I used swfupload for the actual UI/handling of the upload, and integrating it went very smoothly.

PHP5, you king of bastards (setting an instance member inside a static class call)

2009 July 8
by mcgrue

If I’m in an instanced class, and I call another class’s method statically inside of a method in the first class, and that static method should happen to (erroneously) have $this->whatever inside of it…

…it sets $whatever on my outer instanced class.

Here’s some illustrative code:

<?
    class Inner_Static {
        function burrito() {
            $this->_member = ‘A keyboard. How quaint.’;
        }
    }

    class Outer_Instance {
        function taco() {
            Inner_Static::burrito();
        }
    }

    $my_guy = new Outer_Instance();
    $my_guy->taco();

    print ‘$my_guy->_member: ‘ . $my_guy->_member; 

This boggles my mind a bit. Tracking it down cost me a bit of time. Is there actually a sane use for this little tidbit, or am I justified in thinking that a good language would warn you that scope shenanigans are going on here?

Simple scripts always ship.

2009 July 1

Simple needs, simple deeds.

A need for a simple one-off occurred Monday evening at work. Some non-engineer coworkers needed to be shown how to make some non-Latin-1 text into html entities.

Basically, they needed a 5 line php script.

Right before sending them to any number of sites that already do this 5-line operation, I decide: what the hell, I’ll just make one of my own. And so, that night after unwinding, I did.

Here’s my HTML Entitizer. Suitable for all your HTML entitizing needs, large or small!

PHP in Escape from &#76;&#46;&#65;&#46;(jokesfornerds)

One of the reasons PHP is so popular is the fact that it’s got so many handy little functions. In this case, htmlentities() is the blade of PHP’s swiss army knife that we’re using. Of course, indiscriminate use of functions like this cause problems like double-escaped characters (&amp;amp;) showing up in databases.

PHP, the swiss-army knife.PHP’s solution to this sort of thing is generally to throw new corkscrews and toothpicks onto it’s ever-growing pile of tools on it’s knife. If you look at the documentation page for htmlentities(), you can see that as of version 5.2.3 of PHP, another optional parameter was added: double_encode. Which will

Getting the right escape order can be hard, especially for novices or small teams inheriting code from other small teams. To date I don’t think I’ve inherited work on a webapp whose database wasn’t littered with extraneous &amp;’s and rogue \\’s. It’s only by virtue of verge-rpg.com having a single developer who is really, really annoyed by this problem the the point of neuroticism that &amp;amp; never appears in the database except in posts that actually wanted to display &amp;.

Although even this level of OCD-database-cleansing didn’t prevent escaping-related errors on the first go-round.

Teh (sic) Implementation.

So, the only time-consuming part of getting this script into my wordpress site (other than me taking a bloody half hour to blog about a 2-minute job) was convincing wordpress that it should allow <?php fragments into my posts.

Luckily, other people before me have wanted this very thing. Wordpress’s biggest strength is again one of PHP’s: if you want it, it’s already been made for you. In this case the Exec-PHP module will let admin-level users of your blog post for-reals, actual PHP into your posts! You’d better hope your admins don’t have their accounts compromised! (…one moment. Changing my password.)

In PHP’s case, the code that you want that’ already been written for you is in every single function’s talkback thread. These functions may not be hyper-optimized or the best solution for any given problem, but they generally are what you want to prove a point. You scan the docs, you grab the code, you put it in your site, and you move on to the next problem in your own app.

Quick and dirty, the way PHP likes it.

For the curious, here’s the solution I spat out (copy included):

<h1>Escape html</h1>
<p>This is a simple script to give the escaped codes for some html. Useful
for making foreign languages play nice with html, regardless of how the
server handles string encoding.</p>
<?
if( isset($_POST['escape_me']) ) {
echo('<h2>Your escaped html</h2><div'.
     'style="background-color: #ddd; padding: 8px;">');
echo(str_replace('&','&amp;',htmlentities(stripslashes($_POST['escape_me']),
     ENT_NOQUOTES,'UTF-8')));
echo( '</div>' );
}
?>
<form action='/html-entitizer/' method='POST'>
Text to escape:
<textarea name='escape_me' style='width: 550px; height: 200px;'></textarea>
<input type='submit' value='Create my html entities'>
</form>

(weird formatting so it doesn’t run off the side of the screen; I don’t actually code like that. Mostly. ;)

Coda

It is of note that this tiny amount of effort got me two really sincere “thank yous” from the non-engineers. It’s important to note that things that are mindlessly trivial to a programmer can be tedious tasks to someone without the power to bully the computer into doing labor for them. One of the guys, a computer saavy guy who had access to lists of what each escaped character translated to, insisted that he’d just search/replace the offensive characters by hand.

Ostensibly, this was offered to save me work.

How much time did my 2 minutes of code save him?

(Don’t forget a google for “html entity converter” would’ve saved even that, had I cared to not make the tiny toy script of my own. I’ll ramble on about re-using other people’s work more later, but it’s key to remember even what little work I did end up doing was extraneous and largely an exercise in vanity.)

beta is the new gamma

2009 June 29
tags:
by mcgrue

Work continues apace on beta.verge-rpg.com.

Actually, it’s quite brisk now. Almost 60 revisions have passed in the last week.

Gayo and crew have banged on the forums, and I patched several oversights. Locally I’ve moved on to the new downloads section, which I’m looking forward greatly to finishing. Mainly so there can be an upload script that works for most users and gives progress feedback.

Are all webapps 98% mundane crap? I’ve been doing them for almost a decade now, and I think I have an answer.

(The answer is “yes”.)

Gruedorf: boards done.

2009 June 21
tags:
by mcgrue

Even though I’ve been lax in posting, I’ve been working (when I can) on finishing the beta.verge-rpg.com boards.

As of revision 237, the section is good to go for this run-through.  I’m going to now move on to the file section

Captain’s Blog: Frontier Psychiatry

2009 June 12
by Jonas

Mission Date: 0 years, 231 days

UN Mission Command has been alarmingly silent on the the events of last week. I suppose this is protocol, until they have a solution they don’t want to worry us. At least I imagine that was the thinking when whatever contingency plan they’re following was written, but in the meantime their procedural consideration for our psychological states is driving us insane. Best thing to do is ignore it, because up here our highest priority has to be figuring out why everyone on board is so miserable. It is ultimately our problem.

I’ve been meeting with Dr. Saratoga, ship’s head psychiatrist. She says the problem is that everyone on this ship is disgusting filthy racist, and a narcissistic egomaniac to boot.

Some background. When choosing from candidates to crew of the UNSS Ennui and be the future colonists, there were several important criteria: They had to be able, willing and ready to have children, be a distinguished and successful professional in a field useful to the colony, and have passed a thorough screening for mental illness. Some self selected characteristics (found in anyone who would volunteer to be a colonist) are a lack of close friends, family, spouses or children, and a degree of impulsiveness.

I think Group G needs to get over A

I think Group G should get over A

Maybe you’re getting the picture. The ship is full of self-absorbed workaholics whose biological clocks are becoming increasingly prominent parts of their personalities. They think the only reason they haven’t yet started happy families is because they haven’t met any equally “serious” people. What do you think happens when these people are confronted by thousands of other people exactly like themselves and confined in a ship with them?

The mirror is very unkind.

Our population is a rich tapestry of statistically enforced and algorithmically maximized genetic and cultural diversity, which leads to the second half of the problem. Have you ever done a calculation of how many single people of the opposite sex, who are roughly your age group, who you find attractive and would find you attractive, and not currently in relationships exist in the population of, say, your city? Well that’s your city, where the cultural gap between you and other people is somewhat limited by geography.

Dr. Saratoga has teamed up with statistician Dr. Minoh and computer modeler Dr. Hakeem to identify 200 unique cultural groups that are only willing to date within two or three other groups in any significant numbers, and over 500 smaller groups that absolutely refuse to date outside of their own group. The largest group, about 7% of the ship’s population, is the group who will only date in a cultural group other than their own. While this group has the shortest relationships on average, they also have the most and are (so far) the happiest. We’ll see how they do over time.

For everyone else, once all criteria has been factored in, for the average person the number of acceptable mates is fewer than three people.

I’m not even considering the possibility of sending these findings to UN Mission Command.

Captain Richards out.