The DOM & Oh My Zsh!

The DOM. Forgot to throw in the main info about the DOM I learned yesterday in last night’s blog:

  • The Document Object Model is a representation of the current view of the browser, and can be manipulated without reloading a page.
  • The HTML is the text in a file first used to display the page.

With Javascript we can (1) view a current representation of our Document Object Model. With Javascript we can also (2) select specific portions of the DOM, and manipulate them, which changes what shows up in a browser window.

This small portion of text cleared up what the DOM is after a long time of not truly knowing.

I didn’t get as much done tonight as I had wanted. I started late and didn’t stay focused so it’s all my fault. I spent too much time messing with how my terminal/editor looks. I decided on using zsh with Oh My Zsh and a Powerlevel9k theme. It’s pretty sweet. All sourced from this post I saw on Reddit. Now that I have a solid config at some point I’m sure I’ll mess with it more to make it more custom to me. However, I’ve already done a few minor things like changing the ArchLinux logo and text to Ubuntu. It’s pretty cool though. I can see what branch I’m working on if there are uncommitted files if there are committed files waiting to be pushed, the time, the battery left on my laptop. I can extend these features more too, which I’m sure I’ll do someday.

I also spent a bunch of time implementing “proper” linting for JavaScript. There are so many style guides out there I struggled figuring out what to set up and use. I ended up deciding on an ESLint implementation using JavaScript Standard Style. Turns out WebStorm supports Standard by default these days so it was easy to set up. However, I had to get it installed which was easy. The hard part was finding where the node_modules folder for global installs was on my computer. I ended up running across it as a comment on a Stack Overflow post.

I also got my invite to Cypress today. I have it installed but haven’t done any work with it yet. I think I’ll use it to set up tests for my Rails Portfolio Project. Check it out. It’s definitely slick. I also started reading You Don’t Know JS as I’ve been looking for something to do outside of my computer screen to continue my knowledge expansion. Knowing that I’ll encounter JavaScript no matter what language I end up working in makes me feel like diving deeper into my knowledge of it will help no matter what. I really do enjoy Ruby but I might end up not working in it so yeah.

Time spent today: 1:59
Time spent total: 331:00
Lessons completed today: 3
Lessons completed total: 532

Let’s Be Strict

Today I spent 30 mins pairing with one of the Learn instructors trying to work through some issues my Rails portfolio project has. Something I found out is that the project requirement to use a custom attribute writer instead of has_nested_attributes actually removes some functionality from the final app. Because of this lack of Rails magic, one of my problems is harder to fix than expected. The other one is just a more simple if...else statement.

JavaScript is coming along and I’m happy it’s clicking more and more each day. It was definitely frustrating to have a rather solid grasp on a workflow, resources, and a knowledge base and then go back to almost nothing. I haven’t dove back into the Mozilla Developer Network (MDN for short) docs but I know it’s coming soon.

Something that I ran across today in my IDE was a linting error from JSLint stating Missing "use strict" pragma on one of my functions. So, like a good dev, I Googled this (well DuckDuckGo’ed this). I came to a great post and discussion about this on Stack Overflow. My takeaways were that using 'use strict'; enforces things that JavaScript allows to happen or will throw silent errors for. So, it basically forces a person to write their code correctly. However, this can be dangerous in legacy code. A great answer contained this gem IMO:

Where should I use ‘use strict’;?

  • In my new JavaScript application: Absolutely! Strict mode can be used as a whistleblower when you are doing something stupid with your code.
  • In my existing JavaScript code: Probably not! If your existing JavaScript code has statements that are prohibited in strict-mode, the application will simply break. If you want strict mode, you should be prepared to debug and correct your existing code. This is why using 'use strict'; does not suddenly make your code better.

I plan to add 'use strict'; to the top of every new JavaScript file I work on. I see no reason not to at this point in time and it’ll only enforce me writing better code in the end.

What do you think about 'use strict';? Leave it in the comments for me.

I also found out tonight from my Free Code Camp Nashville Co-Organizer Dave that he scored us a table at Music City Code 2017 which is pretty sweet. Not sure what we’re going to do with our table just yet so if you have ideas please let me know!

