Took a huge leap in Koans today after hanging out at the General Assembly downtown. Met a few people (due to Mozilla shirt, what what George), but mostly processed a few key ideas in Ruby Koans--now committed to github after someone's recommendation.
Today's chunk was rather huge: Focused on classes, constants, message passing, and methods, as well as finished the Greed game code (which didn't take too long), and the Dice Project code (which was very familiar to Chris Pine's version). One major difficulty I've come across is writing code to someone else's code--it's really frustrating when you have a design idea but it has to work with someone else's idea of how it should be framed.
I left off at Proxy Object Project, realizing I think I need a night to let the learning settle in before I get back at it. I also need to find my coding notebook so write the pseudo-code, since I'm not nearly good enough to just figure it out by writing code straight. This is a lot of calling objects and messages to be sent around--which is everything I read about today--but I just need some time to digest and review before kicking it in. 259/274... so almost done!
Interview week starts off tomorrow, followed by meeting with a startup CEO about another position, and more interviews next week.
Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts
Wednesday, July 13, 2011
Friday, July 1, 2011
Late night update
Just a late night update. I started playing around with Watir today, and all I can say is this so far:
The source information is OLD. I understand this is a test app that is probably old now (no updates to Firefox since 3.6? oh boy...), but none of the documentation from online is either written very well or edited. One of the example programs it even came with had a line of code defining a search bar as 'seach,' and then calling on the search later with it spelt correctly. Whoops
This will likely be a great time for me to start digging through a Ruby gem to figure out what is defined in FireWatir's gem and what is not. It'll end up being a week of just testing every little thing that I see, just to see what it does. Oh boy!
I also was introduced to a website today, Weekend Testing. It's a community of testers who do stuff on the weekends, I guess. This weekend will be bad for it--but if the driving schedule goes as planned, I might be able to spend some time on it next Friday and Saturday, just to see what goes down. It looks exciting, none the less!
Getting Zachary's pizza tomorrow. Excited as usual.
The source information is OLD. I understand this is a test app that is probably old now (no updates to Firefox since 3.6? oh boy...), but none of the documentation from online is either written very well or edited. One of the example programs it even came with had a line of code defining a search bar as 'seach,' and then calling on the search later with it spelt correctly. Whoops
This will likely be a great time for me to start digging through a Ruby gem to figure out what is defined in FireWatir's gem and what is not. It'll end up being a week of just testing every little thing that I see, just to see what it does. Oh boy!
I also was introduced to a website today, Weekend Testing. It's a community of testers who do stuff on the weekends, I guess. This weekend will be bad for it--but if the driving schedule goes as planned, I might be able to spend some time on it next Friday and Saturday, just to see what goes down. It looks exciting, none the less!
Getting Zachary's pizza tomorrow. Excited as usual.
Thursday, June 30, 2011
Napa Wrap Up
I'M OUT
...almost.This week ramps up to a close early upon realizing I need to move out of this apartment by tomorrow afternoon, and still have things to box up tonight. Packing light--and it's nice because I got rid of all my books (woo Kindle, thanks Colleen!)-- and I should be able to fit my whole apartment in to the trunk and backseat of my Altima. It's all increasingly busy, considering this is the first hour (and only hour) I have to myself today. It's been meeting after phone call after meeting since yesterday, and will not end until Colleen and I leave on Sunday morning.
I have had fun testing out two new products that came out recently: turntable.fm and google+. I moderate my own turntable room (dropturntables, aptly named), and we have about 4 - 5 regulars show up. I'm also at the eventbrite one on occasion--great bunch of people there. Google+ I just hopped on last night, and right now it looks like Wave+ with Facebook. Wasn't a fan of Wave, but I'm excited to see how G+ turns out.
I'm reading a new book: Everyday Scripting with Ruby by Brian Marick. It's a programming book written specifically for testers, so I'm hoping I can finish it up by the end of the weekend and I'll have "some" kind of STE chops with improved Rubying. I'm also getting on Watir to work on some web app testing skills. I like the presentation of Watir, and I think it'll help me get those basics I need to have if my interest in testing continues the way it is.
Starting Sunday, it'll be driving about 10 hours a day for a week straight. I'm hoping to use the blogspace to share my trip with some pictures. Would love to hear back from readers: ideas for on the road? Colleen and I have Pandora, but we know how long that lasts! The last car trip I did was the 2006 drum corps tour with the Vanguard---but I was on a bus, and the driving was all at night, so I slept. Post a comment!
Back to packing...
Tuesday, June 28, 2011
Rubying with Regexp
So far Ruby Koans is a lot of review for me. I learned a few new things (a lot about symbols!), but I finally get Regular expressions. This was almost completely new, but I run into the code quite often when looking through examples--most commonly at rubyquiz. Let's see if I can go over all the params from Koans...
Note: Ruby reads from left to right, so it'll return the first string to match from the left. There are some examples of this where you can check for all matches, so I noted those.
''[/text you want to match/] -- checks a string for matching content.
if what you are searching for isn't there, match comes up nil
''[/text you want to match?/] -- the question mark means the last character is optional. so [/oranged?/] checks for orange and oranged, but oranged is optional.
''[/text you want to match+/] -- the plus checks that last character to see if there are more, and will return all of the extra ones.
''[/text you want to match*/] -- asterisk is similar. it's like a combo meal of ? and +, so it returns all of them if that character exists in the string.
array.select { |a| a[/[characters you are checking as options]rest of string/] }
phew that was a long one. this replaces the first character with whatever is in the array. for example, [a/[bcfj]ar/] checks for bar, car, far, and jar.
''[/\d+/] returns all the digits as strings. similarly I could use [/[0-9]+/] as a range.
''[/\s+/] is for whitespace. It claims it's a shortcut, but I don't get that part yet. This is one I need to play around with a bit more.
''[/\w+/] is for words, which is anything A-z and 0-9.
''[/.+/] is for return carriages.
''[/^[characters negated]/] the ^ checks for everything but what's in the match string. Likewise, you can use capitals D, S, and W to negate any of the above checkers.
And for quickies...
[/\Atext/] /A anchors to the beginning, while \z anchors to the end (put \z at the end too!). Likewise, carat (^) and dollar sign ($) anchor to start and end of lines. \b anchors to a word boundary... another one I'd like to test a bit more.
.scan can be used to find all of the matches, and returns them in an array. Useful for finding all the words or numbers in a string.
.sub is used to replace the first, while .gsub is used to replace any time the string is matched.
Okay. That was a lot to take in. I'd like to start looking at more examples of Regexp and how it can be used in context, but in the meantime, back to Koans.
Note: Ruby reads from left to right, so it'll return the first string to match from the left. There are some examples of this where you can check for all matches, so I noted those.
'
if what you are searching for isn't there, match comes up nil
'
'
'
array.select { |a| a[/[characters you are checking as options]rest of string/] }
phew that was a long one. this replaces the first character with whatever is in the array. for example, [a/[bcfj]ar/] checks for bar, car, far, and jar.
'
'
'
'
'
And for quickies...
[/\Atext/] /A anchors to the beginning, while \z anchors to the end (put \z at the end too!). Likewise, carat (^) and dollar sign ($) anchor to start and end of lines. \b anchors to a word boundary... another one I'd like to test a bit more.
.scan can be used to find all of the matches, and returns them in an array. Useful for finding all the words or numbers in a string.
.sub is used to replace the first, while .gsub is used to replace any time the string is matched.
Okay. That was a lot to take in. I'd like to start looking at more examples of Regexp and how it can be used in context, but in the meantime, back to Koans.
More koans, and bedtime. Maybe.
With my domain registered, might as well put it good use. Here's to an exciting year at heypodo.com (which, for the record, doesn't have an index page yet).
About 1/3 through Koans now. Pine never covered symbols, so this last section was mostly new to me. I never understood the purpose of symbols before because they felt a lot like strings to me, but they clearly are not strings. Aye.
About 1/3 through Koans now. Pine never covered symbols, so this last section was mostly new to me. I never understood the purpose of symbols before because they felt a lot like strings to me, but they clearly are not strings. Aye.
Testing, writing, moving update
I'm approaching my last week here in Napa, and the apartment is progressively getting more empty each day as things get sold and so on. Having less distractions is kind of nice, actually. My last few days have been the most productive since the last work day I had, so going back to living with absolutely nothing but a computer and a bed will be a welcoming change.
Today was filled with a lot of reading. That wasn't its original intention, because I don't like staring at the computer screen unless it's work related, but it was in all good purpose. I did learn a lot about context-driven testing, which appears to be the most common testing concept for software. I think the most informative part of it all was that I do a lot of this stuff already. I remember particularly when I had to make a last minute design call on the drill for Vintage's drumline show 'Rhapsody,' and even though I don't like making last minute changes, it was definitely for the better.
One drill move that Lisa designed clearly wasn't working, and the kids were getting frustrated. Why wasn't it working? Partly because some of the kids were moving too far, too early, and one wasn't moving consistently. I ended up breaking down the move into two subsets, because mathematically, it made sense. We were flipping three diagonals from one side of the gym to make one long one on the other, so I had them split the diagonal to make three short straight lines, and the end result was awesome.
Of course, software testing is a bit different, but I love the idea of critical thinking and just figuring things out. I started Koans about 30 minutes ago, and I'm about 5% into it. Going slower than expected, but it's been a long day. Unfortunately, no work on Rails or HTML today as planned, but I do hope to get out the design notebook and work on some website ideas for Connecticut's Best Disc Jockeys. All in due time.
There was an interesting comment on Hacker News about how Blogger hasn't changed over the last four years, compared to other blogging forms such as wordpress. I strangely have to agree, since I used it for my teaching one about that much time ago, but it's friendly territory. It will be nice to complete my own blogging app, since it'll truly be something I can call 'my own.'
Night everyone.
Today was filled with a lot of reading. That wasn't its original intention, because I don't like staring at the computer screen unless it's work related, but it was in all good purpose. I did learn a lot about context-driven testing, which appears to be the most common testing concept for software. I think the most informative part of it all was that I do a lot of this stuff already. I remember particularly when I had to make a last minute design call on the drill for Vintage's drumline show 'Rhapsody,' and even though I don't like making last minute changes, it was definitely for the better.
One drill move that Lisa designed clearly wasn't working, and the kids were getting frustrated. Why wasn't it working? Partly because some of the kids were moving too far, too early, and one wasn't moving consistently. I ended up breaking down the move into two subsets, because mathematically, it made sense. We were flipping three diagonals from one side of the gym to make one long one on the other, so I had them split the diagonal to make three short straight lines, and the end result was awesome.
Of course, software testing is a bit different, but I love the idea of critical thinking and just figuring things out. I started Koans about 30 minutes ago, and I'm about 5% into it. Going slower than expected, but it's been a long day. Unfortunately, no work on Rails or HTML today as planned, but I do hope to get out the design notebook and work on some website ideas for Connecticut's Best Disc Jockeys. All in due time.
There was an interesting comment on Hacker News about how Blogger hasn't changed over the last four years, compared to other blogging forms such as wordpress. I strangely have to agree, since I used it for my teaching one about that much time ago, but it's friendly territory. It will be nice to complete my own blogging app, since it'll truly be something I can call 'my own.'
Night everyone.
Sunday, June 26, 2011
Finished a rails app
It took me all day--including several breaks to do some job hunting, updating websites, and buying two domain names--but I finished the whole Ruby on Rails introduction guide, and I understand for the most part what's going on. It seems like Rails is best for multi-user support, which is the main reason why I think startups are so "on it" now, especially the ones that revolve around social networking.
The mvc infrastructure is actually quite a piece of art. Rails is so well integrated within itself that it really isn't that difficult to create and move things around, particularly when you get to writing the different views and methods. Of course, writing views takes some html/js/css knowledge... so I'll get to that. Posted the outcome on github (or should be up shortly after this update).
Gameplan now? Get back to rubying. I fixed up secret santa a bit more so there are 4 less variables and all the data is stored within one array instead of the 4 or 5 I had before. Next step is to implement STDIN to save a group of information into the array, and then it should be at its final stage of development.
Then, it's onto the next ruby quiz I want to check out.
So... new week, new goals. HTML and CSS reviewfest, and if all goes according to plan, get that website cranked out!
The mvc infrastructure is actually quite a piece of art. Rails is so well integrated within itself that it really isn't that difficult to create and move things around, particularly when you get to writing the different views and methods. Of course, writing views takes some html/js/css knowledge... so I'll get to that. Posted the outcome on github (or should be up shortly after this update).
Gameplan now? Get back to rubying. I fixed up secret santa a bit more so there are 4 less variables and all the data is stored within one array instead of the 4 or 5 I had before. Next step is to implement STDIN to save a group of information into the array, and then it should be at its final stage of development.
Then, it's onto the next ruby quiz I want to check out.
So... new week, new goals. HTML and CSS reviewfest, and if all goes according to plan, get that website cranked out!
Saturday, June 25, 2011
Exceptions! And all that other nonsense.
I puttered through Eloquent JS chapters 4 and 5 after falling asleep last night about half way through chapter 4. Can I blame myself? The majority of the chapter was about cats. I get enough cats on reddit.
Today's valuable lesson, however, was in error management, something I completely suck at (some might say epicfail). I learned about catch and throw, which is useful when certain qualifiers come up, say... an error you expect, and you need the program to zoom through to another block of code, ignoring all previous code.
After reading about that, I said, hey! This is how I'm going to fix my secret santa program! As it turned out, it didn't work the way I wanted it to in Ruby, so I will have to practice catch/throw a bit more to make sure I get it. I tried 'raise' as well, but all that does is shoot out the error that I was already expecting. I imagine raise being more useful when you expect your code to produce an error later if certain parameters are not correct.
So after much strolling around the internet, I ran into my true solution (for now) on tutorialspoint.com, where I learned about something Chris Pine just glanced over when explaining loops. Apparently I can use 'retry' statements to start loops over if something goes wrong--in this case, if the person is left with himself to pick.
I'm going to try mu is too short's solution as well (listed here), because it just dawned on me how simple it would be in comparison.
Tomorrow is Engagement/Peace Love and Firefox at Dolores Park, so I think I'm gonna try and get down there for ice cream and swag.
EDIT: And before I forget, my Secret Santa code is on github here: https://github.com/podopie/startingruby/blob/master/secretsanta.rb Also celebrating +100 hits on the blog, which is awesome since I've only had it for two weeks! Here's hoping to getting at least 1000 hits before the summer ends.
Today's valuable lesson, however, was in error management, something I completely suck at (some might say epicfail). I learned about catch and throw, which is useful when certain qualifiers come up, say... an error you expect, and you need the program to zoom through to another block of code, ignoring all previous code.
After reading about that, I said, hey! This is how I'm going to fix my secret santa program! As it turned out, it didn't work the way I wanted it to in Ruby, so I will have to practice catch/throw a bit more to make sure I get it. I tried 'raise' as well, but all that does is shoot out the error that I was already expecting. I imagine raise being more useful when you expect your code to produce an error later if certain parameters are not correct.
So after much strolling around the internet, I ran into my true solution (for now) on tutorialspoint.com, where I learned about something Chris Pine just glanced over when explaining loops. Apparently I can use 'retry' statements to start loops over if something goes wrong--in this case, if the person is left with himself to pick.
I'm going to try mu is too short's solution as well (listed here), because it just dawned on me how simple it would be in comparison.
Tomorrow is Engagement/Peace Love and Firefox at Dolores Park, so I think I'm gonna try and get down there for ice cream and swag.
EDIT: And before I forget, my Secret Santa code is on github here: https://github.com/podopie/startingruby/blob/master/secretsanta.rb Also celebrating +100 hits on the blog, which is awesome since I've only had it for two weeks! Here's hoping to getting at least 1000 hits before the summer ends.
Thursday, June 23, 2011
Method Magic!
After some playing around, I finally got the code to work. Here's the example from Eloquent JavaScript (finding out the *3 +5 equation to a number) written in Ruby.
The real interesting difference was in Ruby, I needed to call the 'goal' variable in both methods. I don't think I could have used an instance variable here, just given the way the code is written. Another simplicity with Ruby is that I don't need the return statement in order to call the variables. Other than that, it's fairly similar.
I also noticed that it was better to put the ' + 5' method before the ' * 3' method, only because the return tended to be shorter. The return the other way around for 24 would be (((((1 * 3) * 3) + 5) + 5) + 5), what a mess! It never gets the chance to say that 3 * 5 is the same as 5 + 5 + 5. How unfortunate.
I imagine it could also be completed using procs? Maybe I'll try that out tonight.
Probably will get one more Eloquent JavaScript chapter done tonight, and I'd like to recode the Secret Santa program if I'm still awake after that. Someone is coming by to purchase my television in the morning, so consider that an opportunity for productivity to increase.
Gordon shared this link with me today: Local variable's memory can be accessed outside its scope?! Also will get to this for reading tonight.
Aye I feel stupid after taking a day off. I'll go climb tomorrow for a bit in the morning, but tomorrow will be a serious reading/hacking day.
The real interesting difference was in Ruby, I needed to call the 'goal' variable in both methods. I don't think I could have used an instance variable here, just given the way the code is written. Another simplicity with Ruby is that I don't need the return statement in order to call the variables. Other than that, it's fairly similar.
I also noticed that it was better to put the ' + 5' method before the ' * 3' method, only because the return tended to be shorter. The return the other way around for 24 would be (((((1 * 3) * 3) + 5) + 5) + 5), what a mess! It never gets the chance to say that 3 * 5 is the same as 5 + 5 + 5. How unfortunate.
I imagine it could also be completed using procs? Maybe I'll try that out tonight.
Probably will get one more Eloquent JavaScript chapter done tonight, and I'd like to recode the Secret Santa program if I'm still awake after that. Someone is coming by to purchase my television in the morning, so consider that an opportunity for productivity to increase.
Gordon shared this link with me today: Local variable's memory can be accessed outside its scope?! Also will get to this for reading tonight.
Aye I feel stupid after taking a day off. I'll go climb tomorrow for a bit in the morning, but tomorrow will be a serious reading/hacking day.
Moving on with Eloquent JavaScript
After cruising through Metal Gear Solid last night (such a great critical thinking game!), I read through chapter 3 of Eloquent JavaScript. I'm avoiding my original idea of skipping ahead after reading this chapter; there was some great content that helped explain a lot of the fundamental ideas in Ruby that I already was slightly aware of, but actually took the time to explain them in detail. These would be scope, stacking, and branching, the last of which was brand new to me.
Till then! Time to make dinner, and then back to go from learning to using.
Scope
Scope, to my understanding, is all the different levels of the program. I think the best personal example I can think of is a book. Books consist of the "book," or top-level, chapters, or different methods, and the literature (or just words). Variables can take place on various levels of your scope, so it's important to consider when writing a program the organization and scope of your variables. When I last posted on stackoverflow, I got asked why I used global variables ($), especially because Ruby makes it almost unnecessary. This would be... me not thinking about my scope.Stacking
I posted my first question at stackoverflow on a stack error. Stacking essentially is Inception, or how many levels deep you go. Fortunately (or unfortunately, depending on how you look at it), computers only allow so many stacks, probably in the tens of thousands. I know you can increase it manually, but most of the time it's not necessary. Anyway, if you're using recursion, and the stacking NEVER STOPS, you'll eventually run into a stack error. They look a little different between Ruby:SystemStackError: stack level too deep
and JavaScript: RangeError: Maximum call stack size exceeded
but mean the same thing. Bright side of things: I can create a stackerror on command. The world is mine... recursively.Branching
If you can figure out stacking pretty well, branching is the idea of working with a flow chart. Eloquent JavaScript adds to this mix or even more lucrative branching, letting more than branch work at the same time using ||, the computer equivalent of "or." I'll post an example of this later tonight in Ruby, borrowing the original example from Eloquent JavaScript just to practice my Ruby skills... or rather translation skills.Till then! Time to make dinner, and then back to go from learning to using.
Subscribe to:
Posts (Atom)