Day 30

Tonight I was able to get much deeper into the ORM section. The curriculum returned to the lesson then lab format that is more familiar. Learn how to build a few methods and why you build them that way. Then immediately do it locally. Then the next lesson builds on the last. This is much easier to make progress through and I feel much better about databases now. Well, I feel much better about how they integrate and how Ruby wraps them. I’m on a lab entitled “Bringing It All Together” and it looks like there is a small section on Dynamic ORMs before I move into learning about ActiveRecord.

A spot where I got stuck for a bit was instantiating a new object using a Hash. This is something I had not done before and was not easily found via DuckDuckGo (yes my default search engine is not Google). So I ended up throwing some code I found into my file and it passed the test! Here it is:

def initialize(h)
  h.each {|k,v| public_send("#{k}=",v)}
end

I still had to make sure I had my attr_accessor‘s in place to pass my tests but that’s a pretty nifty piece of code I’ll be sure to save for later.

The same music library examples are being used and I’m having flashbacks to my Music Library CLI project that I completed with Mike. I can only imagine building that again utilizing a database. Hopefully, by the end of this DB section, I won’t feel as intimidated by such a task.

On a non-coding note. My youngest daughter hasn’t been getting up in the middle of the night to eat so now I’m being tasked with her first meal of the day because mommy is almost out the door at that time for work and doesn’t have time. This means I’m getting up at 6am pretty regularly right now. It’ll be nice if she starts sleeping until 7 or 8. If she keeps this up though I’m going to go back to a split coding day with some time in the morning and night.

Time spent today: 2:41
Time spent total: 130:22
Lessons completed today: 8
Lessons completed total: 318

Day 29

Polished off the SQL tonight and I have to say it was more in depth than I thought it would be. It’s one of those things that is hard to visualize being new to it. When the tables are laid out in a grid it all makes sense but just trying to do it all in your head is confusing, even for me. I’m sure if I was doing it every day it would be much more intuitive but right now I’m still a little fuzzy on keeping track of the data I’m looking for through multiple JOINS.

I started on ORM (Object Relational Mapping) tonight but only got through the first lesson and lab before calling it. I’m seeing how it all connects through to store data persistently. The main thing being this:

An ORM is really just a concept. It is a design pattern, a conventional way for us to organize our programs when we want those programs to connect to a database. The convention is this:

When “mapping” our program to a database, we equate classes with database tables and instances of those classes with table rows.

This overview really makes it simple to think about the objects I’ve been working with and how they’ll be stored and retrieved.

I’ve realized my 7 lessons/labs per day is pretty ambitious. Especially on these days when I work for ~3 hours. I think I can make up the rest on my LONG weekend coding sessions if I actually get 10+ hours in on Saturday and Sunday. We’ll see.

Time spent today: 3:20
Time spent total: 127:41
Lessons completed today: 3
Lessons completed total: 310

Day 28

Today started with multiple review videos on the CLI Gem Project. I also was able to schedule my project review for Wednesday night. I’m looking forward to some one-on-one time with an instructor talking through my code. The project states:

BE PREPARED TO:
1. Explain your code from execution point to exit point. We’re making sure you wrote it and understand how it works, nothing else. 10-20 minutes
2. Refactor code. 10-20 minutes

If necessary, after the assessment, be prepared to:
1. Extend the application with a new feature, more data, a different domain etc. 20-30 minutes
2. Submit an improved version.

However, until then I’m pushing on.

Today I got through most of the SQL (Structured Query Language) section of the curriculum, 89% to be exact and I’m committed to finishing it up tomorrow. In this section I’m learning:
– How to create SQLite3 databases.
– How to create, update, select, and delete data from database tables.
– How to relate data within a given database.
– How to write SQL code in both my command line and my text editor and execute the code against a database.
– How to write Ruby programs that talk to and save data to my databases.

I have to say it’s more interesting that I thought it would be. In addition, I can see perfectly how databases fit into the whole web app ecosystem. It’s also fairly easy to pick up the SQL DSL (domain specific language) because it’s pretty much just procedural coding. I also have done a couple intro SQL Server courses in the Microsoft Virtual Academy so the vocabulary wasn’t new to me and I understand the 30,000 ft view of databases and relational databases.

