All posts by superchlorine

Headache-free course scheduling with the UofT Timetable Generator

Get the UofT Timetable Generator for free on Google Play!

While many things at the University of Toronto are wonderful, the process students have to endure to piece together a course timetable each year is far from enjoyable. I’ve hinted at this before, and the issue is that it’s a headache to pick all the courses you want and fit them into a schedule that…

  1. has no time conflicts;
  2. ensures that you don’t have eight hours of back-to-back classes on Mondays and Tuesdays and no classes for the rest of the week; and
  3. ensures that you don’t have a class that ends at 10 pm and a class that starts at 9 am the very next morning (because I have to commute at least an hour each way and I need to sleep, dammit).

My friends and I are making this timetable-construction process go down a bit smoother with the UofT Timetable Generator, an Android app we developed this summer. It may not be ingeniously named, but the UofT Timetable Generator resolves the first two problems and does it quickly and efficiently. All you have to do is type in the courses you want, hit “Generate”, and you get your optimal timetable without developing a headache along the way!

The UofT Timetable Generator also offers the following options to better tailor your schedule to your needs:

  • Morning: Prefer morning courses when possible
  • Evening: Prefer evening courses when possible
  • Spread: Distribute courses as evenly as possible throughout the week
  • Packed: Pack courses into the fewest days possible

The UofT Timetable Generator is free to download and use, and is available at the Google Play store. The app only supports St. George campus’ Faculty of Arts & Science courses at the moment, but we do intend to expand support to all campuses and faculties at the University of Toronto in the future. Regardless, we invite you to check out our app! We’re eager to get some feedback to figure out what next steps we should take with our app.

For more UofT Timetable Generator-related things, check out the app’s website! We have a few goodies there, like an explanation of our timetable generation algorithm, which we built from scratch, and links to Android resources that we found to be very helpful.

Storing HTML data in XML files, in a PHP application

Recently, I have been working on a PHP website with no SQL support (yeah, don’t ask), but needed to maintain a small database of pages and posts that could be updated via a WYSIWYG web interface. I ended up going with the following configuration:

  1. Store data in XML files.
  2. Handle XML data in PHP using the SimpleXMLElement class
  3. Allow WYSIWYG editing with CKEditor, an Javascript-based open-source text editor

This is a very simple set-up, but there are a few things to note:

Continue reading

Online YUI Compressor

The Online YUI Compressor is a fantastic little tool that compresses your CSS and JavaScript files for you. It strips all comments and extraneous whitespace and, if you’d like, it can also obfuscate your JavaScript by renaming your variables where possible to short space-saving single-character names. My files tends to shrink by 50% after running them through the compressor, which saves me a lot of bandwidth in the long run!

The YUI Compressor is an open-source project developed by Yahoo!, so feel free to also download YUI Compressor from GitHub and run it on your local machine.

kill -WINCH $$ to fix bash prompt wrapping to the same line

Sometimes, my bash prompt wraps long lines incorrectly, such that I’m typing over my own prompt like this:

My bash prompt is wrapping long lines onto itself! The horror!

I used to just live with it, trying to remember what I already typed and counting characters if I was going back to change something. That made my Unix experience much more frustrating that it should’ve been, because executing this single command immediately resolved the issue:

kill -WINCH $$

What does this do? You’re basically telling bash that the window size has changed. It turns out that if you resize your terminal window, bash sometimes doesn’t notice the size change without you giving it an extra nudge. Without the correct window size in hand, bash can’t wrap your text correctly!

If that doesn’t solve your bash wrapping woes, then it may be because your prompt format is incorrect. (Yup, I’ve been there, done that.) Do echo $PS1 to see what your prompt is, make changes and test drive your updated prompt by doing export $PS1='your_new_prompt_here', and save the version that makes you proud to be a shell user by putting export $PS1='your_amazing_new_prompt_here' in your ~/.bash_profile. Arabesque has a detailed guide on formatting your prompt, and Fabien Loison has way too much info about adding colour to your prompt.

Have fun at the command line!

Getting svn to ignore files and directories

Who knew it would be so hard to get svn to ignore some files and directories?

I’m working on an Android project, and I wanted svn to stop looking at me questioningly regarding files and directories that were automatically generated every time I built my source code. Basically, I needed svn to completely ignore the following:

  • bin/ and gen/: directories with generated code
  • proguard/: directory generated by my editor, Eclipse
  • .classpath and .project: Eclipse project files
  • local config file
  • Thumbs.db: annoying Windows thumbnail database files that are EVERYWHERE
  • All built Android files, which have the extension .apk or .ap_
  • All Java class files, which have the extension .class

I didn’t think it would too difficult to get svn to ignore some files for me, but it turns out that svn really likes to pay attention to my files. Hours passed before I finally got svn to relax and ignore what I wanted it to. Below the cut, I share my newfound wisdom with you.

Continue reading
WordPress logo

WordPress, stop inserting HTML into posts and pages!

I like to have control over all the formatting in whatever I produce — websites, documents, slideshows. This is why I write all my posts in WordPress’ text editor. I add in all the necessary HTML formatting myself. No WYSIWYG, thank you very much.

However, WordPress does this really annoying thing where it will wrap every block of text it perceives to be a paragraph in <p> tags. The key word is “perceives”, because it also wraps images, lists, and very non-paragraphy things in <p> tags. Even more frustrating is that there is no option within WordPress’ dashboard to change this setting!

BUT, we can stop this behaviour! All it takes is these two lines of code:

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

Insert them into your theme’s or child theme’s function.php*, and tada! Auto <p> production gone for good (until you remove those two lines from your function.php, of course).

*If you’re using a child theme and it doesn’t have a function.php, just make a new text file in your child theme’s folder and call it function.php. You don’t need to copy all the code from the parent theme’s function.php. WordPress will call whatever is written in the child’s function.php, and then whatever is in the parent’s function.php, so you won’t miss out on anything.

Hello again, world!

I’m currently in the process of moving over my old posts from my old portfolio site over here, as well as fixing any bugs in the layout. All of this should be done by the weekend, so go enjoy life and come back in a few days!

Update (Aug 25): Currently trying to get Disqus comments to import properly. This is driving me nuts. If the site suddenly starts to look weird, or comments disappear, or things start to fail, it’s because I’m trying to fix the comments! T__T

Update (Aug 28): Comments should be working now! It’s possible that Disqus may have forgotten to change a stray comment permalink here and there; if there is, let me know, and I’ll try to get that fixed.

Points on a plane

Given a bunch of points, how can we figure out which two points are closest to each other? We could compare all of the points and choose the pair with the minimum distance, but that’s a lot of work.

Below the cut, I try to explain a better algorithm to find the closest pair of points. This algorithm and its explanation are all over the Internet, so surely one more explanation won’t hurt. Besides, I think mines has the most pictures in it. :)

Viewer Advisory: Some graphs and technical language.

Continue reading