Archive for May, 2010

Permissions problems with WordPress on PHP5/IIS7 (Windows Server 2008 SP2) with FastCGI

I recently rebuilt a Windows 2008 server and set it up with PHP5 and FastCGI under IIS7 for a bunch of word press blogs. I came to the end of the install and was setting rights to the wp-content folders so people could upload attachments, but ran into some troubles.  I dunno if this changed because of Service Pack 2, but I found I now have to assign the rights, not to “Network Service” which is the Identity of the app pools, and not to “ISS_IUSRS” group, but to an account simply called “IUSR”.  I’m sure previously i just assigned permission to the network service account?  And surly IUSR would be a member of IIS_IUSR’s by default?  I dunno!  Anyway I had to use procmon to monitor the requests and see which account was actually being used.

So to conclude; You need to give modify permissions to the wp_content folder, to the IUSR user and the user your App Pool runs as (eg; ‘IIS APPPool\codeblog.shawson.co.uk’)

3 Comments

OO & Inheritance with Javascript

I’m getting ready to start a game development project and getting my OO Javascript up to scratch- I’ve been googling around for a while as there seems to be a whole load of different ways to implement OO and in particular inheritance in javascript.  I’ve finally found a method that work’s reliably, and with multiple generation of inheritance- It’s from an article on the site point website – for quick reference I will cut to the meat and give a usage example- for details see the original article;

add this function to your project;

function copyPrototype(descendant, parent) {
  var sConstructor = parent.toString();
  var aMatch = sConstructor.match( /\s*function (.*)\(/ );
  if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; }
  for (var m in parent.prototype) {
    descendant.prototype[m] = parent.prototype[m];
  }
};

Then define your classes (prototypes) like so;

function AClass(param) {
   this.Text=param;
}
AClass.prototype.Speak = function() {
  alert(this.Text);
}

function BClass(param, name) {
  this.AClass(param);
  this.Name = name;
}
copyPrototype(BClass, AClass);
BClass.prototype.Speak = function() {
  alert('Hi ' + name);

  // Call overridden parent method...
  AClass.prototype.Speak.apply(this);
}

So the above example will give you 2 classes- B is derived from A.  Calling AClass.Speak will give you a single alert with the contents of the 'text' property, whereas BClass.Speak will give you two text boxes; the first greeting you by name, and the second being the alert box from AClass.  I've tested this myself with multiple generations of inheritance and it worked fine, where other methods have not.

No Comments

Javascript Nintendo Emulator!!

This is crazy; http://benfirshman.com/projects/jsnes/

A full blown nes emulator powered entirely by javascript/ html5 canvas.  I know- I’ve seen quake running, which is a full blown 3d game, and very cool- but this is a full blown games console!

No Comments

Processingjs & Box2d Physics!

I started messing about with processing.js recently which has led me to messing with full blown processing (due to processing.js having no ide!) and I’m trying to apply physics to a basic game engine I’m putting together, to help me get my head around the language in general.

In case you’re wondering what led me to start with processing.js this is, in my opinion, a pretty good contender for flash’s replacement since it’s assassination by big Steve!   It’s a totally javascript based tech requiring absolutely no plugins, using just the canvas element in html5.  The downfall is it’s still really quite new and not quite fully featured (but can still do some cool stuff) and currently only supported by the most modern browsers (FireFox, chrome, safari, opera) but support will ramp up as browsers start becoming more html5 compliant.  The tech itself is a port of a framework originally built in java called simply “processing“.  dot net magazine ran a pretty cool demo tutorial in their last months issue.

Anyway, back to the point; I’m using pBox2d which is a port of jBox2d which is in turn a java port of the original c++ Box2d physics engine!  I had trouble trying to apply forces to move my little space ships- according to everything i had read online you use ApplyForce(b2Vec2 force, b2Vec2 point) but the b2Vec2 class doesn’t seem to exist- turns out you have to use Vec2 with jbox2d, and the method starts with a lower case a on this port to fall in to line with java conventions (that stumped me for bit!)

