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.

main.c
common.h
common.c
network.h
network.c
gui.h
gui.c
dynamics.h
dynamics.c
httparse.h
httparse.c

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,
Waited.
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.
Music'd.
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.
Moonrose.
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,
Train'ed.
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.
Laughed.
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)

Okay.

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.

Sunday, December 28, 2008

Wind is so awesome it's already the past tense of victory

The world got intensely windy in the past 20 minutes, and it's incredibly neat.

It's raining out, but I think I've got to go outside. Ridiculous wind.


wooooo

Harumph

Transitional stages suck.

Once you get settled in, hunkered down, into the groove, whatever flashy cliche you'd like to use - work gets a lot easier. Time flies by but the work flies by faster and you look around to think "Wow, I can't believe I've done all this stuff!" and feel proud. Then you decide to grab a sandwich and take a break and it's approximately a hundred trillion years before you can concentrate again.

I'd like to know if people who work this way (because really, it's difficult to believe that we all work this way) get more done, or less done, than people who don't.

The type of work that gets done during those focused periods is incredible! It boggles the mind to think about how ridiculously productive a person can be - but then there's these innumerable lengthy periods of downtime hanging about and you might come out at a balance overall, or even a loss on productivity.


Anyway, I'm in one of those places right now.

I want to be doing stuff, but there are a million little things pulling in different directions. I want to play video games but they're in Windows - just the slight bit of difficulty to boot out is enough to make it not worthwhile. I want to do some animation but it takes a level of concentration I really don't feel I have at the moment. I want to go to sleep but I've been drinking a lot of pop and I don't want to just waste my time in a comatose state. I'd love to watch more Scrubs but that means downloading more and I've already watched several hours of it tonight.

I want to make food but I don't have anything complete to eat: Pasta without sauce, soup without crackers, cereal with old milk.

I want to clean my room and do laundry but it's the middle of the night and cold everywhere - it'd mean being up for the next several hours.

Most of all I want to stop whining on about my completely non-problems, but here I am complaining away, wah wah wah, 'I can't make up my mind on simple things booo' - it's kind of pathetic.

I think I'll work on the taxonomy - by which I mean think about the taxonomy while I tidy the room and somewhere in there, fall asleep.