Tuesday, August 21, 2012

ruby koans - begin!

I'm coming down with something. I'm bummed because I would like my brain to be at its peak operating power for studying - and also because I feel obligated to not go anywhere to prevent infecting others, and that's boring.

I started up Ruby Koans just a few minutes ago (I'm going to wrestle my foggy head into submission, or at least fail spectacularly) and after the first challenge, my terminal returned back to me this quote:

learn the rules so you know how to break them properly

That's a nice quote. Ruby, you're kind of like that boyfriend who is too good to be true and you probably have some secret baggage that's going to destroy everything we've built so far but I don't know it yet, but right now I really like you and I want you to meet my parents.

Friday, August 17, 2012

libraries

My new study partner, Nathan, and I figured out what libraries are all about earlier today. We didn't know what this line of code that said require 'date' was all about, so we commented it out, and then had an "ah-ha!" moment. It's a library! It's something fun built in to Ruby that you can just pull out when you need it. Just like Sinatra is also a library?

Unfortunately, then we both learned that neither of us was accepted to the internship. Ultimately, I'm kind of okay with that. I'm just barely scratching the surface of what Ruby can do, and I'm sure in a few months I'll look back and laugh at my pathetic attempts. I taught myself how to knit almost five years ago, and it was a long process, and I am still learning things to this day. So I'll just stick with it and some day I'll be as good a programmer as I am a knitter. Because I'm pretty good at knitting. 

Also, it helps a ton to have a person to bounce ideas off of! Even though I didn't produce anything during our several-hour study session, I feel like I reinforced some concepts, and "ah-ha!" moments are worth like 1,000 points.

Friday, August 10, 2012

jenna gains a level!

If I haven't outed myself as a total video game nerd, I'll do so right here. The last few weeks studying Ruby almost non-stop, I've felt guilty about doing anything else. My stress levels were also probably higher than they should have been, if my dreams about getting speeding tickets and moving back into an old, moldy apartment were any indication. I'd take little breaks but always, in the back of mind, was this little ruby nagging at me that I wasn't done.

So today was kind of nuts, then. I slept poorly, woke up feeling a little crazed, but I got right into it and by early afternoon I'd completed my first ever web app (can you tell I'm excited about it?). And it was like how I imagine you feel when you level up. Jenna gains +1 intelligence! Jenna gains +2 vitality! Jenna learns a new ability: guilt-free resting! I'm a pretty instinctual person, so I rolled with it. I submitted my internship application (while it might seem like it, I was not doing all this purely for fun), feeling like I'd accomplished everything I set out to do. I may be wrong. But it felt right!

Then I caught up on a knitting project, watched that episode of True Blood I missed (this is serious stuff), and now it's almost two hours until my modified bedtime and I'm not even tired and kind of bored. I'll get back to the coding once my brain muscles have a chance to rest, but I'm still riding the wave of tiny victory.

Thursday, August 9, 2012

my first ever web app - in 10 minutes!

With the guidance of AppFog's Alex (who, as you should know, is the best climber at the rock gym), I created my first web app with about zero skill or frustration. It's free to sign up with 2GB of memory. Getting started stumped me because I didn't realize the secret was the "Download Source Code" button.


So clicking that downloads all these files to your desktop, including one called app.rb (since I'm doing this in Sinatra, which I don't even know how to use!), which you can seriously just paste code into. I used a super-simple array full of things I usually say. Ideally, I'd like to modify it so that users can input some text and talk back to me. This will be handy in case people ever miss my witticisms while I'm sleeping.

So, stop whatever you're doing and talk to me. And then, when you're done with that, make your own elementary apps. Or good apps, whatever.

Wednesday, August 8, 2012

the things i've been doing

