Archive for » November, 2008 «

Sunday, November 30th, 2008 | Author: renaebair

 

Shack for my ugly codez

Shack for my ugly codez

After a chaotic holiday weekend and chaos with sugar-injected children, I finally found a free hour this weekend to create a nice, cozy class for the time_track app! Now it just needs a big refactor before I can start implementing new features and functionality. So far I think I’ve covered most of the Ruby basics other than blocks and procs but I’m not sure I’ll need those for this little program right now.

I finished Chris Pine’s “Learn to Program” book this evening. I’m looking forward to spending some time re-reading Why’s Poignant Guide To Ruby; I think I’ll find some nice gems (hahahaha) in there now that I have some more foundational knowledge of programming under my belt. 

For now here’s the new codez:

Friday, November 28th, 2008 | Author: renaebair

I think I feel too much. Maybe I spend too much time on reddit.com. Maybe I’m just cursed by being an Aquarian. Or perhaps I am just human. But how can I be human and share my humanity with people like these terrorists in Mumbai? How can my life be filled with love, hope and beauty while so many lives are void of all those things? Where is the disconnect, the great divide? 

I just spent the last 20 minutes looking at these photos from Mumbai; I’ve been moved to tears many times by human tragedy so I wasn’t surprised to find myself a complete wreck after looking at these. I am an incredibly soft humanitarian and I feel the pain in the world every day. I carry it with me like an emo 14 year old myspace addict. When I look at my own children smiling I can’t help but remind myself that there are children just as beautiful as my own that are crying, being beaten, raped, or neglected at that very moment. When I go to the store to buy groceries I think about all of the families out there that don’t have money to buy groceries to feed their children. When I walk outside on a cold Maine winter evening and feel the icy air rip through my bones I feel sad for the people that don’t have a way to escape that cold, no homes to keep them warm. When I buy clothes for my kids at a department store I think about the tiny, fragile hands that made the clothes for only a few cents a day. I think about how my own country has destroyed the natural environment and economic structure of third world nations so that we could pay as little as $3.99 for a shirt at walmart when in the real world you couldn’t even buy a yard of fabric for that little money and make it yourself. 

My husband thinks I’m totally nuts. I drive myself insane because I can’t rationalize all of the chaos out there and I can’t find a way to contribute to the solution. He reminds me gently that I am contributing my raising two children with so much love and patience because someday they will inherit this world. He is right, but it doesn’t make me feel any better about the horrific things that are happening.

And as everything falls apart, as our humanity frays at its seams, the American consumer just goes right on consuming. They run in their hamster wheels and their scenery never changes because they refuse to look beyond their own borders and their own fabricated reality. We are losing our civilized world. We are falling victim to the savagery that is born through hateful dogma, consumerism, and our lack of presence within our children’s lives.

We work so much because we need to pay bills. We need to pay bills because we have been made to feel as though we “need” certain things like two cars per household, lots of name brand clothes, the newest technologies, new furniture, candle sconces, new coordinating bath rugs and shower curtains, on and on. We need these things because the TV tells us we need them. Our neighbors have them. Our friends have them. We must have them. We must assimilate. So we consume. And it never ends. We’re never happy. We are slaves to jobs that most of us hate and we work to pay for things that we turn around and sell in a lawn sale at 10% of its original price a year later. In the meantime, we’ve left our homes empty. Our children are forgotten. And when we are not there to nourish them emotionally and provide a stable foundation of love and support they turn to TV, computer games, myspace communities, and other forms of support and get lost in the confusing web of unattached support systems. 

I am overburdened by the sadness in the world. I cannot understand hatred because I’ve never truly felt it. I just want peace, understanding, diversity, and acceptance. I want that for all of us. Isn’t the need to love and be loved a part of all of us? When I sit quietly in the rocking chair as I nurse my baby boy, my thoughts wander. Many times I have looked into his dark, dreamy eyes and wondered how anyone could not love a child like I love my own. And I wonder how anyone that is this loved could ever grow up to do so much damage later in life. I don’t think they could. I think that love and peace must start between a mother and her child, and then blossom from there. I can’t think of any better way to cleanse the world of hatred than to hold our sweet children close to us, rock them gently, and allow ourselves to love them with every cell in our body.

Thursday, November 27th, 2008 | Author: renaebair

OMG wow I need to learn how to use classes! I’ve been working on the time_track app and it’s getting so out of hand. I took the advice of Ben regarding the time formatting (see advice here) and I’ve also added reading/writing to a yaml file. At this point it’s incredibly bloated and needs some work, so that is the next step.