I dug out the full definition for the body class from jBox2d so for your reference, all the method signatures…

jBox2d: Body
 public Body(BodyDef bd, World world) //ctor
 public Vec2 getOriginPosition()
 public Vec2 getCenterPosition()
 public float getRotation()
 public Mat22 getRotationMatrix()
 public void setLinearVelocity(Vec2 v)
 public Vec2 getLinearVelocity()
 public void setAngularVelocity(float w)
 public float getAngularVelocity()
 public void applyForce(Vec2 force, Vec2 point)
 public void applyTorque(float torque)
 public void applyImpulse(Vec2 impulse, Vec2 point)
 public float getMass()
 public float getInertia()
 public Vec2 getWorldPoint(Vec2 localPoint)
 public Vec2 getWorldVector(Vec2 localVector)
 public Vec2 getLocalPoint(Vec2 worldPoint)
 public Vec2 getLocalVector(Vec2 worldVector)
 public boolean isStatic()
 public boolean isFrozen()
 public boolean isSleeping()
 public void allowSleeping(boolean flag)
 public Shape getShapeList()
 public ContactNode getContactList()
 public JointNode getJointList()
 public Body getNext()
 public Object getUserData()
 public void destructor()
 public void setOriginPosition(Vec2 position, float rotation)
 public void setCenterPosition(Vec2 position, float rotation)
 void synchronizeShapes()
 public void quickSyncShapes()
 public void freeze()
 public void wakeUp()
 public boolean isConnected(Body other)

Anyone else who wants to get started with this, download processing, then download pBox2d and copy the pBox2d files into the library folder of the processing IDE!

3 Comments

Backwards compatible Embedded HTML 5 Video

A couple of useful guides about how to be handling embedded video which is compatible with the iPhone & iPad (given the lack of flash support) using HTML 5, while still offering a flash alternative for older (main-stream) browsers

  • http://www.webmonkey.com/2010/05/embed-videos-in-your-web-pages-using-html5/
  • http://camendesign.com/code/video_for_everybody

No Comments

MIX2010 Videos

Meant to post this a couple of weeks ago- just incase you havn’t already seen them the videos from various sessions at Mix2010 ; live.visitmix.com/Videos

No Comments

HTML5 & the Processing.js JavaScript library

Just reading up on html5 and the processing.js javascript library which takes advantage of the new canvas element to do some pretty cool stuff (check out their ‘exhibition’ section) – came across this site which has loads of useful stuff on it.. code.bocoup.com

No Comments

ASP.net aspx pages posting back to the wrong URL when using Server Rewrite

Had a problem today working on a new phase of one of our existing sites (a problem which I’m sure I came up against on another site and fixed a few years ago…) – we just added server rewrite with a whole new URL structure like so;

www.site.com/ group name/ series name/ book.htm

This allows the user to chop off a folder and get back to the relevant listing page- pretty standard stuff now days.  So this introduces a bunch of virtual folders.  All the sites resources were set to use absolute paths and everything was loading in and rendering fine, but the page crashed every time I click the “Add to cart” button– bit of a show stopper.

This was because dot net isn’t aware of the rewrite- so while they hit the site on a url like;

childrens-books/beast-quest/book1.htm

asp.net thought the page was at

book-details.aspx?id=9780123456789&catId=1&seriesId=2

so did a post back to that page, relative to the current folder, giving me;

childrens-books/beast-quest/book-details.aspx?id=9780123456789&catId=1&seriesId=2

trying to reference the physical file (which existed at the root level) from the context of a folder which doesn’t really exist.  The fix is easy (once you find it!) – for this site the main asp.net form tag was in the masterpage so I just added the following to the Page_Load of my master page;

form1.Action = Request.RawUrl;

Thanks to Ruslan Yakushev’s post on IIS.net

No Comments