I started off on my first day of Ruby learnin' with TryRuby.org.
Then I spent the better part of a whole evening setting up my Ruby and Rails environment as instructed by Railscast #310.
After that, I had a pleasant breather with Why's (poignant) Guide to Ruby.
Then I really put the nose to the grindstone with (so far!) my favorite tutorial, Ruby in 100 Minutes from JumpStartLab.
Looked at Rails for Zombies, got confused, ran away.
Found Michael Hartl's Ruby on Rails Tutorial, got overwhelmed...ran away.
So I started playing RubyWarrior, got to level 4, got stuck. Read a ton of documentation, asked some friends, stayed stuck.
Started a simple unit converter project, (have I mentioned I got stuck?) got stuck, finally figured it out, wanted to add some text prompts, got stuck again.
Came back to Rails for Zombies, started getting the hang of it (!!), felt I needed more basics, went back to Ruby.
Currently plowing through Learn Ruby the Hard Way, where I'm learning lots!

Short-term goals:
Work on that unit converter so it asks you politely (or not) what units you'd like to convert from/to, and outputs the result in a polite (or not!) manner.
Make a GitHub repo.
Write a text-based adventure! Because everyone loves those!
Write a web app that takes all of my common words and phrases and randomizes them into strings of speech so that I basically never have to speak again. My reactions and responses to things are pretty generic, anyway, and usually involve something about "butts," "whales," or "bacon."

Tuesday, August 7, 2012

this is getting serious

I woke up this morning to shut my blinds and my sleep-addled brain was trying to define a method for my actions.

def close_blinds
    puts "go back to sleep, jenna, you have no idea what you're doing"
end

Monday, August 6, 2012

little things!

It took me a while and a lot of help from Alex and Ryan, but I actually wrote a from-scratch program. It's not impressive but I'm really excited. Next, I need to write a separate method for printing the text results.



Sunday, August 5, 2012

an ongoing quick reference list of things i've learned

Methods are like verbs. It's like you're telling the code to do an action on something.

You use def method to define a method. Obviously.

to_s converts to a string.

to_i converts to an integer.

to_a converts to an array.

Hashes are ways of storing variables (like an array, but not in any specific order) and they use curlies: {}

class names must be capitalized. Learned that the hard way!

Variables with an @ are global variables (used throughout the entire program); otherwise, they are local variables (exclusive to the method).

Parameters are the things inside parentheses when you define a method: def like_this_here(parameter)

arg is a great abbreviation of the word "argument," which can be a placeholder for parameters. It also happens to sound like a pirate. def ahoy_mateys(arg)

A colon in front of a word makes it a symbol, which uses less memory than a string.

To insert an apostrophe, you can type \'. Like, "The bacon\'s burning!" And \n inserts a line break. These are called escape sequences. I guess because sometimes, you just need to get out?

<<NAME . . .  NAME allows you to type a multi-line paragraph. NAME can be anything!

Everything in Ruby is an object. Everything. (How many times have I heard this? Maybe repetition is the key.)

Good resources:
Ruby in 100 Minutes
String methods
Learn Ruby the Hard Way

everything works in my dreams

I solved my current Ruby project in my dreams last night. Unfortunately, all I get when I look at it now is this vague feeling of deja vu, but no solutions or inspiration. I wish I could have taken notes.

Edit: how embarrassing that I mixed up class and def! Since this is a learning blog, I'll leave it up so I can look back on it and laugh. Or cry. Or cringe.


Friday, August 3, 2012

programming magic

I've been feeling a lot like Harry Potter lately while writing code. I think it's as close to magic as we're going to get. You have this vessel (that's the computer!) that can do just about anything you tell it to, as long as you communicate with it properly. It reminds me of Hermione's lesson about the pronunciation of "wingardium leviosa." You say it wrong, you get an error. But if you say it right, and you concentrate real hard, you have an elegantly levitating feather and all your other classmates look at you, awestruck, and there's a little trill of orchestrated music in the background. That's how I wish my programming went, at least. Also, there's no dementors in my programming fantasy world.

Wednesday, August 1, 2012

this is my kind of humor.

"I think God once said that it's not good for data to be alone, and Ruby provides a few ways to facilitate this."


I'm a fan of this trend of mis-prescribing quotes to historical (or in this case, biblical) figures. It's so nice of God to be looking out for the data.