So far the application prompts the user to hit “enter” to being time tracking and then “enter” again to stop time tracking. When the user stops the tracking the two times are subtracted and the resulting time is stored in a yaml file. In addition, all of the times in that yaml file are added together and the running total is stored in another yaml file.

Yes, this is still a very simple little application. But I have delusions of grandeur for this app, so let me tell you all about its distant future! I want to create an open-source time tracking application that requires as little user input/maintenance as possible and has built-in fault systems to detect possible user error (in case the user leaves and forgets to stop the timer). I believe this would be incredibly useful to programmers that do a lot of client work and whose clients demand very accurate time logs.

Here is how it would run: When you open the application it sits unobtrusively in your menu bar (think Caffiene). When you click its icon with your mouse of choice (I prefer the Razer Lachesis; great for coding and gaming fun) it starts time tracking. You go about your work, writing beautiful code. When you want to stop tracking time you simply click the icon again in your menu bar. The total time is stored. You can click it again to start tracking time when you are ready to work some more.

The app will have a nice functionality that detects when there hasn’t been key strokes or mouse movement over a certain period of time and it will prompt the user for input to determine if they are still there. If it gets no response it will create a ticker at that very point in time (but won’t stop tracking) so that when the user returns (if they were ever really away) they can choose to look back and find out where they should have stopped the timer.

The app will of course calculate the time logged for any date range so that a programmer can keep very accurate time logs of his work on projects. There will also be a quick way to change between time tracking for different clients in case you end up working on multiple client projects a day. I’m very excited about it and I know it’s going to take a long time to write and will probably be quite impossible. But the delusion is there and I’m going to follow it! :)

So here’s the gross code I’ve written thus far and my next step will be to compact this all into a nifty little class:

Category: Uncategorized  | Tags: , , , , ,  | One Comment
Tuesday, November 25th, 2008 | Author: renaebair

I wrote my first little app in Ruby tonight. Well, that’s a lie. I’ve been writing cute little inapplicable apps for the last month but they’ve just been exercises out of Chris Pine’s “Learn to Program” book. Tonight I actually decided to write a very basic time tracking app armed only with the knowledge I’ve cultivated thus far and it came out swell. I know it’s quite basic and lame, so please laugh. I am laughing at it right now. But I’m learning as quickly as I can with only 2 hours of time a night available for learning Ruby. 

I did end up having to use a hack to display my time (from seconds) to a pretty-formatted date/time string. But I hope to come back to this problem later and come up with my own solution. It doesn’t store the data to a file yet but I’ll be adding that tomorrow evening. I know it will only take 5 minutes but the kids do wake up around 5am and I’d sure like to sleep now :)

Here’s the nuby code:

Category: Uncategorized  | Tags: , , , , , ,  | 3 Comments
Monday, November 24th, 2008 | Author: renaebair

 

Being unstable and bitchy is all part of my mystique

Being unstable and bitchy is all part of my mystique

I’ve been a rubyist for three weeks now and it’s my turn to rant.

Only a few years ago it was “fringy” and incredibly cool to be a rubyist. There was an underground camaraderie/elitism between fellow Ruby pioneers. They realized they were onto something so discreetly awesome that they would have an oportunity to claim fame and fortune as this language was introduced to the masses over the next few years. And claim their fame they did. But alas, now that the language has become significantly mainstream and generally accepted as legit, these expats (Java devs enjoying a more trendy and carefree life in ruby_land) are now hurriedly disclaiming it before anyone has a chance to notice that they are doing something mainstream.

The Rails community is just as bad. It has a larger market share of ranters and they are especially prissy. Shitting on Ruby and Rails is coder couture and everyone’s jumping on the bandwagon. What most of them fail to realize is that Zed Shaw beat them all to it. They aren’t the first to disown rails, though they proclaim their hatred with such shocking fervor that you’d think they were. The ranters that followed him are just callously ripping apart the very language that freed them from their boring (insert crappy language) jobs and offered them the beauty of a minimalist coding atmosphere. They are acting like petulant children that were spoiled for 18 years by adoring and forgiving parents, only to turn around and rebel for the sake of rebellion.

