bloc referral

If you are interested in learning to code with a mentor, try bloc and get $100 off.

Tuesday, August 19, 2014

Reading Rails Group

My originally idea for the next Ruby Newbie activity was to read different Ruby libraries, but I found it hard to find new and interesting libraries to check out. I chose the Inflector Library because it was a library I started looking into at work but as I read through it I found out it was a Rails library.

I have avoided Rails and it components when doing new things for Ruby Newbies and trying to stay focused on learning the concepts of Ruby, but at the end of the day Rails is Ruby and thats why I plan to hold a new event on the off weeks of the book club, called Reading Rails.

Rails is made up of 7 main components and the first component we will be reading through will be the Active Model. I am excited to finally jump into reading Rails core libraries and hopefully demystifying it. If you are available please join the discussion this Sunday.

There will not be a requirement for joining, just a basic understanding of Ruby.

My Javascript book next read list

I spent some time reading Eloquent Javascript and it has been a tremendous help in better understanding Javascript. The book itself was listed as a beginner book on the free book list and has been an easy read with already having Javascript experience.

I spent a lot of time avoiding books due to the fear of not understanding, but I have found that book have been the greatest help in understanding towards the next level. I have already completed the second part of the Well Grounded Rubyist. My goal with recording these book reviews will be to force myself to read and understand them by presenting its contents. If I had more time I would start a similar Ruby Newbies Group for Javascript.

For the time being I will be focusing on finishing Eloquent Ruby and Eloquent Javascript and then proceed to the books below.

Eloquent Javascript - Beginner
Speaking Javascript - Beginner
Javascript Applications - Intermediate
JS the Right Way  - Intermediate
You Don't Javascript - Advanced

Friday, August 15, 2014

My tour through more Javascript components

I have spent a lot of focus on Ruby during my journey, but as of late I have been bootstrapping my learning with Javascript. The following is not pure Javascript but some of the components associated with it.

Last week I was tasked with adding a modal to the display ruby functionality, something I do not have much experience with. I have previously worked with Ajax and jQuery by including snippets in my app, but never to the scale I had to this week. It took me half a day just to get the Ajax working, all of the resources on the web push you towards a simple implementation with Coffeescript examples, but that was unfortunately not helpful. I needed to learn how to implement a solution using javascript and without js.erb files.

The article that helps me most was this blogpost. It helped me understand that Ajax works very similar REST, which I got a lot of experience with while working with the Twitter API. The similarity is because the Ajax sends/receives request via JSON. Once I realized it was JSON, I knew I just needed to parse the JSON using jQuery. I spent a lot of time learning jQuery last week and how it handles events.

Think of REST and JSON as a hash or dictionary of information that can be parsed. They seem complicated but they are not.

My apologies for not giving much context but the message was sent using the this one line in my controller and received by the following jQuery function.


I highly recommend taking the time to learn Javascript, as it is intertwined a lot of the web. I sent out a tweet this week with a whole list of free Javascript books on the web. I am looking forward to learning more in the future and hopefully sharing in more detail about JSON, Ajax, and jQuery.

Wednesday, August 13, 2014

#CatchUpConf2014 - Nell Shamrell - Test Driven Development: A Love Story



I spend a lot of time in legacy code and this video has inspired me to write test. I watched this video months ago when I was determined to learn TDD and testing. I can't say I really understood it then but I can truly say this is very helpful for what  I do today.

I was encouraged to write more test and take more chances on harder parts of the codebase.

Some times things just can't be engineered: The email validation saga ends

I briefly wrote a blog post how I defeated the email validation on the server side and the possible idea on created my first Ruby gem to do so in the future. I also through in a quick picture of my success in creating client-side validation in JS, I felt pretty proud till I realized I was going to suffer the same emails string pains I did with Rails.

It is surprising that there are so few blog post/resources on working with validating emails, luckily I found a lot more examples in JS then I did in Ruby. It seems there are not many people creating modals using bootstrap to take multiple emails separated by commas.

I received the recommendation to use the jQuery Validator, which was easily implemented once I learned how to reference the proper id's. I had limited jQuery experience prior and most was copy and pasted, without much realization of what I was doing. I did a lot of catching up in learning jQuery thanks to treehouse and can now say I have  working knowledge of it. I was surprised to learn that jQuery is basically a powerful form of CSS for Javascript and not much more.

Even after learning what was needed to know I discovered, with the help of multiple coworkers, that the jQuery Validator does not work well with Twitter-Bootstrap. I was unaware, but not fit to explain, there are many limitations with bootstrap and many advanced features in front-end development are limited because of it.

Bootstrap is a great tool for individuals looking to get a decent front-end design quickly and focus more on the back-end program. I have quickly realized there will always be a point where tough decisions will be made. There is a Bootstrap Validator, but similar to many other tools, it does not handle multiple emails in a string.

Bootstrap prevents the validator to activate until a valid email is entered, which is the opposite functionality in this JSfiddle. This is absolutely mind-boggling, but forced me and the team to make decision to move on. There are just too many factors, the fact this is a modal, using bootstrap, and the need to validate a string of emails separated by commas.

It came to a point where no more time could be sunk into this feature and the executive decision was made to move-on without client-side validations. If this was a personal project, I would of walked away sooner, but the determination to implement all features a requested caused me to spend more than time than needed on this.

This was an experience I will not forget and for future failures I hope to find a solution, or realize a stopping point sooner. I stand here defeated but with the advice, you can't engineer everything.



Monday, August 11, 2014

sublime key binding path command

If you find yourself typing out the path of a file multiple times, I recommend using the below shortcut in you Key Bindings. Sublime is a powerful IDE and has many shortcuts and tools hidden in it.

I was unaware of Key Bindings but happy to have found this thanks to my coworker @robdel12.

{ "keys": ["super+ctrl+f"], "command": "copy_path" }

email validations for arrays in rails

Sometimes things just aren't that easy. Rails is definitely nice when you do everything out of the box and do not veer to far from the path; I am quickly finding that there are some things that are difficult figure out.

For example I had a task late afternoon to validate emails that are stored in an Array. I original stored all emails as strings but due to way the Rails Mailer works and the needs of the application, the emails are now being collected using CSV(separate by commas) in a string. I am easily able to split that string using split(",") and serializing that into an array. I am also handling single emails by converting them using the Rails method Array.wrap(). Those 2 methods could be blog post in their selves but I am opting to just explain my next issue.

The trouble with storing the emails in an Array is that it broke all my email validations, which does not check a string of emails,  I now am tasked with testing the validations by hand, after discovering that the Active Validator only validates strings.


Validate an array of emails.
emails: ["ilikerobot[at]gmail.com, hello[at]briandouglas.me"]

emails.split(",")

emails: ["ilikerobot[at]gmail.com", "hello[at]briandouglas.me"]

With this being my first major case where Rails couldn't do what, I am considering looking at the Active Validator to see if I can contribute to it and add this functionality, but it might be better as a gem. I am sure it would take longer than a night to implement but it could be a cool challenge to create my first gem and this idea seems simple enough.

My first implementation:








My final implementation *after peer review, it turned out I wrote too much code just to check for the validation of an email :)







I also did the same validation in Javascript, on the client-side.