My latest Flickr photograph

Load text with custom fonts when the font is ready. in programming

Saturday 21st of January 2012, 06:40:06 pm

Over the past year and a bit I've run into many occasions where it is ridiculously tricky to load a bit of text, styled with a custom font, because browsers don't know when a custom font is ready. They can tell that they finished downloading it, but then can't tell when it is also ready for typesetting (A large font can easily have 200ms between 'download complete' and 'fully parsed and ready for use').

The solution: through my own work on font parsing, work I did for Processing.js, and a P.O.C. for PDF.js I have now come up with (almost) the perfect solution: Font.js, a library that adds a sorely missing object to the JavaScript toolbox, namely a "new Font()" object.

Check out the Font.js demonstrator page, or have at it by forking it on github!

0 comments - view/add comments

Trap keys for HTML elements - show the browser who's boss in odds and ends

Sunday 20th of November 2011, 02:38:26 pm

Say you're writing a browser game. Everything's going great until your user hits "backspace" and BAM! The browser goes to the previous page. How annoying is that? Forget about annoying, it means your game is unplayable because it doesn't trap important keys.

With this simple self-contained script, it can. And it comes with a handy jQuery .trap() function, too, so that you can just chain it in wherever you like.

Now THAT's handy.

Also: github link here.

0 comments - view/add comments

Adding macros to your CSS without breaking things in odds and ends

Sunday 20th of November 2011, 02:36:26 pm

For the redesign of Nihongoresources.com I needed CSS macros at the client. I like SASS, but it doesn't let you keep shared design elements actually shared once the CSS it generate is loaded in a browser, so I needed something that kept those links in. LESS has a horrendous syntax, and is not CSS compatible, so I rolled my own macro package that sticks with the syntax that is used in proper CSS so that things work even if people block scripts.

Get your CSS macros here.

It also comes with a jQuery .macro() function, so you can change macro values even after the page has been loaded by the client's browser and be assured that everything that uses that macro is updated accordingly.

Also: github link here.

0 comments - view/add comments

Get your simple page comments here. in odds and ends

Monday 31st of October 2011, 04:08:42 pm

So I needed something to add instant commenting to random pages I write (because I don't keep all my stuff on one website, and sometimes I'll make pages that have a limited lifetime but I'd still like comments for). So I dug into my Primer on Bezier curves, and ripped out the commenting functionality as it was the most modular starter I had lying around.

I cleaned that up, made it truly modular, and the result is a really quick and simple way to add a comment section to a page. It only requires three lines of PHP to add comment functionality to any page, and is highly customisable thanks to nearly everything being CSS classed.

It's also on github

0 comments - view/add comments

Let's do JS templating! in odds and ends

Friday 21st of October 2011, 01:17:39 pm

For no good reason, let's get some templating going on for HTML pages, without needing server-side variable substitution. I have no idea when you'd actually use this, but then again maybe it's exactly the kind of thing you were looking for. Have some.

0 comments - view/add comments

Summer 2011 brings photographs in photography

Wednesday 7th of September 2011, 09:32:08 pm

I've not been spending enough time posting entries, because I now have four websites on which I can post things when things happen, and no good solution (yet) on how to manage content between them...

That said, summer vacation 2011 consisted of visiting Ottawa, Missisauga, Waterloo, Toronto, and the Canadian Rocky Mountains (Canmore, Banff, Field and general hiking).

I'm going through my 2000 photographs that I shot for the more interesting ones, and the result so far can be viewed on Flickr. More to come =)

0 comments - view/add comments

HTML5 meets Pomax in programming

Monday 7th of March 2011, 09:10:51 pm

I like trying things because I have a need for them. One of the things I needed way back when I was writing the first revision for my book on Japanese grammar was a way to tell roughly how many pages of typeset material a plain text file would be.

What better way to check than using dynamically generated HTML, right? So I forgot I had ever written a utility that did just that, until a few days ago, when I realised I still had it lying around, and had everything I needed to clean it up and make it look fairly nice, too.

The result, I think you shall find, is actually rather attractive.

Now I just need to figure out how to make it deal with all manner of HTML instead of just plain text. Should be a great WP/Drupal/Dokuwiki/etc theme!

0 comments - view/add comments

Bezier information for everyone in Processing.js

Monday 7th of March 2011, 09:07:50 pm

If you've ever wanted to know something about Bezier curves, there's a good chance I've covered it in my rather lenthly "Primer" on Bezier curves, conveniently located at http://processingjs.nihongoresources.com/bezierinfo/.

And if it's not there, just ask and I shall probably add it to the article!

0 comments - view/add comments

Writing a shoutbox in nihongoresources

Thursday 22nd of July 2010, 09:55:58 pm

Because I'm migrating some of the functionality of nihongoresources to a new domain, dictionaries.nihongoresources.com I figured this was a good opportunity to let people voice their opinion in a less barrier, more direct way. Shoutbox style.

I tried a few premade ones, but they all had their own issues, so I figured I have enough technical skill, why not write one myself? After all, how hard can it be? This not being Top Gear, the answer is "not really that hard", you just need to make sure to do things in such a way that other people will be able to customise it easily. Because that means you'll be able too, as well.

The result is a pretty simple PHP SQLITE backend / JS CSS frontend shoutbox that uses the remarkably simple on-page code "<div id='shoutbox'></div>" and that's all you have to do (well, and load the shoutbox.js script of course).

It works well enough for me. To see an example in action, just head over that aforementioned dictionaries.nihongoresources.com!

Download: here

0 comments - view/add comments

I, for one, welcome our North Korean traffic wardens in odds and ends

Wednesday 7th of July 2010, 07:51:03 pm

Futuristic deployment methods are futuristics.

0 comments - view/add comments

previous 10 posts