I understand there are shortcomings in both Ruby and Rails. Neither platform solves all problems nor do they claim to; sure, some of their frontmen would have you believe it does and it’s been marketed as such in many cases, but most programmers realize that Ruby isn’t the end-all of programming languages. Ruby isn’t the answer to all programming questions. There are plenty of great languages out there and more will inevitably be created. The most frustrating thing about this is that both Ruby and Rails are open source. Any one of these trendy haters could learn some C and make it all better. But who wants to spend time contributing when there’s no money to be made or fame left to be had?

In the Rails community I think the issue of elitism has been the cause of a lot of friction and lashing out. Those who have been unfairly excluded from the Rails lunch table seem to be especially vigorous in their attempts to bring down the popularity of the language. Then there are those that come to Ruby or Rails on the promise of the language being the universal remedy and they are disappointed, hurt, confused, even a bit ashamed once they realize that this is just another programming language/framework. They act as though they are waking up naked in cold shower after prison sex. First comes shame, then outright rage.

I don’t care if these assholes left decent paying java jobs for this “revolutionary” ride and were disillusioned. They should have had the foresight that there is no panacea of greatness. There is no single solution. What ruby does offer is a more intuitive way of coding. Its form is simple. It’s full of grace. Ruby is succinct. It’s not the messiah of languages though it attracts many messiah-figures and their fanboy prototypes. There is a market for it, there are people that love to code it, and that’s about it. I don’t want to hear you rant on about it like some burned lunatic just because you think we all need turn around and follow you on your way out the door.

There should be healthy discussion about the shortcomings of programming languages. It draws a landscape for new ideas and solutions. It gets a community thinking and working together. But what I am so annoyed with are the reformed evangelicals that are all of a sudden declaring that “this shit ain’t cool no more” and expect everyone to throw up their hands and say “Oh wow great leader, you’re right. Let’s just go learn [Scala, Erlang, Clojure, Whatever].”

I’m aware I’m just as uncool for ranting on the topic even though I’m ranting about the ranters. But I’m not attempting to be cool, no one reads my blog anyway, and I’m a mother of two babies who spends her time wiping poopy butts and scraping peanut butter out of carpets. The biggest decision I have to make on any given day is whether or not it’s ok to serve them a piece of chicken that’s not organic and then hope that the growth hormones won’t give my daughter porn-sized boobs three months from now. I play video games, I code a bit here and there, but I have no claim to fame. I’ve been writing Ruby code for three weeks. Seriously.

Ruby gave our family a launch pad for success. My husband was a quiet early adopter and he’s worked happily with the language for a few years. He’s been able to find a job with a sweet company that lets him work from home. Which means that he gets to work in his boxers and t-shirt, is able to have PB&J’s with us at lunchtime, and is always home for dinner at 5pm. I am quite enjoying the solace that comes from not being neck deep in the rat race.

For myself, I’ve been learning to program with a language that doesn’t make me want to cry. I remember doing C++ and Java homework in CS classes in college; I do believe I have post-traumatic Java syndrome. It’s unbelievable even to me that I have dared to get into programming again. But Ruby is making it easy; even fun. I’m happy to code with it, and I’m happy to be enjoying the amenities of the lifestyle it has provided for us. I’m sure I’ll have qualms with some aspects of it someday. And it will be ok to voice them. It’s ok to bite the hand that feeds you. Just don’t bite it off.

Category: Uncategorized  | Tags: , , ,  | 60 Comments
Sunday, November 23rd, 2008 | Author: renaebair

Tonight I sat down to do some more work in Chris Pine’s “Learn to Program” book. I’ve been working in it for a couple of weeks now and I find that it’s a good refresher on programming methodology. It’s a bit outdated but it still serves a function for me right now. (I think it was first published in 2004). 

I’ve been sailing through the book and all of the exercises and was quite happy with myself; until I got to section 10.2 where I was asked to write my sort method as a “rite of passage.” Obviously, Ruby has it’s own sort method, Array#sort. But never one to ignore a fun challenge I geared up for an interesting evening.

I tried a few things on my own merits but ultimately went searching online for some tips. I came across a beautiful solution (trust me, there were UGLY ones out there) but I couldn’t wrap my newb brain around the logic of it. So I asked Adam to step in and help me decipher what was going on in this code:

As an aside, this stuff takes me awhile to digest because my brain is already pathetically overused by the time I sit down to learn. Between watching Serenity and Sébastien all day, keeping the house in reasonable order, preparing three nutritious meals a day, and everything that happens in between all that I am poached by 8pm when the kids are finally in bed. On top of that, Sébastien still wakes up every hour and a half all night long to nurse, and they both wake up by 5:30-6:00am for the day so I never really sleep; so just add zombie to my list of character traits, along with indecisive, erratic and total_nutcase.