I feel good about progress again after today. I had felt stalled (I know I was making progress though just couldn’t see it as much in the “numbers”) for a bit. Coming after SQL is Object Relational Mapping (ORM) and ActiveRecord, then Rack, then Sinatra where I’ll build my next portfolio project. After that comes Rails and when I’m done with Rails the job hunt can commence, although, I’ll still have more learning to do to graduate. After Rails is a bunch of Javascript, Rails and Javacript, React and finally Redux. It’s a lot but I know will move by at a good pace. My ambitious goal is to be done with or working on the Sinatra projects by 4/9/17. Two weeks to complete 40 lessons and 55 labs… that’s 7 per day. I think I like that. Instead of setting an amount of time to get things done completing a set amount of the curriculum. As long as I pull out projects which take much more time I think this could be doable in the long run. I wonder what my pace has been so far… 10.96/day is the pace I’m sitting at. Hmmm… maybe I’ll stick with the time format as I seem to be getting more done that way. Either way, I’m going to benchmark and see if I’m at 48 more lessons complete by next week and on pace. This is good.

Time spent today: 6:00
Time spent total: 124:21
Lessons completed today: 17
Lessons completed total: 307

Day 27

So I went later than I wanted to tonight, but I was on a roll. I would have finished much earlier but I spent 2.5 hours today at a developer meetup. It was interesting as I’ve only been to one other so far. It was good to meet some people and start putting real people to the dev community in Nashville. I did find out that basically nobody is learning/using Ruby (at least at this meetup). The largest language according to the people today is .NET because of all the healthcare companies. I showed a lab to a guy who’s 4 months in at Nashville Software School and he was impressed with the TDD and seeing how it worked. He said he never sees tests like that and doesn’t know anything about writing them. I assured him I didn’t know much about writing tests either but I did read them all day long.

The big announcement is … I FINISHED MY CLI GEM PROJECT! Now, I haven’t done my review with my instructor and passed yet but it’s done. I’m currently working through my Travis CI tests and getting those to pass. I expect that to be passing soon and then I’ll update my gem. It’s already live on RubyGems.org! I’ll have a new version pushed up when I get my Travis passing.

So I had a few hang-ups along the way but most of it had to do with scraping. I figured it out though by trial and error. From what I understand scraping is mostly trial and error so there isn’t much to pass along knowledge wise. I did run into the problem of trying to turn this: "7\n" + "\n" + "\n" + "Paddlers\n" + "\n" + "going" into this: "7 Paddlers going". When I did gsub("\n", "") it returned 7Paddlersgoing and gsub("\n", " ") returned "7 Paddlers going" with too many spaces. I was thinking I was going to have to split the string into an array, filter out the \n and then join the array. Then I thought, “Why not Google turning multiple spaces into a single space.” That seems like a problem someone would have solved already. Guess what? They have. So I ended up with row.css("div.attendee-count").text.strip.gsub("\n", " ").gsub(/\s+/, ' '). Called gsub on a string that had already been changed.

I just realized that Travis is never going to pass because I don’t have any tests in my gem. Whoops! So I’ll remove that integration for now. It’ll be a nice future project to write tests for the gem.

To explain my project, in brief, you run the program from the command line, it asks you to input a zip code to see meetups from, if you enter less or more than 5 digits or not 5 digits, say 5 letter, it tells you to input 5 numbers. Then it asks for a radius to search in, I limited the radius to <100 miles. Then it returns a list of all the meetups scheduled for today. If there are none it tells you such. It then asks you if you’d like to search again. I’m proud as well as ready to move on to SQL.

Time spent today: 7:24
Time spent total: 118:21
Lessons completed today: 1
Lessons completed total: 286

Day 26

Tonight I made some good progress on my CLI project. I finished watching Avi’s video on the project and it helped A LOT. It was long so I decided to just complete the basic stub of my project and leave it at that for tonight. I really like working with fake placeholder data for as long as possible. This way it’ll all hopefully just work when real data is passed in. So taking the stub I’m sharing below and abstracting that out to have objects holding the data for each meetup. Then building the methods to create those objects in another class.

What I have so far:

class MeetupsAround::CLI
  attr_reader :todays_date

  def call
    @todays_date = "Saturday, March 25"
    input_zipcode
    input_radius
    list_meetups
    again?
  end

  def input_zipcode
    puts "What zip code would you like to see meetups for?"
    zip_code = gets.strip
    if /\b\d{5}\b/.match?(zip_code)
      nil
    else
      puts "Please enter a five digit zip code."
      self.input_zipcode
    end
  end

  def input_radius
    puts "What radius around that zip code would you like to see meetups for?"
    radius = gets.strip
    if /\b\d{1,2}\b/.match?(radius)
      nil
    else
      puts "Please enter a radius less than 100."
      self.input_radius
    end
  end

  def list_meetups
    puts "Today #{todays_date} are the following meetups:"
    puts <<~HEREDOC
    1. 2:30PM - Developer Launchpad Nashville - Coding Jam - 19 Developers going
    2. 9:00AM - Score Nashville Events, Networking and Workshops - Join us for a "Start your Business" workshop! - 2 Members going
    3. 10:00AM - Paid to Speak Entrepreneurs - How To Get Your Speaking Career Started - 18 Members Going
    HEREDOC
  end

  def again?
    puts "Would you like to search again? [Y/N]"
    input = gets.strip.downcase
    puts input == "y" || input == "yes" ? call : "Goodbye =)"
  end

end

Next up I’ll change the HEREDOC block and utilize an object iteration to list each object. Something like:

meetups.each.with_index(1) do |meetup, i|
  puts "#{i}. #{meetup.time} - #{meetup.group} - #{meetup.event} - #{meetup.attendees}"
end  

Now I don’t know if this is exactly what I’ll end up with but it’s what I’m thinking at this point in time. I’ll also need to have an array with the meetup objects called meetups in this scenario. For this project I’m suppose to record myself coding for 30 minutes so I think when I go to tackle this I’ll do that recording. I’ll watch the video Avi made another time and get a solid plan of action down and then go for it. Pretty sure they don’t want a video of me watching videos hehe.

Tonight I also installed a couple more packages into Atom. Specifically minimap, seti-icons, atom-beautify, highlight-selected, pigments, minimap-highlight-selected, and minimap-pigments. I highly recommend them all so check them out.

Time spent today: 2:22
Time spent total: 110:57
Lessons completed today: 0
Lessons completed total: 285

Day 25

So tonight I started my CLI Gem project. This one is going to be in my portfolio and has A LOT more to it. Okay, well maybe not a lot more but it’s the first time I’m starting from scratch to build something. Luckily, I’m not left out to dry and there is a how-to that’s over an hour long that Avi did. Of course, it’s not exactly what I’ll need to do and I’ll run into problems along the way but it’s nice to have a good resource to start with. I’m sure I could find a nice video around but having one provided definitely saves some time.

I decided to build a CLI Gem that will return the meetups in a specified radius from a specific zip code for the current day from Meetup.com. The first big time saver was bundle gem new_gem_name which basically scaffolded a new gem with the name provided and even initialized it as a git repo. Avi provided a great set of steps to build a Gem:
1. Plan your gem, imagine your interface.
2. Start with the project structure – google.
3. Start with the entry point – the file run.
4. Force that to build the CLI interface.
5. Stub out the interface.
6. Start making things real.
7. Discover objects.
8. Program.

I’ve completed 1-4 in a very basic way now. Next is to stub out my interface with fake data. That will allow me to ensure my flow is working correctly and then basically code to the exact info I need. This workflow is also allowing me to make progress quickly and see the iterations that I’m going through to get to the end result. Not much else to share as I didn’t do anything too “deep” today. Just getting started on this project. If you’re interested in building your own gem using bundler check out RailsCasts #245 New Gem With Bundler. If you want the walkthrough that Avi does you’ll have to join Flatiron. I’m hopefully going to be able to finish this project on Saturday. However, I have a meetup to attend and I have my son this weekend. This will be the first weekend I have my son since I’ve started the program. I only have my son one weekend a month so I’ll have to see how much time I truly can sacrifice when the kids are awake.

You can follow along with my progress on GitHub here.

Time spent today: 2:29
Time spent total: 108:35
Lessons completed today: 0
Lessons completed total: 285

Day 24

yawn it’s been a long day. My 3-month-old was up early today. Either way, I got my scraping project done tonight. Nokogiri can be quite particular about the things you use to select content. Turned out I was pretty much there and just needed to change how I was accessing the info I needed.

Attended a Study Group tonight which taught me something very important. When using pry inside a loop when you enter exit into the pry prompt it runs the next loop. This way you can see what is being passed in each time. I was struggling trying to see what was being passed in each time in my scraping project. So now I know and that key piece of info is what helped me finish my scraping project which can be found in full here.

I’m calling it a night. I start my first portfolio project tomorrow building a CLI Ruby Gem.

Time spent today: 2:35
Time spent total: 106:07
Lessons completed today: 1
Lessons completed total: 285