Archive for the 'PHP/MySQL' Category

April 18, 2007

Announcing vbLatex v0.1

Well, after an extraordinarily long period of development (over 2 years at least), vbLatex has finally made it to a public release. You can read all about it here.

vbLatex is a relatively simple plugin that uses dvipng and LaTeX to bring pretty math rendering to your vBulletin forums. I’ve gotten a fair number of e-mails about it, as it’s the system that we’re currently using at SFN - go and visit to see it in action.

The concept is Steve Mayer’s latexrender class; I felt I could improve somewhat on the this class but right now there’s no significant improvements, other than the switch from ImageMagick to dvipng.

Right now development is at what I regard as an early beta stage. Basically, I haven’t worked on the script for a good 9 months and I don’t plan to add any significant revisions until at least July due to my preparation for exams and other committments (this blog included).

There is a good chance that this could break vBulletin at some point, and your users simply won’t be able to see any threads. If you can’t figure out what’s wrong, then feel free to e-mail me.

Anyway, enjoy, and hopefully there will be more updates to it reasonably soon!

12:11 am | Posted in Computing, LaTeX, PHP/MySQL, SFN, Web Development | 2 Comments » | Show comments »

December 22, 2006

Server Move

Well, if you’re reading this (and I really, really hope you are) then the you’re seeing the page from my new server! I decided to take the plunge and purchase the VPSLink-2 scheme, which gave me a bit more room to play around with. In hindsight, that was a very wise choice as 64MB of RAM just isn’t enough for a LAMP stack (as pointed out by Scott Yang in my recent post).

I’m running various services and things to make life easier. Currently it uses about 54MB of RAM idle, although that shoots up a little when loaded. Overall, I’m pretty happy with everything as it currently stands - the speed of the website is much, much better than it used to be with DreamHost and things are going pretty swimmingly.

Read More »
Continue reading “Server Move”…

11:56 pm | Posted in PHP/MySQL, Site Development, Web Development | 2 Comments » | Show comments »

May 4, 2006

The joys of tags

Well, inspired by WB and with little else to do, I decided to look into tags and how best to implement them on my blog. Boy, was that a mistake.

There’s three basic schemas that one can use; non–normalized (the MySQLicious solution) which uses fulltext, the sort–of–normalized and the fully (3NF) normalized. There are problems with each, but in the end I opted for the latter choice. The only major obstacle to overcome was efficiently displaying a list of tags for each entry. Clearly I didn’t want to have to run a query for each individual entry since that would be hidously inefficient.

So after much googling and beating my head against a wall, I came up with an idea. MySQL’s GROUP_CONCAT function is extremely useful, so I used a subquery to get all of the tags for that news entry and GROUP_CONCAT them all together. It’s not pretty, but it works and it seems to be okay–ish. I know subqueries aren’t particularly efficient, but this seems to be the best way that I can think of without doing something completely radical (for instance, dumping the RDBMS system altogether).

Anyway, that’s kept me up until now (3:17am). The rest of the stuff is coming together nicely. Getting load times of between 0.1 and 0.01 seconds on my lowly laptop, so I’m hopeful that this will be a lot more efficient than my last incarnation. Once I’ve got the basic foundations laid, I’ll be setting up the user system and hoping things work nicely. Themes are also getting there, but there’s a lot more to do.

If only I could put this much effort into doing something useful – like revision. Oh well.

3:19 am | Posted in Computing, PHP/MySQL, Warwick Blogs | No Comments »

August 6, 2005

PHP and Smarty

…is, as they say, “the roxor”.

However, it’s now 4am, and I’m rather tired. Enthusiasts will be pleased to know that I did actually do some work on the site today (whee), so we’ll see where that goes tomorrow perhaps.

For now, I bid you farewell.

4:01 am | Posted in PHP/MySQL, Randomness | No Comments »

July 6, 2005

Over at last

Hurrah! It’s over!

Finally, I’ve finished porting the website over to the new backend. Overall, it’s taken about 7 hours, which isn’t too bad considering the sheer amount of code in this site - a lot of which you don’t actually see. Whilst the displaying code is quite simple and in many cases trivial, there are various options for myself, the administrator, to add/upload files. I just don’t like using phpMyAdmin as much as I used to for that kind of thing.

Admittedly, I’ve not finished the Admin CP but I’m not too bothered about that at the moment. However, there’s still plenty to be done:

  • Create the User CP: will contain password changer, preferences (styles etc) and a small profile section.
  • Update the Admin CP so that it actually works. I always find this to be a bonus.
  • Add a “remember me” option to the login interface - at the moment it automagically remembers you anyway, but that’s not good enough.
  • Re-create photos section.
  • Finish updating the statistics section, because it’s a templating nightmare and I can’t be arsed at the moment.
  • Plugin interface? This is a real big one to do and I don’t know that I can be bothered. Could be interesting though.