That being said, I definitely asked Adam to sit down with me and help me work through that code. We re-worked it a bit to fit with my data from the exercise, and here is what we have:

It took me about an hour to realize how this insertion sort functioned. I didn’t want to just know the code to write it, I really wanted to understand what was going on behind the code. Adam, being the resourceful teacher that he is, made a diagram with word & index cut-outs and wrote out the code on paper. He moved the cut-outs around through the code to show me what was happening through each iteration of the code. It was brilliant because after an hour of staring at the code and feeling brainwashed, I finally understood! Yay for milestones!

Adam, showing me the logic of an insertion sort with paper cut-outs

Adam, showing me the logic of an insertion sort with paper cut-outs

But with that understanding came a desire for more goodies! It seemed as though there must be a faster way to sort through data. So we went hunting for information on sorts and we found this really neat animated example of different kinds of sorts:

http://www.inf.ethz.ch/personal/staerk/algorithms/SortAnimation.html

The merge sort really jumped out at me because it seemed super fast and looked neat. I wanted to find the code for a merge sort in ruby and run some test data to see exactly *how much* faster it would be than my hand-made insertion sort!

I quickly found this code:

We ran this code and benchmarked it against my insertion sort method and what we found was… awkward. My naive understanding is that merge arrays are usually much faster than simple insertion arrays. But in this case the merge sort was slower by several magnitudes. Our data was stored in a yaml file and consisted of 500 words alphabetically randomized.

Results:
Insertion Sort:
# Run 100 times
# user system total real
# 0.120000 0.000000 0.120000 ( 0.124449)
# Run 500 times
# user system total real
# 0.470000 0.000000 0.470000 ( 0.477175)
# Run 1000 times
# user system total real
# 0.930000 0.010000 0.940000 ( 0.947101)

Merge Sort:
# Run 100 times
# user system total real
# 0.420000 0.000000 0.420000 ( 0.423855)
# Run 500 times
# user system total real
# 2.040000 0.010000 2.050000 ( 2.066814)
# Run 1000 times
# user system total real
# 4.110000 0.030000 4.140000 ( 4.147465)

WOW, right? Well my guess is that whomever wrote that merge sort method was on crack, or I just don’t understand how it’s supposed to work which is a VERY REAL possibility!

Merge Sorts Average Time: O(n*log(n))
Insertion Sort Average Time: O(n^2)

Clearly, the Merge Sort should have been faster. So my task for tomorrow evening is to find a better example of a ruby merge sort and implement it, benchmark it, and move on with my training. I think Chapter 11 in Pine’s book deals with reading/writing from files and such which should be pretty simple. Tonight was an unusual diversion but was incredibly fun and insightful. I certainly know more about sort methods than I ever thought I would *want* to know! :)

Oh, and just for kicks (because I was dying to know) yes, Ruby’s built-in sort method was the fastest on my test data! Made my sorry insertion sort want to cry nails. Ouch.

Ruby Sort:
# Run 100 times
# user system total real
# 0.010000 0.000000 0.010000 ( 0.013807)
# Run 500 times
# user system total real
# 0.070000 0.010000 0.080000 ( 0.066741)
# Run 1000 times
# user system total real
# 0.130000 0.000000 0.130000 ( 0.132825)

Category: Uncategorized  | Tags: , , , , , ,  | 4 Comments
Monday, November 10th, 2008 | Author: renaebair

There is a war raging within me. The context of the war is location. The enemy is myself.

For the past couple of years I’ve been playing mediator to these two distinctly separate sides of myself that are fighting over where I should sit my butt down for awhile. I am in an incredibly unique position; I can live absolutely anywhere. And I do mean anywhere. My husband is a software architect for a thriving company, Intridea, in DC. They have no real office and all of their employees work from home 100% of the time. They are very generous to all of their employees and they encourage them to live where they will be happiest. Their employees are spread out all over the country, from California, Atlanta, Virginia, to Maine. 

Adam’s initial interest in this company was based upon this particular perk. At the time he interviewed with them we were living outside DC in Ashburn, VA — a beautiful town (albeit very stepford-wife-ish) constructed almost entirely of pre-planned communities. The location offered an abundance of parks for children of all ages, shopping, museums, and was only about 30 minutes away from all that DC had to offer. I was part of a mommy group that did lots of play-dates and my one year old daughter was close with a few of the children in the group.

