Saturday, December 26, 2009

So, generic programming

This is a good read.

It's an interview with Alexander Stepanov, and contains gems like:
"I find OOP technically unsound. It attempts to decompose the world in terms of interfaces that vary on a single type. To deal with the real problems you need multisorted algebras - families of interfaces that span multiple types. I find OOP philosophically unsound. It claims that everything is an object. Even if it is true it is not very interesting - saying that everything is an object is saying nothing at all. I find OOP methodologically wrong. It starts with classes. It is as if mathematicians would start with axioms. You do not start with axioms - you start with proofs. Only when you have found a bunch of related proofs, can you come up with axioms. You end with axioms. The same thing is true in programming: you have to start with interesting algorithms. Only when you understand them well, can you come up with an interface that will let them work."
"You can't write a generic max() in Java that takes two arguments of some type and has a return value of that same type. Inheritance and interfaces don't help. And if they cannot implement max or swap or linear search, what chances do they have to implement really complex stuff? These are my litmus tests: if a language allows me to implement max and swap and linear search generically - then it has some potential."
Good stuff; making me think.

Thursday, December 24, 2009

Customizing the blog a bit

This layout has always been rather insistent that I have a very thin middle column in which to place my posts. It's bugged me for a long time, but I decided that messing with the CSS template was outside of my competence level and just asking for trouble.

At the same time, I've always wanted to be able to place code into the blog without it looking like some awful monster crapped out unformatted text.

Well this morning I've fixed these issues.

The latter was as easy as googling "showing code in blogspot" and then following the instructions at the top link.

Essentially, you go to the Layout section of your dashboard, click "edit HTML", find a tag "]]></b:skin>", and insert some CSS in the section above it. It adds the necessary stuff to make pre and code tags to work wonderfully.

Then it recommends running code through a converter to quickly change it to escaped-text before posting it.

I feel like (and am, really) a script kiddie but hey, I've got code showing up in my blog like so:

int main(int argc, char *argv[])
int a, b, c;
int *d = NULL;

a = 5;
b = 6;
c = 7;
d = malloc(sizeof(int));
d[1] = 8;

if(argc == 2)
printf("What a lame example!\n");

return 0;
which is wonderful.

Then I got to thinking "Hey, I'm a cocky CSS editing fiend, why not solve the problem of the blog's lacking width?" And I looked over the code in the layout section.

I found in there (this is likely specific to this template)
#header-wrapper {
margin:0 auto 10px;
border:1px solid $bordercolor;
#main-wrapper {
width: 410px;
float: $startSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
#footer {
margin:0 auto;
line-height: 1.6em;
text-align: center;
These all have 'width' attributes that look like they're big enough to be most of the screen, and they're the only similar ones in the file. 660 pixels isn't very wide - I imagine it was set at that to work on an 800x600 screen, should one need to see my page.

Well you know what? I'm officially leaving those people in the dust.