Time spent today: 3:07
Time spent total: 329:01
Lessons completed today: 5
Lessons completed total: 529

ruby = [], ruby << javascript

JavaScript is coming back to me more and more as I’m getting back into it. I have to say it’s a bit frustrating at times but that’s fine. I look back at how Ruby was frustrating when I started and how I enjoy it so much now (most of the time). Okay. I’m beat. It was a long day. I don’t think I’ll even publish this tonight because it’s not even a full paragraph. Just wanted to get it down on the screen for now.

Actually, I’ll publish this. I just won’t mirror it over to Medium tonight.

Time spent today: 2:27
Time spent total: 325:55
Lessons completed today: 5
Lessons completed total: 524

Back to JavaScript

So I’m back in JavaScript world again. Since I had done a lot of the intro stuff during my Bootcamp Prep work I spent tonight mostly skimming over everything I already had done to remind my mind how to think JS. I have to say, it didn’t come back quickly when I was reading it. The first lab I worked on, well the only lab I worked on, was slow. However, the functions and syntax came quickly. I feel good now that I’m done for the night. Like my brain is back to JS somewhat. I didn’t get the lab completed which was a bummer. I can look at how simple it is and know that I would have finished it in the same amount of time in Ruby but that’s fine. It’ll come quickly. The biggest thing is I know how to solve these problems better now. I just need to find equivalent functions in JS to get done what I need.

One thing I spent some time on was figuring out how to access a local “JS playground” in the terminal. It’s just easier to hit a key combo and pop into the terminal in my IDE and test than to switch over to the browser. It took asking and some searching but I finally came up with running node to bring up a repl (pretty sure I can’t explain this so read the Wikipedia and be more confused). Also, to exit out of it process.exit() is used. This was a nice find because I was spoiled by IRB, Pry, byebug and such in Ruby.

I didn’t technically finish any lessons tonight but I felt like I got a lot done.

Time spent today: 2:23
Time spent total: 323:28
Lessons completed today: 0
Lessons completed total: 519

Docs and Testing and Coverage

I tidied up my app today. I decided to scrub the DB and run a new set of seeds then test everything as best I could. This is where I see automated testing is very useful. I really want to get better acquainted with writing tests. However, I also want to finish this curriculum so I can stop paying tuition. I’m slowly building out my testing resources to take a deeper dive into that once I’m done with Flatiron. I think having high code coverage for my projects will make them more impressive to employers. I know TDD is a key thing being done these days so demonstrating I understand how to do it will be a nice touch.

So I just spent about an hour integrating Travis CI and Coveralls into my app. I’m not really sure how Coveralls decides the coverage but apparently, I have 90% coverage with only 4 tests lol. I bet I can get that up higher. I DO want to finish writing tests for my models at least. I don’t think I’ll delve into Capybara testing at all for this. I think some comprehensive model tests will be a good start. I asked in NashDev #javascript about JS testing tools and a lot of people mentioned Jest although it doesn’t do browser testing. Cypress.io was mentioned favorably as well although it appears to be in closed beta. This looked really interesting to me. Also for browser testing Selenium and TestCafe were thrown into the conversation. TestCafe looks cool but It’s also $500 so it better be good haha. I applied to get early access to Cypress so we’ll see how that goes.

Take a look at my app here and leave a comment with bugs, comments or suggestions, please.

Time spent today: 3:57
Time spent total: 321:05
Lessons completed today: 1
Lessons completed total: 519

Did I Really Finish Rails?

tacos

My Rails project is officially done! Well, it officially fulfills all the requirements that Flatiron School has for it. I definitely have more to do with it. However, considering that I’m done almost a day and a half before my self-set deadline I’m happy. Some minor things in my views (like showing just a user’s items instead of all items), building out a more robust navbar, filling out my readme, and I should be good. I also want to change my Oauth login into a button with a logo on it. I’m trying to no code “raw” HTML but I’ll probably end up doing it for that. Using Font Awesome and Bootstrap inside and ERB tag is just a pain haha.

My largest hangup was my nested forms and getting them to work properly. Although, I felt better this morning when I reached out to a public Ruby Slack room and a guy who’s a boot camp instructor (not at Flatiron where I attend) said,

