jack

I'm a computer guy. I work on websites primarily in HTML5/Javascript/jQuery, PHP and MySQL. I'm very interested in computer hardware.

 

Since the latest posts on PHP.net’s filesize Manual page, at least of this writing, had terribly inefficient code to convert bytes to a readable format, I’m sharing code:

/**
 * filesize_to_str()
 * Converts filesize to a string value.
 */
function filesize_to_str( $filesize ) {
    $sizes = array( 'B', 'KB', 'MB', 'GB', 'TB' );
    $i = floor( log( $filesize, 1024 ) );
    return sprintf( '%.2f%s', $filesize / pow( 1024, $i ), $sizes[$i] );
}

It could be extended easily to push past terrabytes, but if you’re working with those filesizes, you shouldn’t need me to tell you how to do math.

 

When Control became Caps Lock, backspace became `

The network lab process was pretty bad. We were given 6 computers to use, all of them had Fedora 16 installed. I’m glad it wasn’t some weird OpenSolaris setup given the keyboard.

We were greeted with a terminal. I did the logins and set up all the network devices to the proper IP addresses. Then I had to run Wireshark. Wireshark needs a GUI, unless they wanted us to run Tshark. No prior instructions were given to us to launch X to get into Wireshark.

Just typing X hung the terminal at a X with no inputs or window manager. From experience, Fedora came with Gnome so I typed gdm and I was given a login manager. Unfortunately, gdm prevents root logins by default — and rightfully so. I had to manually add a dummy user so I can log into Gnome and launch Wireshark.

Tests were done and outputs were saved. Then I had to bring the data home for the lab report (the instructions were to copy them onto a floppy disk — I’m glad we were implicitly told to ignore it).

Problem: there was no Internet connection on any of the computers. Luckily, we had USB keys with us and were thinking of just copying files to the USB key. The first computer (these aren’t exactly desktop towers, they were 1U rack servers) had the metal cage unlocked so we put the USB key in and copied it without problem.

 

Just about to enter week 7 of my “4A” term at the University of Waterloo. So far, the classes are going well. An update to the courses that I’m taking:

  • CS448 – The course is very fun and challenging. I completely understand the concepts but I’m having a hard time applying them.
  • CS456 – The course is everything I expected but it seems very outdated. For the first half of the course, there is barely anything new to learn that I haven’t learned in high school or while reading my Cisco Certified Network Associate (CCNA) books. We’re just entering network programming, which is completely new to me, but I understand the gist of it.
  • CS490 – The course is mostly taught by students as that is the model that our prof adopted. The professor taught us the first 3 chapters and the rest of it is student presentations. That seems to be a good model for the course, I’m not complaining.  There is no final for the course and only 2 presentations and 2 tests.
  • PHIL216 – I barely have to read the textbook for the course. The course is on game strategies and making decisions while playing games. I love the course. We even get fed.
  • AFM101 – I thought this would be my bird course but apparently it’s harder for me to grasp than the other ones. I have no ability in accounting. I’m really not interested in it at all. I should have taken AFM123 which is “Accounting Information for Managers”. I can’t do AFM123 next term because the 101 conflicts with it.

Reading week is next week, I won’t be coming back to Toronto until the Wednesday or Thursday. There is an OverPower event happening on the Saturday so that’s the main reason why I’m coming back. I plan to spend reading week doing a bit of homework and a bit of developing for the OverPower site.

For the first time in 5+ years, I’ll have to make my apartment look clean so that my landlord and rent it out to new people. It’s a weird feeling so leave this place. I’m still mostly undecided on what I’m doing after graduation. If I end up with a job offer in Kitchener-Waterloo, I’ll likely stay in KW but definitely find a new place. If not, I’ll be back in Toronto and going job hunting — though I should really make use of the job bank we have on UW campus to look for a job.

 

 

I have finished cropping out the scans of all my OverPower cards. It took about 36 hours to scan them all in and probably about 60 hours to crop them all. The OverPower cards have rounded corners and I don’t like to have them showing up on my website because it’ll either be transparent or white.

Luckily, with Photoshop CS 5, I can fill in the missing corners with Content-Aware deletion. I created many Actions to help me automate this process but it still took a while as the process was never perfect. Cropping out the images from the scans were also pretty easy with Photoshop’s Crop and Straighten Photos tool. Again, it wasn’t perfect because some of my scans had cards that were too close to each other. In then end, all of the cards (minus about 50 of them) are processed and ready to be created into PNGs for the OverPower website.

Photoshop doesn’t have a nice tool to batch ‘Save for Web’ on directories with sub directories, so it was a manual process to select each folder for exporting.

And here’s where OptiPNG comes into play. After creating any (regularly visited) PNG for the web, I always run it through OptiPNG to shrink it down further. I don’t understand the algorithms behind it but it works. OptiPNG gives you an option to select optimization levels, with the -o [0-7] flag. Zero being nothing, 7 being sufficiently optimized. Basically, these levels sets up parameters for the program to brute-force compress the PNG file and finds the best type of compression.

© 2012 Jack Truong Suffusion theme by Sayontan Sinha