Following some common design advice of 960 pixelwidth pages (see, I decided to directly increase 660 to 960, and 410 (correspondingly) to 710. This widened the main post section of my blog considerably, and seems to have had no negative consequences.

Hooray for a productive blogging morning.

Python Fun

Every programmer, when learning something new, hits on that devilish quandary:

"What should I program?"

And I am a man like all others, who twiddles my thumbs and wonders "ah... if only I had something to /do/ with this language, I would really start to learn it!"

Well, I've decided to just dink around uselessly and see what comes of it. Then share.

The things we'll cover:
  • Some stupid string stuff
  • some more stupid string stuff, with numbers involved
  • then some regular old math

stupid string stuff:

First I started off playing with the string and list functions, and interchanging between them. Throughout this, I might duplicate existing functionality -- if I do, comment and tell me how to do it better! I'd love to learn.

I decied that I wanted to take a string, say "Hey man, what's up?" and insert stuff between each letter. I couldn't really find a quick way to do this, but some related things popped up.
a = "Hey man, what's up?"
will give you ['Hey', 'man', 'what\'s', 'up?'] - and that's nice, but I want things broken down to the letter. So I wrote a function breakout:
def breakout(input):
r = []
for i in input:

return r
breakout("hello") returns ['h','e','l','l','o']

then you can do a str.join() - let's wrap it into a function!
def splitByChar(instring, splitchar):
return splitchar.join(breakout(instring)
you can, through this, call splitByChar("hello", '.') and receive 'h.e.l.l.o'

ah, stupid pointless string stuff.

more stupid string stuff, with some math

Next up, I decided to play with phone numbers. I decided to break them up into their constituent digits and add them. This was (as many things in python are), an easy task.
def summit(input):
sum = 0
for i in input:
if i.isdigit():
sum += int(i)

return sum
This function runs quickly through the string and adds to the sum for every integer found.

I put in my phone number, print(summit("519-703-3336")), and received 42. Exciting!

Then I got to wondering.... I wonder how many phone numbers out there sum to 42? I wonder what the distribution is like across the rang of sums from 0 to 90? Let's write some code to find out:
def smattering(input):
arr = []
for i in range(0,9*input):

temp = []
for i in range(0,input):

upper = int(''.join(temp))
upperStr = str(upper)
for i in range(0, upper):
arr[summit(str(i))] += 1
if i % 1000000 == 0:
print(str(i) + ", " + str(upper - i) + ", " + str(i/upper))

return arr
This code makes a 90-element list, then brute-force walks from 0 to 9,999,999,999 and calculates every single sum, stopping every million steps to print out how far we are in, how far we have left, and a percentage through the path we've walked. I did some simple calculations, every printout occurs about 9 seconds apart, and 9,999 of them are required to take the calculation to completion.

This translates to about 24.9 hours. That's a pretty long calculation -- and it's kind of required; summing each of 10 digits for each of 10 billion numbers is 100 billion operations no matter what way you cut it. I've left the calculation running in a terminal (two, actually - one which will conclude and print the values to the screen and to a text file, and another in an interactive terminal in case I come up with fun things I want to do to the list off the bat) - but I'm beginning to think

some regular old math

is in order to find out the answer to this question a bit faster. The clock is ticking, and I have a day to find out. I'll update once I've thought about it a bit.

Wednesday, December 23, 2009

Hard to settle

So far I've played with Python, learned some piano, written a program to help me learn large-number multiplication, played hours of Ogre Battle 64, and watched the first season and a half of Weeds. Also seen friends, walked many kilometers, and slept gratuitously.

I think a haircut is in order. Maybe not today, maybe the 27th or so. Also, laundry.

I'm going to move forward with watching the SICL videos, and then dive into the Graphics/Language stuff. Math can happen in my spare time, as can piano. I've also got a phone-interview for an internship today. I'm not certain quite what to expect - algorithms and code-related questions, a history of myself, or just good discussion. I hope it goes well.

It's been wonderful to have time not committed - when I decide I want to do something, I can generally just go do it. I've learned a lot and I feel much happier than I have in weeks.

I also fixed up my home-server's webpage, have read a bunch of my various books (Contact, The God Particle, the latest Wheel of Time book), listened to a TON of the music I've accrued over the past semester, and played with some VMs. Installing Slackware is an interesting experience to say the least.

I'll post back in a few days (likely just post-christmas) about my progress on SICL, Python, Graphics, and my C-spitting-extensions to C.

Wednesday, December 16, 2009

A flurry of activity

Well, that's another semester past.

I have from right now until January 10th to myself, effectively. It's time to decide how to use it.

So from what I can tell, my options are:

Base Skills
Something Complex

Graphics would be making computers do graphical things for me and also making graphics myself. Playing with Blender, with the GIMP or Photoshop, with Paint and maybe Flash, reading about colour-theory and how to paint a perdy picture. I'd also be drawing a lot, and reading about basic art stuff. And of course, playing with C/OpenGL to make the computer do cool things, and learning related math (Matrix Algebra, anyone?)

Languages would be reading about and learning Lisp and Python through the development of simple (and slightly more complicated) projects with them. I would watch the SICL videos from MIT's Open Courseware, generally get a better feel for Lisp, and I'd just do stuff with Python. I would like to implement my scope/stack/reference/object stuff for C.

Basic Skills would be math and physics and chemistry and maybe biology, just learning voraciously over the break -- very largely just improving my mathematical skill and comfort level. I would also be spending a lot of time working on music and some basic technology things, like awk/sed and being a better vimmer, using the full extent of regexp's and scripting.

Something Complex would be choosing a project - I'd spend a few days choosing, then go through a design phase and build myself something good. Something that I could sell, or at least use in my day to day life. Maybe this could include working on an Open Source project, or attacking Sam Altman's company Loopt, which just does not seem to be doing a good job with my idea.

Anyway, one of those four things. I'll have to ask myself "Where do I want to be on January 10th", and my answer could be "I want to walk up to a Piano and lay down the driving rhythm line from 'Don't Stop Me Now'.", or "I want to be able to take 4 files of similar data in disparate formats and spit them sorted into a single new file, every 10 seconds or when the file exceeds 100 lines, and I want to be able to write the thing to do it in about two minutes.", or maybe "I want to be able to spend a weekend and make a simple game, with my own pixel graphics, my own physics, my own everything, and run it on Linux or Windows.", or maybe "I want to be able to do what I want to be able to do. In Lisp. (really poor recursion joke)". Ooh, or, "I want to be able to read a Wikipedia article on a mathematical topic and not have it go over my head before I'm halfway down the page."

So, which of those sounds best? Or at least, sounds like the one I'd like first? I'm going to spend an hour or two thinking about it.

Monday, November 9, 2009

The next few weeks, schoolwise

and a tiny bit of databases

Networking I've got a good mental start on. I'm agreeing so far with Martin on using a linked list - I considered just making a big buffer and filling it in using some neat math, but that...

that sounds complicated. Easy to write out, hard to set up. I'd much rather save each datagram into a list and then sort the list, and iterate through it to write it out/test whether or not stuff was received. So I'm going to set up my listeners, send out the request, read everything in, sort and check my data (likelier I'll sort as I read), rerequest what I haven't got, repeat until I've got everything, then write the data out. Cool.

Haven't looked at modelling or databases yet. Will do so soon.

Have a meeting for 3750 tomorrow, we'll have discussion and such, and get back on track.

Alright, school is looking manageable. Modelling and Networking are both due circa Nov 26th, DB will be sooner, and 3750 is ongoing and constant. This iteration (final) is due next Thursday.

Then Finals!

Tuesday, November 3, 2009

TA ta ta

Just dropping a note whilst TAing:

registered for my courses for next semester: phil: critical thinking and phil: intro to metaphysics, also cis: digital systems, cis: computer graphics, and cis: compilers -- compilers isn't actually signed up yet, I have to get waived in like everyone else.

finally got "The Great Hunt", book 2 of the Wheel of Time back. I'd left it on the plane on the return-trip from Tucson. Also bought "The Light Fantastic", because I freaking love discworld.

Started reading manga. Got through a volume of Legend of the Strongest Man: Kurosawa last night, and I've started on Trigun. Downloaded Gambling Emperor Zero v1 and 2 as well. I'm gonna check what sort of things I find at the end of the internet for marvel comics now. I knew I liked this format - just never got into it.

It's a time of great opportunity: Networking and Modelling aren't due until late November, and there's no more midterms. I have only to push forward on 3750 and get a decent (>75%) mark, same with databases, and I can safely devote some time to side projects. I'm looking at you, Awesome.

Which reminds me: What the hell, blogroll? I've posted since "Still Working". I posted last night. I posted a week or two ago. Yet you insist on showing that I haven't worked on my project in 3 months. I've remade the blogroll, deleted caches, tried alternate URLs, it always pulls up some ancient thing out of the XML. confusion++;

I'll try to figure that out

Monday, November 2, 2009

Breaking the rules

It's 2:03, and I promised myself about a week (maybe a bit more?) ago that I would absolutely fundamentally definitely start going to bed by 1 as a soft deadline, with 2 as an absolute final hard deadline. By 2 AM, I would be lying down in my bed, trying to sleep.

Well, here we are. 2:04.

I'll be done this in a few minutes, it's okay. I feel like this quarter hour of blogging is more important to me in the long run than this quarter hour of sleep. I'd rather look back and remember this, than vaguely remember a dream I may have had at some point in the future. So let's move on! (this was the title's namesake by the way, I broke my new rule. This isn't the first, the last, or even a notable time I've done so). So let's move on to a few random tidbits worth mentioning.

Justice is awesome. I've known this for a while (I started listening in earnest back in the summer), but some things, like their unreleased fabriclive mix, are just staggeringly good.

I became vegetarian after being vegan. My original reasoning for switching to being vegan was that we have no right to hold any dominion over any creature, aside from the thought of "might is right", which isn't at all universalisable, or even really that reasonable at all. A friend of mine (Andrew Stoneburgh) suggested the argument that we are actually being farmed right now. What if we're in the matrix, and being farmed, would I be cool with that or freak out about it? And after some deep consideration, I'm really okay with it. I am fine with that thought. Continuing that, if I'm okay with being farmed without my consent, it is unreasonable for me to have a problem with farming animals. I do still have problems with the way they are treated, absolutely. I just don't feel like the very notion of farming is evil or wrong, which brings use of animal products back into reasonability. Still not okay with killing them for their meat though.

Well, that's about it for now. I'm hoping that November will be a good, productive month. I don't have too much to think about scheduling wise, just TAing and assignments at the end, and 3750. Signing up for courses as soon as possible, and OSAP for next semester. Hoping to take Compilers with McCaughan, Graphics with Calvert, and some other stuff or something.

Okay, it's 2:33. Half an hour is enough. Goodnight, world.

Thursday, October 8, 2009

Robyn can't figure out the difference between dependency and composition

That's what you get for a title when I'm writing a brief post at 4:00 AM. You get a snippet of something a confused housemate says regarding UML diagrams.

-- A breakthrough! He has realized that what he is observing is aggregation. Now he has expressed a desire to know what aggregation really means. I can dig it.

I am prepared to believe that there is more good music than I can hear out there, and it's a fascinating thought. Every stone turned brings about a revelation of a musician who leaps not off the page, but out of the speakers? That was a good try at being clever, I guess.

The past week has been pretty full!

I travelled to Arizona on Tuesday, September 29th, to attend the Grace Hopper Celebration of Women in Computing, with my friends Melanie Veltman and Ali Tremblay. Ali and I flew out through Toronto and Dallas Fort Worth to Tucson, where the amazing weather embraced us (so warm! at night even!) and the intriguing desert flora crowded in to be awesome and bizarre. 20 foot cacti and strange green trees, spiny little bushes, and prickly fuzzy bulbus things were scattered about!

That was just the environment. The conference itself took place at a right-fancy hotel nestled between some tall (cactus covered!) hills on the outskirts of Tucson. Google, Microsoft, the NSA, Facebook, IBM, Intel, Amazon, Intuit, Sun, many more businesses, many universities, and thousands of attendees from all over the world at various levels of academia and industry attended the conference, to celebrate the role of women in the field of computing.

I had the educational and intriguing experience of witnessing an inverted female:male gender computer science ratio while in attendance. I was not on the receiving end of hostility or under attack, but it was at times lonely, isolating, or embarrassing. Being the only male in a room while a gender issue is discussed is bizarre - you can feel all eyes glancing at you. I may have abstractly understood what it is like to be a woman in a male dominated field before, and while I cannot claim to have a full understanding of the experience now, I am definitely more learned.

Please don't misconstrue this as me saying I in any way had a bad time! Everyone I met was intriguing and friendly. I made some new friends and we explored the conference and some of the foothill paths around the hotel. The Grace Hopper Conference is an unbelievably friendly and supportive place - everyone seemed interested to learn about one another. I feel lucky to have attended and to have met some of the most interesting people in the world - I'll definitely try to attend again.

And oh, the weather! This reminds me though, I have to post photos I took.

The time since our return has been one of the least sensible in terms of sleep schedules that I've ever held during regular class time. I have not fallen asleep before 7AM on any of Saturday (after flying in), Sunday, Monday, or Tuesday night. It's Wednesday and here I am, 5:08 AM, wrapping up my evening. I'm preparing for a whopper of a sleep at a projected 4 hours. There's quizzes tomorrow, assignments and deliverables due, friends to visit, movies to see, then friday. Which is TAing, more assignments, and then probably heading to London for Thanksgiving. Which means I won't be around home for a weekend until the 17th. I can't wait to see my family!

Final notes: I'm trying to be vegan. Have been for a week or two, it's going okay. Causes a lot of moral self-reflection. I still think meat and animal products are delicious and I wish I could eat them, but I must not due to the moral imperative.

Hopefully I start a new trend of regular blogging.

Tuesday, August 25, 2009

I'm just gonna leave this here

theme="Whatever magic does not already exist in nature, we have the power and perhaps, the duty, to create."

for later, when I need it

Saturday, August 8, 2009

Typing can be enjoyable for the sake of it

Every once in a while, when you get into a certain state of mind, you can easily think of what you want your hands to say and just let them fly acrsoss the keyboard for an extended period of time, as I"m doing now. It's cathartic, really, kind of a close bond between you and the machine. You just think, type, and try to take the buffer out between. Don't even look at it - at the keys, at the sctreen, just close your eyes and let the text spread out beneath you like a warm safe cloud.

I find I run upon that certain style of thought very early in the morning, when I still exist in a day the rest of the world has moved successfully on from. Living in the past, you might say, puts me into a place where my disjoint mind can do naught but want to spout out a never ending stream of ASCII love.

There are those who would take the humorous phrase, "diarrhea of the mouth", and appropriate it for the keyboard: "diarrhea of the hands" or "fingers", which manages to at once make the whole thing less and more disgusting. I am not one of those - but I am aware of them.

I saw 500 Days of Summer last night, and Terminator: Salvation (on to very different factors of form) and enjoyed them both (Terminator less). Perhaps the Esquire Article is onto something with a supposition that Sam Worthington is a very great actor (he fared well in McG's slaughterhouse, as did Anton Yelchin. But Yelchin always fares well.), and I was positively enthralled by the work of Marc Webb, Zooey Deschanel, and Joseph Gordon-Levitt. Funny and watchable, well composed and endearing. I've also finally called Joseph Gordon-Levitt by his actual name, instead of (I confess!), "that kid from 3rd rock" or "angels in the outfield". I'll strive to keep it up.

So I'm done now, my hands are no longer playing that mad piano game with my mind and are starting to make typos at merely par. Good morning to you, good night to me, and let's all have a chat sometime later this weekend yes?


gosh italics are fun

Thursday, August 6, 2009

Whose laughing now, Twitter?

Looks like I found an alternate means of getting my stupid messages out to the world just in time, before the great Twitter Outage of ot-nine.

Working hard, will write some fiction tonight. Summer party tomorrow, went to a tech talk earlier about Testing. Got a rad book, "How We Test Software At Microsoft". The book was written by the three guys who did the presentation, Alan Page, Ken Johnston, and Bj Rollison, who all do neat Test related stuff here at Microsoft. They're pretty cool guys, and illuminated the topic magnificently.

For those who don't know, Microsoft splits production up into "feature crews" which have a Developer (Software Development Engineer), a Tester (Software Development Engineer in Test), and a Spec-Writer / Designer (Program Manager), who all work together to create a feature. This sounds like perhaps a trivial detail from the outside, but it is a vital piece of our culture. Think about how important testing software is, and how undervalued it tends to be. Now think about your perception of "oh god microsoft makes bad products lawl". Now think about the fact that they employ about 11,000 SDEs (devs) in total, and about 9,000 SDETs (tests) - there is nearly a tester for every dev in the company. Testing is taken very seriously here, and regardless of any person's opinions on Microsoft or its products, this is a powerful defense against bugs and defects. Complex software will have issues - and our testers (in conjunction with devs, and pms) do a damn fine job of sorting those out and producing high quality software.

Anyway, that's enough of my hivemindspeak for now. Tried ModPlug recently; where has it been all my life?!

Tuesday, August 4, 2009

That Ambiguous Comma Operator

The ternary 'conditional operator' can be tricky sometimes. If you've ever looked at The 12 Bugs of Christmas and been frightened off by them, congratulations on your humanity.

After seeing a particularly confusing piece of code today, of the form:

func(a, b ? c : d, e);

I began to ponder whether func takes 2 parameters or 3, and what the heck I should assume is going on here. It also (for the first time) made the question of "does d,e evaluate to d, or to e" relevant to me. So I wrote a test program!

First, let's see what happens when we use commas in the ternary operator during assignment:

num = v0 ? v1 : v2, v3; /* each of these is a variable vn where n is the value */

This evaluates to 2. Simple enough-- let's move on.

What happens within 'func(0 ? 1 : 2, 3);'?

This case ends up being straight forward. The comma is taken as part of the parameter list and not as part of the conditional operator, regardless of the prototype of the function. I'd started out thinking that whatever works might be done (if func took 2 ints, this would treat the comma as a parameter separator, and if func took 1 int, it would be a comma operator inside the condition) - but it does not. The comma is strictly for parameters in this case. Neat - but I'm still curious what would happen to it used as a comma operator here. Should be the same as before, right? Let's force it to be used in the conditional and find out.

func((0 ? 1 : 2, 3), -1);

This is the function I tested. The second parameter (-1) isn't necessary for anything other than illustration, and so that I didn't have to rewrite the function. 'func' Now becomes meaningful to specify: it takes two ints and prints them out in the left-right order in which they were received. This is the output:

one, two: 3, -1

Wait a minute. This time, the comma operator's right hand value was treated as the expression's value! That's not the same as before! What the heck? Let's check the spec*:

3.3.17 Comma operator


expression , assignment-expression


The left operand of a comma operator is evaluated as a void
expression; there is a sequence point after its evaluation. Then the
right operand is evaluated; the result has its type and value./43/


As indicated by the syntax, in contexts where a comma is a
punctuator (in lists of arguments to functions and lists of
initializers) the comma operator as described in this section cannot
appear. On the other hand, it can be used within a parenthesized
expression or within the second expression of a conditional operator
in such contexts. In the function call

f(a, (t=3, t+2), c)

the function has three arguments, the second of which has the value 5.

Forward references: initialization ($3.5.7).
My own emphasis is added in the 'Semantics' paragraph. Clearly the right-hand operand is the one which should normally provide the value. What happened in the assignment then, which caused this to be reversed?

To the best of my knowledge, the answer is actually inside of the 'Example' paragraph. I quote,
in contexts where a comma is a
punctuator (in lists of arguments to functions and lists of
initializers) the comma operator as described in this section cannot
So the issue is that this comma is (again) not treated as part of the ternary conditional operator, but treated as an illegal comma operator floating around on the far right of an initialization. My guess is that this
If a ``shall'' or ``shall not'' requirement that appears outside of
a constraint is violated, the behavior is undefined.

(from the definition of 'undefined behaviour')
is what is allowing the situation to occur. A comma can not be placed within an initialization list and be treated as a comma operator. So if you force that to happen... whatever the heck the comma and the people who wrote the compiler have agreed on could occur.

In this particular case, it looks like what they've done (this is in gcc) is just ignore the comma and everything after it until the semicolon. Thus in the line

num = v0 ? v1 : v2, v3;

num evaluates to 2, and the ", v3" just doesn't enter the picture. Giving us our unexpected result.

Crazy cool.

* You may have noticed that this is not coming from an official ANSI or ISO standards site, and if you're particularly astute, you may have also noticed that this is merely a draft of the C90 spec. That's because I found it first and feel like C90 is good enough. But I checked the C99 spec as well (again just a draft), and the only modification is an explicit statement that a comma operator does not yield an lvalue. I only looked at drafts because ISO and ANSI are mean and don't like people to see specifications without paying money. I'm cheap, so our learning is lessened. :P

** What? a double star? That's right folks, you get a bonus note! During the writing of this post, I realized that my test program was being rather silly. I made several variables 'v0', 'v1', etc to hold simple int values. It was only while writing that I recognized I could have simply used '0', '1', etc, and that this would be less confusing to read about. I originally wrote

num = 0 ? 1 : 2, 3;

As the first expression, which now uses the variables. I didn't think this could possibly cause any difference - and was wrong! When writing a second program later to do some different tests, I used my newfound sensibility and bypassed the creation of variables. I was given the following unfriendly error code:

newterntest.c:5: error: syntax error before numeric constant

It took just a moment to recognize that this was because of the comma! The comma is (as we've discussed) unexpected and not allowed here, but it looks like this case is obviously wrong enough to the compiler writers that they generate a syntax error before the integer '3'. So whileThis on its own isn't too crazy - the crazy part is that

num = v0 ? v1 : v2, v3;

doesn't even throw a warning under -Wall -pedantic (with or without -ansi as well), while the literal integer actually causes a syntax error. Every other parenthesized use of comma operators in this situation gives at least a "warning: left-hand operand of comma expression has no effect", but our code draws a blank!

General weirdness.

edit: removed the pre/pre tags from the blockquotes. They were there by default, made the quoted text appear in a plaintext-ish font and I felt they added to the post. But in the published version, they rendered underneath the righthand column. So they're gone.

Sunday, August 2, 2009

I'm back.

I didn't forget about this (these) blog(s). I didn't stop posting for a lack of things to post. I didn't lose motivation or stop for any of the reasons I have before. This time I had something else to do that was more important - and I wasn't going to let myself spend time here when I knew I should be there. I procrastinated on it for a long time regardless, and I've finally moved past.

So let's get these cogs a cranking.

In the time I've been gone, I've flown on my first airplane, stayed in a hotel alone for the first time, climbed my first mountain, played my first game of whirlyball, had a highway cleared so my friends and I could ride along it, bought a second laptop, started an internship at Microsoft, and spent my first whole month (well, more than) in a different country. It's been quite a journey - and it's not nearly over yet.

I can't wait to be back in Canada, but I've got the rest of my work left to do, my first time skydiving to have, PAX to attend, and who knows what else? I miss my friends and family, but I'm having a good time here and I've made some new connections too. I can't say much about my work other than that I'm working on Office, and I'm coding a small feature that'll be present in a few of the major apps in Office 2010.

I've been learning lisp, listening to a lot of music, learning some foundational graphic design, and working a bit on Awesome. I'll update again soon; I have things I can show - pictures and personal work and such.

Catch you on the flipside.

Tuesday, March 10, 2009

Coding right feels good.

I have been converting my 2750 project from a hellish nightmare to dreamy pie. When I first wrote things, back in assignment one, I needed a main, and server functions. Thus, main.c and serverfuncs.c were born.

How much hard coded, non-modular spaghetti I managed to throw together is ridiculous. Over the course of the next two assignments, I expanded main.c and serverfuncs.c - never by much. It was incremental, but repeated. Over and over again I added a single function, three lines here, four there.

I ended up with a 150 line main.c with a 70 line while loop full of garbage, and a 550 line serverfuncs.c, which had keyboard io, dynamic library loading, network functions, fifo functions - shit was not so cash.

My project has been to nicify this in time to use it for the database portion of the assignment, which will be due in a day or two. I am feeling very good about it at the moment.


Are now my code files. Main is about 20 lines of intensely readable code, and everything else just works marvelously at the moment. The only errors valgrind gives are dlopen() related, and there are no leaks.

What became network.c used to be a series of functions which figured out the size of a file, read the entire thing into memory as a string, then repeatedly ran a function on the string which would find replacement tags and replace them. It then wrote the string to a temporary file, which would be read back in moments later to be sent out to the client.

The repeated function - this was the worst part. "replacements" was called on the string 'data', which could be very large. "replacements" would load up the first search string, and then perform a strstr() on "data" repeatedly looking inside it. When it found the string it wanted, it would perform a lot of loopy string manipulation and pointer arithmetic, allocate a new string of a slightly altered size from data's, copy everything over, then free data. Repeatedly until it couldn't find the search string in data any more. Repeatedly until it ran out of possible search strings.

Now, when a tag is found by yacc, it gets passed into the new "replacements", which acts very similarly, but only on a small piece of text, and in a much less complicated fashion with less string and pointer manipulation. It was nice to see entire functions bite the dust as everything became streamlined.

I still have the gui/fifos to reimplement (the code is there, just needs to be brought over), and lex/yacc to fix. Then there's the database portion of the assignment. Which is due Wednesday at midnight / Thursday at 9:00 AM. In other words, I haven't got a lot of time left.

This has been a good part of an ongoing lesson in time management. Balancing the development of this code with TAing, SOCIS, Senate, and 3 other courses (now 2) has been difficult, but not impossible.

I've gained a lot of respect for proper code as opposed to messy code - and learned that even the intent of "doing things right" is meaningless when you don't know what "right" is, or adhere to it when you find out.

Challenges ahead? I'm not certain how to actually find the dynamic bits with whitespace - unless lex and yacc return every possible tag and I check it, I have no idea how I'm going to get them to find a dynamically loaded string as part of a precompiled token/rule.

Also, there's the instability that my program had during the last assignment. I don't know what caused it - and I spent a long, long time walking through valgrind traces looking. If I can make it be more stable with a <20 line delta, that's great - but it's unlikely I can do so.

Also: letter writing went well enough. Glad to have that done. And good night.

Sunday, March 1, 2009

Calculation Complete!

On a particularly inane note, after some calculation, since the beginning of this project (16 weeks, 2 days, 10 hours, 36ish minutes ago), I have (by one naive metric) averaged a bit better than a post every two days.

60 posts (now), divided into that time, comes out at about 1.9 days / post. I'd like to get that number below 1, but I'm happy with my progress and commitment. Go team Wyatt.

My notes:

5:54 PM, November 6th, 2008
6 minutes
6:00 PM, November 6th, 2008
6 hours
12:00 AM, November 7th,
2 days
12:00 AM, November 9th, 2008
16 weeks
12:00 AM, February 28th, 2009
4 hours
4:00 AM, March 1st, 2009
30 minutes
4:30 AM, March 1st, 2009

16w2d10h36m, 59 blog posts

16 * 7 + 2 + ((10 + (36 / 60)) / 60)

114.44166666666666 / 60 = 1.9073611111111111, ~1.9

I'd like to thank python for being my desktop calculator.

Saturday, February 28, 2009

New Things

I just finally replaced those awful speakers I've been dealing with for the past few years. There was an issue with the power connection on them, and my jerry-rigged solution finally gave out. I had the power cord pegged underneath my computer monitor, and a deck of magic cards holding pressure on the speaker. It was awful. Anyway, these are nothing crazy - just a $40 2.0 system that doesn't sound awful. Insignias from Future Shop.

I also bought headphones - after so foolishly leaving my other pair in a classroom, I decided I would shell out for another pair and just take much better care of them. Sennheiser PMX-60's. I like them so far, and bought the replacement warranty, so I can be abusive to them like I'd like to be. .. I also just checked them out online and found I've overpaid by about $20. Presently deciding if it's worth the hassle of returning them and waiting for shipping.

Going to work on 2750 tonight, and probably watch some Scrubs. I've got big ideas for how to reorganize that code - and I'm excited to get in there and do this right. Also bought a sweater that I swear Sheldon could wear.

A sentence I'm happy with: "Sometimes you make me feel... Like I am Worf and we are on the Starship Enterprise."

Sunday, February 22, 2009

The coding (working) groove

As a personal note:

I love working. I love coding, reading, playing music, doing math questions - counting these here as types of work - they are always intensely fun. I just also love doing nothing. If one were to count it as a type of work for the sake of argument, then you could say I get stuck in the groove of doing nothing.

This is just one more brick in the wall that reads: Whatever you have to do, you have less time to do it than you believe. Whoever you love knows it less than you think they do, and whatever you apply yourself to, you can enjoy.

I guess it's a bit of a steal from "A journey of a thousand miles starts with a single step."

-also, Microsoft Interview time is scheduled. I'll be writing about this more soon.

Saturday, February 14, 2009

Mission: Success

Slightly less time spent running about than I planned on, but I covered good ground. My trip went as follows...

Part I

Ran around the college bend,
Trotted up to the Hanlon,
Slinked onto Centennial's grounds,
Maneuvered to the top of the sled hill,
Rollicked down the slope,
Frollicked across the field,
Sauntered onto the hidden path,
Emerged onto Edinburgh.

Part II

Trekked toward downtown,
Rocked into the great river,
Walked across Wellington,
Strolled up to Waterloo.
Stole past the Montessori School,
Followed under the train tracks,
Visited God in his house,
Caught a falling star.

Part III

Ate the rice of the double sun,
Stood in the royal bank with everyone,
Jogged across the square,
Wandered down baker to the bridge.
Revisited old haunts,
Returned home nostalgic,
Fled long held memories,
Worshipped long known prophecies.

Part IV

Heard the oncoming future,
Zipped along the tunnel,
Descended the hilltop stairs,
Bounded onto the hundred,
Found my way to Elizabeth,
Hopped a bus back downtown,
Purhased a Large Quebec (and got my own fork),
Stalked beneath the tracks.

Part V

Ate past the silent fast food stores,
Texted on the bridge,
Explored through the park,
Deposited my garbage.
Sang my song to a different tune,
Bolted up the hill,
Greeted an unforeseen friend,
Wound up back home.

Ah, what a way to express an adventure. I had fun. Especially the falling star, and the simultaneous train viewing. That was a good touch. We are now on the flipside: you have been caught.

Friday, February 13, 2009

Enjoy this while I can.

My feet work. I am not ill. For the first time in a half decade I simply feel good.

I am going on an adventure. New music: check. Ambitious plans: check.

Catch you on the flipside.

Tuesday, February 10, 2009

Another quick bit here-

I need to sleep better, clean more, organize more, and think less.

... That is all? I wouldn't say work more or harder, but work smarter for sure. Like that screensaver from mom's 486 back in 1992. "Don't work harder, work smarter! Do it!"

Yeah. Too late at night. Goodnight, moon.

Sunday, February 8, 2009

Quick note

I have a job and I'm going somewhere neat. I got through 2750 (barely) but I'm gonna have to gear up again real soon.

Lots of meetings and events and everything coming up this week. Reading week right after. CS Games moving forward and Roboticon on the horizon. Gotta SRM AGM and other stuff.. so much to do, but it's all very rewarding-feeling.

Gonna go watch Tom Cruise be the man.

Sunday, January 25, 2009

Man things get busy quick.

SOCIS, 2750, Digital, Operating Systems, Letters, Roboticon, 1200-TAing, laptop crashes... Just when am I going to be able to watch Andy Richter Controls the Universe?!

Things have been very busy recently. I would be (joyfully) working on 2750 right now, but I have a letter to write. I'd be doing that, but I have OS and DS (Operating and Digital Systems) to do... They're kind of competing here, as this OS assignment is worth way more, but this DS assignment is due first. Actually I only remembered that OS is worth way more than DS as I wrote that ... *researching*

Okay yeah. This is one of 3 OS assignments, and is worth 10% of my final mark. Conversely this is one of 10 DS assignments, and is worth 1.5% of my final mark.

If I quickly try to do what DS I can, then I can switch over to OS and put in a lion's share of time there. Yeah. If I can get OS to a reasonable spot, then I can do letters, and then 2750! ... Man.

Also co-op stuff. I haven't done nearly enough co-op stuff. I've been sidetracked from writing this by doing stuff. Write more another time.

Sunday, January 4, 2009

School's in for the Semester.

As opposed to out for summer.

I'm not at all ready, but that's okay with me. I have Digital Fundamentals, Operating Systems, 2750, Algorithms, and a TA meeting tomorrow. Fun stuff.

(For my use later: They are at 10:30/227, 11:30/124, 12:30/117, 2:30/029, 3:30/Dyer's Office tomorrow)


So I just played a bunch of piano, by which I mean I played around with a piano a bunch. I'm using a lesson book my friend Robyn has, it was pretty enjoyable - but I reached a certain point and just needed to stop or something.

Over new year's a few friends and I played Risk: The Game of World Domination. It was swell. We all used computers to talk strategy back and forth, and everyone played a pretty unique and interesting role, we will have to play again. We made an awesome setup with the board on a large piece of wood balanced on a few piles of stuff (books, TVs, etc), and moved our chairs in around it, in a room that could be called The Perfect Game Room.

As a reflection on the break ... I didn't really do that much. Which is not to say I did nothing - but as usual, I didn't become the paragon of productivity I had intended to. This is not a surprise, but disappointing nonetheless. I traveled, played video games, read Ender's Shadow, learned things, wrote programs, played music, watched Television, cleaned, and thought - so I guess that's enough for some guy.

Also, I started a twitter. I'm pretty happy about it still - that could pass.

Anyway, off to continue cutting things off my todo list before school.