In other news, my car’s booked in for an MOT tomorrow. Really hope it passes because I don’t particularly want to have to spend money on that.

However, for the time being I’m off to bed. So I shall bid you all goodnight, and retire in a bedwardly direction. Muahaha.

11:53 pm | Posted in PHP/MySQL, Site Development | No Comments »

June 21, 2005

OOP is great, and some info about the site

Before you read this post, just understand that it’s more intended for myself than anyone else, and a lot of it won’t make sense. I’ll try and update later as to the changes, but the likely chance is that you won’t actually see any changes at all.

You’ll probably know that I built the code for this site myself. What you probably don’t know is that the backend of this website is rather complex, if I do say so myself. OOP (object-oriented programming) is used extensively throughout to make the backend really, really flexible. For instance, this backend could quite easily be taken out and put directly into another site without too much hassle at all.

The main idea is to use the database to provide content, and, to some extent, the layout for the site. My sites generally tend to sit in a simple fashion - have a toolbar on the left, right or perhaps both, with some floating divs over the place and a few other tweaks and fixes.

It would be much easier to draw a diagram right about now, but I’m too lazy for that so I won’t. However, this is how the whole thing basically works:

  • Instantiate a config object, and connect to the database using the various options.
  • Create a user object. This reads the cookies that are placed in your browser, and sees if you’re currently logged in.
  • Create a session object. This tracks your current session, as well as gather statistics and other menial things.
  • Create a layout object. This is where most of the work gets done. The page gets assembled and output with a variety of options.

Why is it good? Well, it allows for a great deal of abstraction between what I do in the pages themselves and the actual backend, making it easier to debug.

However, I want to take it a bit further; I basically want to ensure that if I wanted to take out the front-end and slap on a completely different site, I can do this. I originally designed the backend for a project that hasn’t yet been finished, and after moving it to realm, I bodged it a bit to make it work. So, I need to do a few things:

  • The layout object currently uses an object to specify various things about the page; i.e. the title, whether we want the toolbar to be displayed, etc. This is a nice little trick that I thought up; each sub-section can display different titles, have different outputs and all sorts of other stuff without messing around too much. Because everything’s buffered until the very last minute, it allows a lot of flexibility. I want to extend this idea - it can certainly be made nicer.
  • Again, the layout object needs to be seperated from specifics. I want to use template sets which are stored in the database, and then these can be parsed to allow for several style sets. It also allows for yet more abstraction.
  • The config options will vary depending on a variety of things. For instance, every site I code will have some sort of database connection, but not necessarily use my LaTeX plugin. I’d like to have some sort of inheritance going on there.
  • Standardize the CSS. This is important if I want to go on and make things better. However, I’m going to have to give this one some thought.
  • Get rid of the damn functions that are thrown about all over the place; all site-specific functions should be in a different file.
  • This is the important one: create a method for processing of form variables and the like. I think the best way of doing this is to modify the page object and provide a list of variables that the script expects. If one is missing or of an invalid type, then the layout object can deal with it in the appropriate manner. This way, I don’t have to do things like escaping strings before they go into the database, I can just shove them straight in without too many worries.

Also, some random facts for you: the backend by itself is over 1500 lines long - if you add the pages code to that (i.e. the stuff you guys actually see), it goes up to something like 3500 lines.

Anyway, I’m going to go off and get started, methinks. No time like the present, and all that.

6:33 pm | Posted in PHP/MySQL, Site Development | 1 Comment » | Show comment »

June 9, 2005

The evil math has arrived!

Hurrah, LaTeX is installed. Now I can write such prettyness as:

It had to be done.

Edit: having just posted that, it looks rather nice, and it seems to fit in quite well as well. Here, have some more:

Cauchy Integral Theorem:

Fourier Transform:

You know you love it really.

2:29 am | Posted in LaTeX, Maths, PHP/MySQL, Site Development | 1 Comment » | Show comment »

June 8, 2005

Regular expressions suck.

Those of you that have visited in the past 12 hours might have noticed that the links that I had been using in my posts on the blogs didn’t work properly. The reason? The pure, unadulterated sheer joy of regular expressions.

Basically, instead of typing etc I have a safer alternative to including HTML in my posts. It involves the use of bbcode-style tags, and as a result, my link tags are written in a similar fashion. The simpler ones work great, but I decided that for the link tag, I’d make it a bit more complex.

