Let’s Keep It Safe With Authentication

It was a strong day and I moved into Authentication. Authentication is going to be a beast I can tell. However, it looks like because it’s such an important topic there are a lot of best practices and good documentation out there. I still haven’t wrapped my head around the Sessions Controller 100% but knowing that it was almost identical in 3 separate labs tells me it’s a relatively static and consistent concept for what I’ll be doing.

Sundays seem to be quiet across there were probably <10 messages across all the channels I’m a part of on the NashDev Slack and only a few people chatting in the Learn (I use Learn and Flatiron interchangeably) Slack. I wrote my code for most of the day using RubyMine. It feels slow compared to Atom but I know that’s because it’s ridiculously powerful. It’s like using Notepad versus Word. I think I’ll be able to appreciate it more when I build out my Rails projects. Things, where there are more freedom and chance to mess up, might show off the power of the IDE better. When I’m literally inside a test suite box the IDE doesn’t have much to offer that text editors don’t have. Please correct me if I’m wrong.

I’m searching for things to write about sometimes (it seems obvious to me), however, I’m not going to stop writing.

I’m ready to start tackling the first Rails project. I’ve seen a few people looking to pair and the instructor stating that people who were well into Authentication could jump in on the first project. I’ll be looking for someone to take on that task with and hopefully be on my Rails portfolio project before next weekend. If I can start it before Saturday I think there’s a strong probability it’ll be done before the 22nd as that’ll give me 2 weekends of full days bookending a week of shorter days.

I’m working on some other projects now outside of Flatiron. Trying to get the bones around a continuous group project that we can work on for freeCodeCamp Nashville. I think it’ll be good. Trying not to get too distracted but it’s a nice thing to mix in. Example, learning how to deploy Ghost to a DigitalOcean droplet, which actually wasn’t hard. Even better, upgrading that install via command line. I really want to deploy Discourse but I can’t think of anything I’m involved with that it would be useful for right now. O well, in time.

Time spent today: 7:55
Time spent total: 267:06
Lessons completed today: 13
Lessons completed total: 502

Rails is Moving Along

Not as much time spent on my curriculum as a typical Saturday but that’s alright. It’s because of the freeCodeCamp meetup that I Co-Organize (see the previous post from earlier today). I still feel accomplished. I’m at a point in the Rails section where I have 4 videos then I’m on the last section before the projects. Tomorrow will be telling as to if I’ll hit my goal of starting my Rails projects on the 10th or not. My wife has been asking if I’ll be done with Rails by the end of the month and I hope it to be before that. I guess it depends on how complex an app I decide to build. After I submit my Rails project I’ll spend a day refactoring my Sinatra project. The UX is still weak and navigation is clunky.

I’m feeling good about things in the program. I’m also now looking forward to cracking open one of my 2009 Silver Oak Napa Valley Cabs when I’m officially done with the program/land a job.

Time spent today: 5:00
Time spent total: 259:11
Lessons completed today: 7
Lessons completed total: 489

freeCodeCamp Nashville May Meetup Recap

man in tie presenting

So today Dave Harned and I hosted the monthly freeCodeCamp Nashville Meetup. There were 8 of us there and it was good to see new and “old” faces. I think we’re starting to build more of a core group that will consistently attend the meetup. With that, we’ve started exploring some other options for larger meetup locations. The library is nice but the wifi is awfully slow and that’s a pretty big downside considering what we’re meeting for.

Dave and I presented on RESTful APIs and general REST info. You can view the slides here and to get a feel for what it was like, the image above is what Dave looked like presenting. So after that, we chatted for a bit about many things.

IDE’s were brought up. Specifically, WebStorm (which you can get for free with a .edu email address), Brackets, and Visual Studio Code were discussed. As were the limitations of CodePen and using Cloud9 instead and some of a Cloud9 setup.

In the discussion of local dev environments, Dave brought up MAMP and how he was dabbling in some WordPress when he was using it.

Other resources that were mentioned were: Eli the Computer Guy and The Coding Train on YouTube. An algorithms course on Coursera was mentioned but not the specific one. We were talking about Stanford though so I think this is the right one.

We also worked through the freeCodeCamp Truncate a string challenge together. I didn’t think to save it at the time but we used Dave’s computer so hopefully, he has the solution locally on his machine still. If so I’ll update with it.