I was pregnant with our son, Sébastien and he was due in January of 2008. We decided that we wanted Adam to have the ability to work from his home office so that we could go back to Maine to be close to my family and our old friends for support. In November of 2007 we packed everything and made the trek back to Maine. We didn’t anticipate not feeling so good about that decision. 

It was only a couple of months into the winter when Adam and I both started having awkward realizations about the state we had called home for so many years. We began to realize the meaning of the phrase, “You can never go home.” We felt as though we were strangers in a familiar land, mere ghosts drifting through the now dulled landscape of what used to be our home. We saw the same old roads, same restaurants, same street signs, same buildings. We saw family, we saw friends. Although my family has been a great support system for us since we moved back, the friendships that we hoped we were coming back to were not what we thought. Our friends now had kids of their own, lives that were based on different schedules, and had formed common ties with other people in our absence. Friends seemed more competitive and less open and loving. It wasn’t as we remembered. 

Unarguably, Maine is one of the most beautiful spots. Its dense, lush forests abundant with wild creatures, its long craggy coastline, historical lighthouses, quaint coastal towns, charming mill towns, and its gorgeous mountains and lakes make this state a definite contender for the “great place to raise a family” category!

But aside from what a tourist might see, there are some pitfalls to this great state as well. Aside from the small city of Portland (where the cost of living is incredibly over-priced based on the economic situation there), Maine lacks any real enriching, cultural opportunities. Rural towns are alarmingly white and I would consider most Mainer’s attitudes and values to be aligned with those living in red states, despite Maine’s long history of being a blue state. And don’t get me started on red states, you probably won’t like what I have to say :) 

Also, Maine is quite cold. It certainly hardens us, makes us rugged and weathered. I could chop wood in the dead of winter and not complain too much, or shovel a driveway after a storm dropped 16 inches of snow on us. But being hardy isn’t the single, ultimate life skill I want my children to have when they are ready to go out into that beautiful world someday.

I’d rather that my children are open-minded, well-traveled, philosophic, inventive, and that they know to question authority. I want them to walk the streets of great cities and feel the excitement that comes from possibility. I want them to understand humanity for all of its failures and successes. I want them to be compassionate, and fierce. However, I would also want them to know how tend the land so that it yields life sustaining food for their bodies, and how to navigate through forests, identify mushrooms, climb mountains, paddle down rivers, ride horses, and how to feel at home upon Gaia herself. 

So what landscape do I choose to raise them upon? The fertile, peaceful earth in Maine, where they will have the opportunity to create a lifelong relationship with their extended family, as well as enjoy the simple and beautiful gifts of nature? Or do I separate them from this state and our family in order to raise them in a location that offers the possibility of a more enriching and cultural life? Are there places that could offer all of these things? If so, would it be worth taking them away from my family, whom now plays a very active and loving role in their lives?

When we left Maine the first time, I was 9 months pregnant with my first child. My parents were devastated. But atleast at that time we could claim that we had no choice; Adam was offered a great job, top-notch salary, and a new career doing what he loved. It was obviously a great benefit to us as a growing family. We had to follow that path and seek out our destiny through that opportunity. We could excuse ourselves based on that. But this time if we were to move somewhere we would have no one to blame but ourselves. Were we to uproot our kids and leave my family we would have to take full responsibility for doing so. And that will be incredibly hard to do. 

Every day my mind wages this location war upon itself. I’ve always been an adventurer. I don’t like to stay in one spot for very long. I thrive on new settings, new people, and the unknown. So I have to ask myself as I ponder the idea of staying or leaving, am I just thinking about leaving because this is a behavior pattern for me? Certainly, my spontaneity and love for discovering places unseen is part of all this. However, I do seem to have an internal checks and balance system now that I have children, whereas before I could have decided to leave everything I knew behind me at a moment’s notice. 

For now I am just stuck in the mud, so to speak. I’m not quite happy where I am, I’m wondering whether I might be happier somewhere else, I’m wondering where that somewhere else might be, and I’m wondering if it would be worth it in the end anyways, all things considered. It’s a tiring battle because no side ever wins. One day the “move!” side gains ground, but the next day (or even sometimes moments later) the “stay!” side catches up. I’m so torn that I feel paralyzed most of the time. It hurts to think about the future because I haven’t made up my mind about the present.