Big mistake. One lesson that I’ve learnt from this is: never mess around with regular expressions if you actually value your life. It’s fixed now, thank god, but I need a sodding vacation after that. Now that I’ve said not to touch them, of course, I’m going to go off and try and implement a proper list code. Whoop-de-doo!

In other, vaguely related news, I decided that I’d go and play around with Tiger. I was up until 4am attempting (in vain) to get the damn thing working with PearPC. In fact, the best place I got to was:

JITC Warning: Invalid expression at 00800000 00000000
JITC Warning: Invalid expression at 00800000 00000000
JITC Warning: Invalid expression at 00800000 00000000
JITC Warning: Invalid expression at 00800000 00000000

Over, and over, and over again. Eventually, this morning, I eventually got the bastard to boot up, only to discover that the install process got about as far as a big, flashing “no” sign. After that, I decided to give up for a bit, so I have the joy of beating Apple software when I get back home.

Incidentally, I’m planning on visiting the Bull Ring Apple store, which promises to be good. However, I’m semi-dreading it, since I fear that much money may actually be spent buying an iBook. On the other hand, I don’t really want to buy one; Intel-powered stuff is coming out in less than a year, and I’d like to think that the price on this existing PPC stuff would be dropped to accommodate the changeover, and get the PowerPC stuff out of the door. Hell, the PowerMac G5 is still a stonking computer; if they were selling them off cheap, I’d probably buy one. Beats my PC any day of the week.

Right, I need to revise. I’m still in the Maths department, and I have yet to actually open my notes (which probably isn’t good). Have fun all, and I shall probably post something a bit later - presuming, of course, that I’m in a blogging kind of mood.

7:13 pm | Posted in Apple, Computing, Hardware, PHP/MySQL | No Comments »

April 29, 2005

The first entry…

Well, this is my first entry on Warwick Blogs (obviously). I get the feeling I could spend a fair amount of time on here though – this is quite worrying. I suppose I should do the entire “hi, my name’s dave!!!!1112″ kind of thing. Here goes:

My name is Dave, and I currently study Mathematics (2nd year MMath, in case anyone cares). Needless to say, the course is rather hard and right now, I’m not enjoying it too much. Then again, I’ve just had exams so that’ll do it every time. That’s all you’re getting, because I’m fairly bad at writing these things. Bahahaha.

Anyway, right now, I’m currently seeing how easy it is to export the data on here. You see, I do have another blog with a pretty interface that I coded myself (rock on PHP 5), and me being me, I want to see whether it’s possible to write a script to grab the data on here and import it. If it’s available in XML then that would be ideal – however, something tells me it probably won’t be.

Then I’m going to recode the script to parse the rather interesting formatting code that blogs uses into the code I use on my website.

So, all in all, it’s going to be a bit of a dull evening. Oh well.

7:21 pm | Posted in Computing, Maths, PHP/MySQL, Warwick Blogs | 1 Comment » | Show comment »

December 16, 2004

RSS = up

Woohoo, RSS feed seems to work. For those that care (and/or know what it is). Make sure you have an RSS-enabled browser (i.e. Firefox) and you’ll be able to keep track of all the headlines from here. Will probably improve this a little but it’s quite easy to maintain and implement.

(RSS - Really Simple Syndication - is an easy way to announce things like news articles, blog entries and the like.)
Anyway, I will be updating the site with some various bits and bobs at some point today/tomorrow/whenever I have free time because I’m quite bored.

Other than that, Sarah’s come over to stay for a few days (which is great) but I’m really, really knackered so haven’t shown it very much. I’ve worked my arse off for the past 2 days on coding bits and pieces and editing a piece together today. In total, I got maybe 5-6 hours sleep over the past 72 hours so I’m really not feeling terribly well. Also, having been up since 7:30am this morning, it’s getting rather late and I’m feeling rather tired - I really don’t know why I’m writing this now, for instance.

Anyhoo, as far as the updates are concerned, I’m going to completely overhaul the backend and make it a lot more nicerer (yes, I know, it’s not a word, although it should be) to work with when I’m implementing new features. The new backend will be something rather cool from a programming point of view - for those that are interested, my backend is quite modular in nature, using a lot of OOP in the new PHP 5.
It won’t look particularly different to you guys (yet) but as I continue to upgrade the code (which I mainly do, just so you know, to try and keep my skills ticking over) with some new stuff, I’m going to try and add user comments and maybe a way for all the QM people to keep in contact. Who knows, I might even scrounge enough money to make the photos get back online.

Anyway, I’ve said enough for tonight. It’s now 2am, I’m tired and I ache like shite. But I’m going to sleep now and make it all better. w00t.

Catch you all later.

1:59 am | Posted in PHP/MySQL, Personal, Site Development, Web Development | 1 Comment » | Show comment »