Archive for the 'Safe For Seneca' Category

Saftey first at York University

Monday, December 24th, 2012

I’m the last guy to be anal about safety, but this is just hilarious!

safetyfirstatyork

If I had a car like this when I was young…

Monday, December 24th, 2012

Things would have been different! I guess that’s not the type of machine you can transport on the highway other than in pieces, so here are just the enormous tires:

bigtires

 

Install all the -dev and -doc packages in Debian/Ubuntu/Mint

Wednesday, December 12th, 2012

Hey look, it’s 2012/12/12 – cool! But that’s not what this post is about.

It always pissed me off big time that the more popular Linux distros don’t install the development files (like header files) or the documentation for the software that comes with them. Being a developer – this is a big pain in the ass for me. It became a really big pain in the ass when I switched from Slackware to Linux Mint a couple of months ago.

I’m no free software fanatic, but damn, why the hell not include the development tools and documentation with Linux? Not only will that make my life easier, but it may encourage some other people to dabble in programming on Linux. Otherwise, do you know what a serious roadblock it is to get a newbie to figure out that there’s a metapackage called build-essential and a package called libgtk2.0-dev which you have to type in exactly like that, with the lib and the dot and the (wrong) version and the dash and the dev? Hell, it’s easier to set up a development environment in Windows (you should be ashamed, Debian).

Whining about it would have been enough, but I actually needed to solve this problem, so here is the solution, you can use it too. It’s a shell script you can download here or copy paste from here:

#!/bin/sh
#
# install-all-dev-packages.sh
#
# Author: Andrew Smith http://littlesvr.ca
# Version 1.0 (12 Dec 2012)
#
# The following script installs all the -dev and -doc packages that should have
# been installed with your software but were omitted for some stupid reason.
#
# Tested on Linux Mint 13 but should work on any Debian/Ubuntu/Mint 
# or really on any Debian derivative.
#
# If you get errors like A : Conflicts: B but C is to be installed
# then add those packages (all of the A) into the following list:  
BADPKGLIST="libdb5.1 libglew1.5 libglew1.6 librdf0"

# List of all available packages
apt-cache pkgnames > /tmp/allpackages

NEWPKGLIST="build-essential"

echo "Searching for required -dev and -doc packages..."
for PKG in `dpkg --get-selections | cut -f 1`
do
  # Make sure it's not in the ignore list
  echo $BADPKGLIST | grep -q $PKG
  if [ $? -eq 0 ]
  then
    continue
  fi
  # See if a -dev package is available
  grep -qe "^$PKG-dev$" /tmp/allpackages
  if [ $? -eq 0 ]
  then
    NEWPKGLIST=" $NEWPKGLIST $PKG-dev"
  fi
  # See if a -doc package is available
  grep -qe "^$PKG-doc$" /tmp/allpackages
  if [ $? -eq 0 ] 
  then
    NEWPKGLIST=" $NEWPKGLIST $PKG-doc"
  fi
done

echo "The following packages have been found:"
echo
echo sudo apt-get install $NEWPKGLIST
echo
echo -n "Do you want to install them? (y/n) "
read YN
if [ a$YN = ay ]
then
  sudo apt-get install $NEWPKGLIST --install-suggests
fi

if [ $? -eq 100 ]
then
  echo
  echo "If you got apt-get erros such as 'A Conflicts: B but C is to be installed'"\
       " then make a change at the top of this script to ignore those packages,"\
       " hopefully that will work."
fi

There is potential for some typical apt-get quircks with the “bla bla is to be installed screw you haha” messages but that’s solvable, you just need to edit the script and blacklist those packages that are erroring. Presumably the list will be different on different OS versions.

Enjoy, you’re welcome!

Fractions driving game in HTML5 instead of Flash

Sunday, July 15th, 2012

I’ve been working on this project part time for a while now, and finally it started bothering me that I couldn’t google the requirements document. That is so because I haven’t publicised it yet, so here you go:

The first step has been to create a requirements document, which I’ve done, on a wiki like real men do. Here it is. It’s complete enough to give you an idea of the scope of the project and some context for some of the posts I will be making.

Progress is pretty good so far. I don’t know if I’ll be putting anything up until there’s at least a playable prototype ready, but maybe. I’ll keep you posted.

Because life is short

Saturday, July 14th, 2012

Some of the photos from my first jump, from the 28th of April 2012. Amazing experience!

My awesome students: Winter 2012 HTML5 DSA

Wednesday, June 20th, 2012

I had a diploma and degree version of a multimedia course in the summer, where half the course was about HTML5 technologies.

The major assignment was for students to implement a functional animation of a data structure and/or algorithm. There were a few of them to choose from.

It took me a while but finally I managed to compile the best of the assignments into a demoable webpage with all the right copyright text in the code.

Have a look yourself, it’s really good stuff!