yeah, that’s the worst. Dealing with nested forms is always something I have to go back and read the manual on.

I felt a lot better about the struggle life.

Check out the repo here. I’ll share the link tomorrow when I get it deployed (hopefully). I’m hoping that deploying is more straightforward since I used PostgreSQL. Not sure how well dotenv is going to play with Heroku. I know others said Figaro made it dead simple to deploy with so I might do that if I hit any snags. I wish I had more to talk about with my process but I think it’s all there is the 100+ commits lol. That and I have tacos waiting for me as soon as I finish this blog post up, get it posted, link to it on my project page, and officially submit my project.

It feels good to be at this point. Even if a little surreal at how far I’ve come in <3 months.

Time spent today: 8:27
Time spent total: 317:08
Lessons completed today: 1
Lessons completed total: 519

Hitting A Wall & Making A Plan

I’m stuck. It’s no fun. I still have things to try but I’ve hit a wall. It’s to be expected and the nested form I’m working on is by no means a simple thing. However, this is basically the BIG problem in this project. In my opinion, at least this is the hardest part of this project.

Include a nested form writing to an associated model using a custom attribute writer (form URL, model name e.g. /recipe/new, Item)

This requirement is the big one IMO. Actually, why not show off the spec and see what others think. Is this a strong project?

### Specifications for the Rails Assessment

Specs:
– [x] Using Ruby on Rails for the project
– [x] Include at least one has_many relationship (x has_many y e.g. User has_many Recipes)
– [x] Include at least one belongs_to relationship (x belongs_to y e.g. Post belongs_to User)
– [x] Include at least one has_many through relationship (x has_many y through z e.g. Recipe has_many Items through Ingredients)
– [x] The “through” part of the has_many through includes at least one user submittable attribute (attribute_name e.g. ingredients.quantity)
– [x] Include reasonable validations for simple model objects (list of model objects with validations e.g. User, Recipe, Ingredient, Item)
– [ ] Include a class level ActiveRecord scope method (model object & class method name and URL to see the working feature e.g. User.most_recipes URL: /users/most_recipes)
– [ ] Include a nested form writing to an associated model using a custom attribute writer (form URL, model name e.g. /recipe/new, Item)
– [x] Include signup (how e.g. Devise)
– [x] Include login (how e.g. Devise)
– [x] Include logout (how e.g. Devise)
– [x] Include third party signup/login (how e.g. Devise/OmniAuth)
– [ ] Include nested resource show or index (URL e.g. users/2/recipes)
– [ ] Include nested resource “new” form (URL e.g. recipes/1/ingredients)
– [ ] Include form display of validation errors (form URL e.g. /recipes/new)

Confirm:
– [ ] The application is pretty DRY
– [ ] Limited logic in controllers
– [ ] Views use helper methods if appropriate
– [ ] Views use partials if appropriate

That’s what I have checked off as well so far. I’m pretty far along and once I nail this nested form part I think the rest will be easier. If memory serves me correctly the nested show/index/new is accomplished through my routes so that isn’t even too complex. I already have an idea for my class level scope method. Then form errors being displayed. Hopefully, I can solve this nested form early tomorrow afternoon and be past it. The interesting thing is my associated model is writing just fine and it’s the “parent” that isn’t creating. I might just go back and comment out the nested part and just get the basic form to work correctly first. Actually, that’s exactly what I’m going to do. Not sure why I didn’t, to begin with. I’m just trying to get too much accomplished at once.

Okay, now I have my plan of action for tomorrow which makes me happy.

I also plan to completely redo my personal site and install Ghost on it. I discovered today that I can install Ghost via cPanel on my web host. BTW, I absolutely love my web host and you should check them out… GeekGhost. I switched to them because they support Let’s Encrypt and a lot of the large hosts do not because they want you to buy SSL certs from them. Might move my GitHub Pages site over to that as well. Create a unified site for myself since I currently have stuff all over the place. We’ll see.

Time spent today: 1:45
Time spent total: 308:41
Lessons completed today: 0
Lessons completed total: 518