UPDATE here’s the code:

function truncateString(str, num) {
  if (str.length <= num) {
    return str;
  } else if (num <=3) {
    return str.slice(0, num) + "...";
  } else {
    return str.slice(0, num - 3) + "...";
  }
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

We had a good time and there were a few extended conversations after we officially ended which I liked. I’m not a Sr. Dev and can’t mentor people too much, yet. However, I really do enjoy seeing people connect with each other and the community we’re slowly building around the central theme of people new to coding utilizing freeCodeCamp to learn.

Rubocop Saves The Day

I missed writing yesterday. However, I chose to skip the writing while I enjoyed a very productive study group. Not really. We chatted about everything except code mostly because nobody really showed up at the proper time for it. After 3 hours of talking it was late and I decided to not write a blog post.

I also went to a Ruby meetup last night. It was underwhelming this month with only 3 of us in attendance. However, I got to meet a dev here in town and a guy who’s building his own PaaS (I think that’s the right acronym). The biggest takeaway was enabling Rubocop in Atom. I already had the gem installed but hadn’t started utilizing it. We got to this point by me telling how I spent almost 3 hours trying to find where my code was breaking a test to realize it was a f. missing. Charles told me Rubocop would’ve caught that.

No abstraction is better than the wrong abstraction.

- Sandi Metz

Time spent today: 2:48
Time spent total: 254:11
Lessons completed today: 4
Lessons completed total: 482

Render Partial New Mouse, What?

Cut it short tonight. Needed to. Learned some more about rendering partials tonight. Main takeaway code example <%= render partial: 'songs/song_details', collection: @genre.songs, as: :song %> will iterate through @genre.songs and passes those objects to the partial as song.

My wife bought me a trackball mouse 🙂

Prepped some of my possible presentation on REST for Saturday.

That’s all I got.

Time spent today: 1:34
Time spent total: 248:16
Lessons completed today: 4
Lessons completed total: 478

Partials of Collections? They’re Awesome.

Partials are coming together more and I have to say they’re pretty sweet. Rails does some automagical stuff that I can’t completely wrap my head around just yet. However, I probably won’t be able to for a while as the people who created it are WAY smarter than me. However, as an example there’s this sequence of things that Rails does:

<% @posts.each do |post| %>
  <%= render :partial => "post", {:locals => {:post => post}} %>
<% end %>

<!-- OR -->

<%= render :partial => "post", :collection => @posts %>

<!-- OR -->

<%= render @posts %>

<!-- Rendering an empty Collection -->

<%= render(@posts) || "There are no blog posts!" %>

The craziest part to me is this little bit that I was taught about <%= render @posts %> which I have bolded for emphasis:

This approach is a bit more abstract. Under the hood, Rails uses the convention that you will have a partial with the name of the models in the collection. Rails will even render a collection of heterogeneous models ([customer, order, customer]) calling the correct partial for each one.

*Mind Blown*

I also took part in a virtual stand up yesterday morning. The instructor who led it asked me if I felt I was retaining the information with the pace I’ve been going (~5 lessons/labs/lectures per day). At the time I said yes because I felt my short days balanced my long days. However, as I worked through some stuff tonight I think my notes are really helping. Pages like this:

are awesome for me to cement more abstract things as well as provide a quick reference to go back and look at when I need. As I work through the curriculum I’m going to see which notes are truly valuable and get them migrated over to my Code & Quill book for long-term reference.

I <3 the community at Flatiron. Here’s a recent chat thread:

jilustrisimo [08:56]
Has anyone been able to roll out Facebook and/or Google OAuth (via Devise) with > an app they’ve deployed to heroku?

yechielk [08:58]
I’ve done github oath

yechielk [08:58]
Make sure you change the app’s URL with Facebook/Google

jilustrisimo [13 hours ago]
[yechielk]2: hey! Do you have any documentation, I’ve been searching on heroku but its either beyond me or not what I’m looking for…I’m not sure where to even place my app_ids/secrets

yechielk [13 hours ago]
Oh, that…

jilustrisimo [13 hours ago]
sigh…yea

zac-baston [13 hours ago]
https://devcenter.heroku.com/articles/config-vars (edited)

yechielk [13 hours ago]
I used a gem called figaro

yechielk [13 hours ago]
https://github.com/laserlemon/figaro
GitHub
laserlemon/figaro
figaro – Simple Rails app configuration

yechielk [13 hours ago]
It’s for storing env variables but it has great heroku integration built in

zac-baston [13 hours ago]
figaro is a good option. also could check out dotenv gem (https://github.com/bkeepers/dotenv) (edited)

jilustrisimo [13 hours ago]
thanks @zac-baston Ill check it out. @yechielk I could never figure out figaro, I used dotenv

jilustrisimo [13 hours ago]
I get using dotenv but arent those files not supposed to be pushed up anywhere?

smithwebtek [13 hours ago]
Yes 2nd the reminder about URL pointing back to Heroku (production). http://diet-planner-v8.herokuapp.com/users/sign_in

zac-baston [13 hours ago]
you certainly shouldn’t commit them to version control. looking at the documentation in that Readme from the repo, it has a section on production in which it recommends the heroku config methods

jilustrisimo [13 hours ago]
thanks guys, I’ll read the doc and shout again if I break everything

snsavage [13 hours ago]
In your Heroku dashboard go to settings and click on Reveal Config Vars. Those keys and values should reflect your .env file.

jilustrisimo [13 hours ago]
@snsavage thanks, I think thats what the doc @zac-baston linked was pointing me towards…so theoretically just set them there then do whatever I need to do for the callbacks?

snsavage [13 hours ago]
So if you’re using something like dotenv you just need to set the values in the dashboard. Just keep the keys the same as your dotenv file.

jilustrisimo [13 hours ago]
do I need to do anything regarding the redirect on FB and Google?

snsavage [13 hours ago]
For my Rails app I have the Facebook site url set to https://carbtracker.herokuapp.com/.

snsavage [13 hours ago]
And then the callback path is handled by OAuth and route.rb as devise_for :users, controllers: { omniauth_callbacks: ‘users/omniauth_callbacks’ }

jilustrisimo [13 hours ago]
it works! at least for Google. I didnt do FB yet

snsavage [13 hours ago]
Great!

jilustrisimo [13 hours ago]
thanks @snsavage @zac-baston @yechielk @smithwebtek !!

yechielk [13 hours ago]
:thumbsup:

zac-baston [13 hours ago]
pretty cool stuff about the web interface. I didn’t know that was there.

jilustrisimo [12 hours ago]
I think its new

jilustrisimo [12 hours ago]
fairly new

snsavage [12 hours ago]
It’s been there since at least 2015.

snsavage [12 hours ago]
It’s hard to find if you don’t know where to look.

sethalexander [3 minutes ago]
I need to save this entire thread for later…

Well, I guess I now saved the entire thread for later…

Time spent today: 2:17
Time spent total: 246:43
Lessons completed today: 4
Lessons completed total: 474

I Partially Understand Partials

I don’t know why I thought Rails layouts and templates would be somewhat easy. While in a sense it’s taking snippets and putting them in other files to reuse of course there has to be some logic in there to ensure that the proper data is being shown. So rendering partials with locals is starting to make sense.

For my example <%= render partial: "authors/author", locals: {author: @author} %>
– The first key-value pair partial: "authors/author" tells Rails the name of the partial to render. Nothing too complex here.
– In the second key-value pair locals: {author: @author} the nested hash {author: @author} key is the name of the variable and its value is the value you’d like it to have in the partial.

I pretty much understand this except for the nested hash’s key. It’ll click I’m sure. I need to get into the Rails console and play some. I have figured out that to effectively have a partial inside a loop I need the argument I pass to the block (the piece in between the |pipes|) the same as the nested hash value. In this case @author.

I’m thinking about presenting a general overview of MVC to my Free Code Camp meetup this weekend. Since I’m basically not thinking about JS at all right now I want to contribute in a meaningful way somehow. Depending on how long that presentation is I might add REST to it. Both MVC & REST are language agnostic so it’ll be useful. Maybe even add CRUD for a 30,000 feet overview of some of the big acronyms in web development.

Time spent today: 2:12
Time spent total: 244:26
Lessons completed today: 4
Lessons completed total: 470