Processing.js SVG support tester

Wednesday, June 13th, 2012

SVG has been a nightmare over the last decade. It used to be that every implementation is different, no one software created files compatible with any other software. These days the situation is a lot better, but I’m still suspicious of SVG.

But I’m thinking of using it for a Processing.js project, so how do I test what software will create SVG files that will display in a Processing.js sketch? I build a tester of course. You put in your SVG file and it will do its best to render it into a Processing.js sketch. Then you can compare that with what you expected to see.

You can try it yourself here.

I may pull it down though, I’m concerned that it will allow people to upload random files to my server, sort of like the APNG assembler… that’s going on my todo list.

What I found so far: SVG files created in Inkscape don’t show well at all. SVG 1.1 files exported from Illustrator CS5.1 seem to work perfectly, though I haven’t tried anything too advanced.

Scalable HTML Canvas / Processing.js sketch

Saturday, June 2nd, 2012

A bit of background: we are trying to port a game written in Adobe Flash to HTML5 using Processing.js.

Flash

An SWF (Flash) file is placed inside a page using HTML <object>/<embed> tags. The size of the SWF as displayed on the user’s computer is dicated by the width/height attribute of the <embed> tag and if that’s a percentage – the size of the parent container.

Because Flash is all vectors (let’s say for simplicity’s sake) – it can be displayed very nicely at any size, and if you specified 100% for width/height then the size of the SWF on the page will be automatically changed when the browser window is resized.

Here’s a demo. I took the flash file from here, it was so hard to find a simple demo!

That’s really nice, and makes thinking about differently-sized screens for your application unnecessary – Flash handles it all for you automatically.

Canvas/Processing.js – scaling at all

Not so with Canvas/Processing.js. You specify a desired fixed size and that’s that. No 100%, no auto stretch, nothing. That’s called a problem in search of a solution!

I tried lots of things, but the first thing I got to work was using CSS for the sizing. You can set a width/height CSS property on your canvas and then the CSS renderer will do the scaling, positioning, and the reflow. Unfortunately though this is the simplest form of resize and it looks aweful even if you’re only scaling up a little.

So even though you can do this resize dynamically – it’s pretty useless other than as a reflow reference.

Then I looked some more at the Canvas scale() function, and its equivalent in Processing.js. This one does a rescale of everything, but transparently to the code. So evn if you were drawing a line from 0 to 200 – that instruction would be changed behind the scenes with a scale of 4.0 to 0 to 800, resulting in a properly drawn line:

Much nicer! All the lines in the sketch are drawn using line() and ellipse(), the image on the top is a JPG and the one at the bottom is an SVG. The one thing that makes this tricky is that you need to change the size of the canvas as a separate step from the scale() call and the order of the two calls matters.

Here is a live demo for you to see it yourself.

Canvas/Processing.js – auto scaling & reflow nightmare

I thought – “great, I’m almost done!” but I thought that too soon. The problem is – even though I can do nice resizes, it will not happen automatically. So I’m still a way off from the Flash sample I started this post with.

Reflow is no laughing matter, I’d say half of the Firefox rendering engine deals just with reflow, with recursion dozens of levels deep. And that’s written in C++ in the framework with access  to everything. Becuse Canvas was designed with a fixed size in mind – it seems I have no choice but to do the same stuff in Javascript.

I tried for a few hours and got it to almost work, but in the end gave up. Even a hacky implementation with my sizing the canvas to the parent element’s size didn’t work very well at all. I won’t go into details, it’s complicated stuff.

So I’ve gone for a compromise. Instead of resizing to any parent element – I assume the Canvas’s parent is the body (with no padding/margin), listen to onresize events for the entire window, and scale the canvas to the size of the window. Not universally useful, but still way better than nothing.

Here’s a demo (resize the popup window to see it).

Next steps?

Probably not for me, not in the near future. It would be great if this problem was solved universally – not only for all use cases but for all browsers. I have other things to do though, so I don’t think it’s going to be me looking into this further.

Bug Me Not

Tuesday, May 15th, 2012

Too often (as everyone knows) a service online asks you to register but it doesn’t seem warranted, perhaps all you want is to download a demo or try something or just look around.

For years I’ve been using a website Mark Paruzel told me about, but I’ve never written about it because I figured not enough people read my blog. But here you go now:

If you get one of these retarded registration requests you just can’t get around – an option might be the website bugmenot.com. Just go there and see if they have a generic username/password pair you could use.

The world would be so much nicer if this wasn’t necessary…

A shout-out from Linus Torvalds

Tuesday, May 8th, 2012

Wow, Linus himself used ISO Master and mentioned he liked it in a blog post (or whatever that Google+ thing is), I am so flattered!

I would post a thank you response there, but I don’t feel like signing up for an account (yes, I am very happy living without most google services).