#ruby, #rails, #OOP, #javascript, #ember
1/26/17
1/25/17
Setting up Polymorphism in Ruby on Rails
Polymorphism can take a little longer to understand conceptually than other topics in OO. It is an abstraction which takes a little more effort for the developer to implement, but makes extending easier later on.
In this example I have three models that I want to add an attachment too: Patient, Prescriber, Order. Each attachment requires the same attributes and instead of adding a new attachment column on each model I am electing to create a new model called "AttachmentObject" and make it polymorphic. I am using the paperclip gem with S3 for attachment upload.
then for my relationships to my "attachable" models (Patient, Prescriber, Order).
It is not necessary to name your "has_many" relationship with a name that uses "able" as a suffix, but you will see that it is a popular amongst rails devs and you should use it as a convention when possible. Now comes the fun parts. With my AttachmentObject I can now use rails helpers to find its related attachable parent. Active Record does this by looking up the 'attachable_type' (which points to either Patient, Prescriber, or Order table) and 'attachable_id' which points to a row on the table. for example:
In this example I have three models that I want to add an attachment too: Patient, Prescriber, Order. Each attachment requires the same attributes and instead of adding a new attachment column on each model I am electing to create a new model called "AttachmentObject" and make it polymorphic. I am using the paperclip gem with S3 for attachment upload.
class AddAttachmentPolyObject < ActiveRecord::Migration
def change
create_table :attachment_objects do |t|
t.string :title, null: false
t.references :attachable, polymorphic: true, index: true, null: false
t.attachment :attachment, null: false
t.timestamps
end
end
end
class AttachmentObject < ActiveRecord::Base belongs_to :attachable, polymorphic: true validates :title, :attachable_id, :attachable_type, presence: true end
then for my relationships to my "attachable" models (Patient, Prescriber, Order).
class Patient < ActiveRecord::Base has_many :attachment_objects, as: :attachable end
class Prescriber < ActiveRecord::Base has_many :attachment_objects, as: :attachable end
class Order < ActiveRecord::Base has_many :attachment_objects, as: :attachable end
It is not necessary to name your "has_many" relationship with a name that uses "able" as a suffix, but you will see that it is a popular amongst rails devs and you should use it as a convention when possible. Now comes the fun parts. With my AttachmentObject I can now use rails helpers to find its related attachable parent. Active Record does this by looking up the 'attachable_type' (which points to either Patient, Prescriber, or Order table) and 'attachable_id' which points to a row on the table. for example:
#explicitly order = Order.create( valid_attributes ) order_attachment = AttachmentObject.create(title: "phish", attachable_type: "order", attachable_id: order.id) #or implicitly order_attachment = AttachmentObject.create(title: "phish", attachable: order)I can then do
phish = AttachmentObject.find_by_title("phish")
phish.attachable #returns the related order_attachment
12/20/16
Cacheing Ruby With APICache gem
If you're running a rails app then chances are you're playing with multiple apis. This week I found myself working with the robust JIRA api so that I could return worklogs and do something meaningful (and more user friendly) for a client.
You could easily write your own cacheing class using timestamps and urls as keys for the queries, but I really like this gem (APICache by Martyn Loughran) because it has a couple nice features out of the box like :period, :valid, and :cache timeout options. The gem is also simple; it consists of two main classes, Api and Cache, which are both under 100 lines of code. The other few classes are wrappers that help you configure your 'mem-cache' store which we'll get into later.
First download the api_cache gem Then add 'config/initializers/api_cache.rb' And add this code
In my example we are retrieving large data sets. Returning the JSON and refreshing the page took around 15 seconds, no bueno. In order to cache all our request to the Jira server we used our own wrapper class that defined a 'get' method. This class inherited from our jira::client so that way all gets would go through our logic. If we want to implement a new http request (like put, patch, post) we can follow the same pattern. We then wrapped our get method with APIcache logic
You could easily write your own cacheing class using timestamps and urls as keys for the queries, but I really like this gem (APICache by Martyn Loughran) because it has a couple nice features out of the box like :period, :valid, and :cache timeout options. The gem is also simple; it consists of two main classes, Api and Cache, which are both under 100 lines of code. The other few classes are wrappers that help you configure your 'mem-cache' store which we'll get into later.
First download the api_cache gem Then add 'config/initializers/api_cache.rb' And add this code
if Rails.env.production? APICache.store = APICache::DalliStore.new endThis will set up a dalli store (which is a pure Ruby client for accessing memcached servers) when you are in production and will use memory to cache data when running locally. This allows you to boot up your app and play around without having to run a second server every time. When you get ready to deploy to production read the Dalli docs to learn more about how the process works.
In my example we are retrieving large data sets. Returning the JSON and refreshing the page took around 15 seconds, no bueno. In order to cache all our request to the Jira server we used our own wrapper class that defined a 'get' method. This class inherited from our jira::client so that way all gets would go through our logic. If we want to implement a new http request (like put, patch, post) we can follow the same pattern. We then wrapped our get method with APIcache logic
def get( url )
APICache.get(url, :cache => cache_timeout, :timeout => 15) do
super(url)
end
end
def cache_timeout
skip_cache ? 1 : 3000
end
The skip_cache is an attr_accessor which we pass in when we instantiate this class on specific situations. Besides that we use our default cacheing timeout setting which is 50 mins.
The Api Cache gem also allows these configurations
{
:cache => 600, # 10 minutes After this time fetch new data
:valid => 86400, # 1 day Maximum time to use old data
# :forever is a valid option
:period => 60, # 1 minute Maximum frequency to call API
:timeout => 5 # 5 seconds API response timeout
:fail => # Value returned instead of exception on failure
}
Check out api_cache gem for the official docs.
11/23/16
That's not broken... Re-think your design
It has been 9 months since I have posted on this blog and I have learned a TON in that amount of time. I'm restarting this blog to share some a few things I learn each month. To start off, here's some Devise.
We have all used the very popular Rails engine ‘Devise.’ A couple weeks ago I came across a new use case with the gem about overriding one of their standard methods. I was dealing with the mailer and a client wanted to redirect to a new page after a user confirmed their account via email. Simple enough. The problem was my agency uses a custom rails engine that preinstalls Devise and therefore some of it's initial configuration; like overriding the 'after_confirmation_path' method.
First I tried overriding Devise's method just like their docs suggest, but that didn't work for some reason. Maybe I source the gem from my local (instead of rubygems.com) and update its child method 'after_confirmation_path' to fit my needs? That could work if I was doing some serious customization to the overall gem, but I clearly was not. I also tried setting the Devise mailer to use my own mailer in its configuration. No luck.
Then I considered calling the 'grandparent' (which would be the devise method) and overriding it for the project I was in. Apparently this is a thing, but there was no way that it felt right for doing something so simple. This was my first hint that I was on the wrong track. (stack overflow dealing with grandparent override). I also tried setting our custom gem's mailer to use my own mailer in its configuration. No luck.
In the end, the solution was a simple configuration that I had overlooked. I'm currently learning Ember.js and I stumbled upon this quote the other day that relates to my problem here: "It sounds like right now you're working hard to do something that Ember deliberately discourages. Generally I find when I'm fighting the framework it's because my understanding of the problem is different (and often not as complete as the framework authors)."
The lesson here: Pay attention to signs that you are on the wrong path and moving too quickly. When solving simple problems look for simple solutions. Don't reinvent the wheel. I should have spent more time looking at my first solution instead of dismissing it and thinking there was something wrong with my apps design, or Devise.
Here's the end product, which Devise easily points to in their docs
We have all used the very popular Rails engine ‘Devise.’ A couple weeks ago I came across a new use case with the gem about overriding one of their standard methods. I was dealing with the mailer and a client wanted to redirect to a new page after a user confirmed their account via email. Simple enough. The problem was my agency uses a custom rails engine that preinstalls Devise and therefore some of it's initial configuration; like overriding the 'after_confirmation_path' method.
First I tried overriding Devise's method just like their docs suggest, but that didn't work for some reason. Maybe I source the gem from my local (instead of rubygems.com) and update its child method 'after_confirmation_path' to fit my needs? That could work if I was doing some serious customization to the overall gem, but I clearly was not. I also tried setting the Devise mailer to use my own mailer in its configuration. No luck.
Then I considered calling the 'grandparent' (which would be the devise method) and overriding it for the project I was in. Apparently this is a thing, but there was no way that it felt right for doing something so simple. This was my first hint that I was on the wrong track. (stack overflow dealing with grandparent override). I also tried setting our custom gem's mailer to use my own mailer in its configuration. No luck.
In the end, the solution was a simple configuration that I had overlooked. I'm currently learning Ember.js and I stumbled upon this quote the other day that relates to my problem here: "It sounds like right now you're working hard to do something that Ember deliberately discourages. Generally I find when I'm fighting the framework it's because my understanding of the problem is different (and often not as complete as the framework authors)."
Devise.setup do |config| config.mailer = 'UsersMailer' end
The lesson here: Pay attention to signs that you are on the wrong path and moving too quickly. When solving simple problems look for simple solutions. Don't reinvent the wheel. I should have spent more time looking at my first solution instead of dismissing it and thinking there was something wrong with my apps design, or Devise.
Here's the end product, which Devise easily points to in their docs
class Users::ConfirmationsController < Devise::ConfirmationsController
protected
def after_confirmation_path_for( resource_name, resource )
super + "?email=#{params[:email]}"
end
end
2/17/16
Hired
Yesterday I accepted my first job with a small start up out of Jacksonville Beach working in Ruby on Rails. Looking back at this blog I can't help but feel proud of how far I have come. From start to finish it took me six months to land an entry level position, which is what I hoped for in the beginning but had no idea if it was possible for me.
I'm going to shut down this blog/project, and start focusing on new things. I will be looking for more ways to blog and contribute to coding communities as this has been a lot of fun tracking my progress.
-John
1/27/16
Hackathon, Meetups and More
I have been in Orlando the fast couple weeks, here's an update of whats been going on.
Tabs on Tallahassee Hackathon
- this was my first all-day hackathon and I had a great experience. Not knowing what to expect, I showed up in the morning and joined a team. We were given some basic guidelines (which can be found on the link above), put into a room for about nine hours, and asked to come up with something. Two guys on my team held senior positions and took the lead. We decided to use Angular (something I had not used before) and began working on our idea which gave information on your legislator by zip-code, then according to your own political beliefs, compared your representative to a legislator that lined up with your own political view points.
We did not get to finish our app but our code is on my github. I contributed to our front end but also spent time watching the back end of our app development, I was very interested in watching the pros thought process. Overall this was a great experience working with a team and I look forward to more events like this.
Ruby Jax Action Cable - my favorite meetup that I attend, this one was back in Jax Beach. Best thing was more reassurance that testing is the path to getting hired. During this meetup Eric Bundy gave a talk and did some live coding on Rails 5 new Action Cable feature.
Jax Tech Meet Up - another cool meetup back in Jax Beach, this one was really great for networking and I received some new contacts that I hope will lead to some freelance work.
WordPress Site Optimization - meetup in downtown Orlando at Envy Labs, pretty cool introduction to wordpress and another great networking experience.
Tabs on Tallahassee Hackathon
- this was my first all-day hackathon and I had a great experience. Not knowing what to expect, I showed up in the morning and joined a team. We were given some basic guidelines (which can be found on the link above), put into a room for about nine hours, and asked to come up with something. Two guys on my team held senior positions and took the lead. We decided to use Angular (something I had not used before) and began working on our idea which gave information on your legislator by zip-code, then according to your own political beliefs, compared your representative to a legislator that lined up with your own political view points.
| Tabs on Tally Hackathon |
We did not get to finish our app but our code is on my github. I contributed to our front end but also spent time watching the back end of our app development, I was very interested in watching the pros thought process. Overall this was a great experience working with a team and I look forward to more events like this.
Ruby Jax Action Cable - my favorite meetup that I attend, this one was back in Jax Beach. Best thing was more reassurance that testing is the path to getting hired. During this meetup Eric Bundy gave a talk and did some live coding on Rails 5 new Action Cable feature.
Jax Tech Meet Up - another cool meetup back in Jax Beach, this one was really great for networking and I received some new contacts that I hope will lead to some freelance work.
WordPress Site Optimization - meetup in downtown Orlando at Envy Labs, pretty cool introduction to wordpress and another great networking experience.
| Meetup @ Envy Labs Orlando |
I also volunteered to give the next talk at Ruby Jax in a couple of weeks. My topic is REST and how it makes Rails awesome.
-John
Labels:
coding bootcamps,
hackathon,
javascript,
learn to code,
meetups,
orlando,
rspec,
ruby on rails,
volunteer
1/13/16
Resume, LinkedIn, Portfolio and Updates from this Week
Past few days I have been all over rubymonk.org, Lynda.com, guides.rubyonrails.org, Rails 4 Way (3rd edition) and some treehouse videos. I also have a portfolio page up here, updated resume, and linkedin ready to go.
Here a summary of the past few days:
Ruby Monk-- Finished ruby primer and am 2 1/2 chapter into Ruby Primer Ascent. I have found this site very helpful with brushing up on things I have forgotten and also teaching me a lot of new things about the way Ruby works. New things I have learned include: converting implicit blocks to explicit, how a class instance variable can be beneficial, the difference between puts and p, and how to use the splat method.
lynda-- finished RSpec course and have a good grasp on how the framework works and why it is so important. Learned how to write model specs (usually the most important specs), helpers, controllers with the HTTP requests, and views.
RubyonRails Guides and Rails 4 Way-- I have spent a few hours today reading over how routes work and was amazed at how it really cleared up a lot for me. Even though I have been feeling good about rails this was super helpful to be reminded about HTTP and route names and how 'resources :name' works.
Tree House-- signed up for a trial (I know, getting spread thin) but am really interested on their take on how ActiveRecord works. I am currently finishing up their Database Foundations tutorial working with sqlite and Work Bench.
When I first decided to learn to code I was attracted by the lucrative salaries and job security. That part of the industry seems less important to me the more I learn. In the past five months I have developed a different way of interpreting things and that is really rewarding. It's amazing because I have been putting in long hours (10-12 hours a day the past 8 days) and am genuinely enjoying the process. My focus is on being a great programmer and I have never felt better.
I never considered myself to have attention deficit disorder until I began to learn to code, not because I constantly struggle with looking at my phone or scrolling my FB feed, but because of the sheer amount of things I want to learn it's hard to decide where to focus my attention. I have decided I am going to finish the month of January out strong and begin seriously looking for work in February. In the mean time I am continuing to practice ruby, study rails, read everything I can, and see if I can find some freelance or open source projects that I can contribute to.
| White Board | Check List | Recent Goals |
Here a summary of the past few days:
Ruby Monk-- Finished ruby primer and am 2 1/2 chapter into Ruby Primer Ascent. I have found this site very helpful with brushing up on things I have forgotten and also teaching me a lot of new things about the way Ruby works. New things I have learned include: converting implicit blocks to explicit, how a class instance variable can be beneficial, the difference between puts and p, and how to use the splat method.
lynda-- finished RSpec course and have a good grasp on how the framework works and why it is so important. Learned how to write model specs (usually the most important specs), helpers, controllers with the HTTP requests, and views.
RubyonRails Guides and Rails 4 Way-- I have spent a few hours today reading over how routes work and was amazed at how it really cleared up a lot for me. Even though I have been feeling good about rails this was super helpful to be reminded about HTTP and route names and how 'resources :name' works.
Tree House-- signed up for a trial (I know, getting spread thin) but am really interested on their take on how ActiveRecord works. I am currently finishing up their Database Foundations tutorial working with sqlite and Work Bench.
When I first decided to learn to code I was attracted by the lucrative salaries and job security. That part of the industry seems less important to me the more I learn. In the past five months I have developed a different way of interpreting things and that is really rewarding. It's amazing because I have been putting in long hours (10-12 hours a day the past 8 days) and am genuinely enjoying the process. My focus is on being a great programmer and I have never felt better.
-John
1/9/16
Great expect(ations) w RSpec
The holidays are over an I have been chipping away daily. This week I have dedicated much of my time to learning RSpec and testing ruby frameworks. Searching around there isnt an abundance of testing information for beginners on the web, but I signed up for a free trial at Lynda.com and have been very happy with there 6hr class on testing with RSpec. I'm about 3/4 finished and have learned much of the syntax and theory behind RSpec.
Also, I can't recommend Lynda.com enough. I have only viewed their course on testing ruby frameworks but I have a feeling that everything they do is at a high level. I plan to continue to use them as I move forward.
Here is a summary of what I have learned the past two days with Lynda and RSpec:
The hiearchy is important: spec file => example groupe => nested group => example => expectations is really the meat of the whole operation and once I understood that I really started to understand the big picture.
Helper methods: It is important to keep your suite as fast as possible therefore encouraging frequent tests. Now this is a non issue for small projects, but as things grow I could see how this would slow things up. Helper methods help keep unnecessary tests from running and slowing down the process.
The let method is really cool because it creates a helper method that takes one argument, which is the name of the method you want to create and then a block of code.
ex.
let(:car) { Car.new}
it "allows reading for :wheels" do
expect(car.wheels).to eq(4)
end
you can also use subject as your helper
ex.
subject {Car.new}
it ....
end
........and going farther you can define subjects implicitly by using a class name as the 'describe' argument
ex.
(this is how it looked like before)
describe 'Car'
subject { Car.new }
it ....
end
end
*is the same thing as
describe Car
it...
end
end
^Here the subject is implicitly defined. As soon as it encounters the class as an argument it creates a helper method with the subject as the class Car. this works well if the subject you are working with is in only one class.
For Rails testing I learned about SHARED EXAMPLES, which is where RSpec begins to get more complex.
Shared examples let you describe behaviour of classes or modules. When declared,
a shared group's content is stored. It is only realized in the context of
another example group, which provides any context the shared group needs to
run.
In rails this comes in handy when describing things like 'CRUD' in your controller.
ex.
describe ProductsController do
describe '#index'
it_behaves_like 'a standard index action'
end
describe '#new'
it_behaves_like 'a standard index action'
end
end
.....and so on
.....and so on
Should be finishing up the rest of the course tomorrow along with the last touches on my portfolio and resume. I'll be going to a meetup this next Thursday at Hashrocket in Jax Beach, and they give opportunities at the end for attendees to put projects up in front of the group to have it "torn a apart" by the pros. I hope to have a TDD or BDD app built from the ground up by then; I'd love to get live feedback that way.
it is now 4 a.m., please excuse the typos
-John
Labels:
learn to code,
lynda.com,
rspec,
ruby,
ruby on rails,
self development,
tech talent south
12/28/15
Tech Talent South Complete, Now What?
| Outside of Class |
Of all the cool things that we did during class, my favorite and most rewarding would definitley be our final project that two classmates and I completed during the final weeks. We were told to make an app using the things we had learned in class; no guidelines. While brainstorming we decided our favorite thing about class was working with api's, so we looked around the web and found some we liked. We eventually choose a weather api and an event api. Two weeks of wrestling with our code we created Drink Weather, a silly web app that takes a users current location and returns the current weather, an adult beverage recomendatioin based on that weather, and also an activity according to weather and location. Working from scratch really helped cement what we had learned throughout class and the all the mistakes that were made during our creation of Drink Weather made us better coders now. We also became very familiar with working on github as a team, and how to deploy a rails app to heroku. I know it's not perfect, but we all took pride in the creation of Drink Weather.
TTS is now completed and here are the next things on my agenda:
- Test, test, test. Pretty much every dev that I have had the pleasure to talk with over the past month has mentioned the importance of testing which is one of the areas that TTS did not cover in depth (we only spent one day on testing and really only provided a basic introduciton). I understand why it is important and know I will need to be comftorable with the practice in order to land a job.
- Learn VIM- I know that there are mixed opinions on vim, atom, sublime, etc. but after talking to some pros it does seem that learning vim could really improve my proficiency and help with job placement.
- Sharpen my Ruby- I am most familiar with Ruby of all languages with JavaScript coming in second. When getting advice from people in the industry, one of the things I was most interested in was whether I should focus on learning one language really well or spread my self out and learn the basics of a few languages. Most people said to get really good at Ruby first which will not only help with a job but also with the process of learning a new language in the future.
- Sharpen JavaScript- Like Ruby, I am familiar with JS and want to continue to improve on it.
I officially quit my previous job at the end of August and aimed at securing a job within six months. That means I will be employed be the end of February, wish me luck.
-John
12/27/15
Kids Code Volunteering
Earlier this month I had the opportunity to volunteer as in instructor for Tech Talent South's Kids Code class. I have now volunteered for two of the classes and it's amazing how scary 8-year olds can be with their parents in the background. All kidding aside, I was really happy with the experience and even more surprised what one can learn when teaching others. I know everyone says it, but teaching a lesson to others (no matter what degree of difficulty) really helps you better understand the material yourself.
In the class we went over very basic code practices beginning with HTML and working our way up to basic Ruby. The kids seemed to respond well to Mike (our other volunteer instructor) and myself, and even though the material was aimed at early beginners, I still found things to learn. For example, while showing kids how to add an image to a web page, I stumbled to remember the exact syntax to do so (thanks Sublime). I can see how relying too much on text editors, even for simple things like adding an image in html, can be bad when that job interview comes around and asks you to get on a white board. TL;DR Learning never stops :)
-John
In the class we went over very basic code practices beginning with HTML and working our way up to basic Ruby. The kids seemed to respond well to Mike (our other volunteer instructor) and myself, and even though the material was aimed at early beginners, I still found things to learn. For example, while showing kids how to add an image to a web page, I stumbled to remember the exact syntax to do so (thanks Sublime). I can see how relying too much on text editors, even for simple things like adding an image in html, can be bad when that job interview comes around and asks you to get on a white board. TL;DR Learning never stops :)
-John
12/5/15
Tech Talent South Week 4 Complete
A couple weeks ago we began implementing jQuery into some rails apps. We made an ATM app with js and gave it some simple logic. Once I began to understand the syntax I began seeing why everyone uses jQuery. I added a couple functions that change some css elements so the text displays red if the user tries to withdrawl more money than they have in the account. I also began playing around with allowing the user to hit the enter key after typing in the field instead of manually clicking with the mouse.
Code that allows user to hit enter when finished with number field:
function hitEnter(id, buttonid){
$("#enters").keyup(function(event){
if(event.keyCode == 13 && $(id).val() !== ''){
$(buttonid).click();
}
});
}
then I called the function six times and passed the appropriate id's.
hitEnter('#d_amount','#deposit')
hitEnter('#w_amount', '#withdrawl')
hitEnter('#x2c_amount', '#x2check')
hitEnter('#x2s_amount', '#x2save')
hitEnter('#dep_sav', '#d_saving')
hitEnter('#with_sav', '#w_savie')
I spent a good amount of time figuring out how to make the message turn red when a user requests more money than they had in their account. I eventually wrote two very simple functions that changed the css from red to black:
function red(){
$('#message').toggleClass('warning')
$('#message').text('you do not have enough money')
}
function backBlack(){
if ($('#message').hasClass('warning')){
$('#message').toggleClass('warning')
}
}
then called the functions like this:
$('#x2check').click(function(){
var amount = parseFloat($('#x2c_amount').val())
$('#x2c_amount').val('')
if (savings < amount){
alert("you do not have enough funds")
red()
} else {
backBlack()
savings -= amount
checking += amount
$('#message').text("Your transfer from savings to checking for quot; + amount + " was completed.")
}
})
Two of my favorite things we have done with rails over the past month was using Omniauth to allow user to sign in with an existing account like facebook or google+ and using google maps api and geocoder to that allowed users to find updated bus arrival times. For our facebook log in we used the omniauth gem with figaro to hide our API key's secret. We then used the omni_auth method to to create the user profile using the "provider" "userid" and "name" from facebook. For our bus app we set out to to create an app that would take an address from the user and then let the user know if there is a bus close by. We created a basic form to allow user input and stored nearby buses in an empty array after looping with a do loop. Using geocodes lat and longitude capabilities in our model, we then grabbed the bus system's api using a really cool gem called HTTparty that does all the parsing for us. We then implemented a live google map showing the location of the current bus using ajax.
Next week we will be working on more rails apps and I will finish the last bit of JavaScript on my portfolio site.
-John
Labels:
codenewbie,
coding,
coding bootcamps,
geocoder,
javascript,
jquery,
marta,
omniauth,
tech talent south
11/9/15
Tech Talent South Week 2 Update
Tech Talent South has greatly sharpened my understanding of many programming basics I thought I had already mastered. It has only been two weeks with the program and I cannot not over emphasize how great it is to have an instructor to bounce questions off of. TTS runs four days a week, four hours each class and two extra office hours each day. So far we have covered the basics of Ruby (arrays, methods, hashes, and Classes), which I had studied when I first began to learn in August by reading Chris Pine's book, "Learn to Program". It was a good refresher on the Ruby language since I had not done anything with Ruby since I read Pines book and I also enjoyed being around other students during the learning process. I have also found it valuable to see how others work out the problems as they go; it ultimately helps me think about problems in different ways, something I could not duplicate working on my own most of the time.


Last week (week 2) we got into Rails which I was really excited about since this was essentially uncharted territory for me. I remember just starting out I wanted to try rails after finishing some ruby stuff but gave up after an installation fail. lol. Thinking back to that point I remember being overwhelmed with all of the information out there and not knowing where the hell to go. Being in this program really helps with that. Now I have a set curriculum with an instructor leading the way to help out when I get hung up on something.
This weekend I started going through the Ruby on Rails Tutorial by Michael Hartl, which is a great supplement to what we are doing in class. I have gotten through the middle of Ch 3, which is basically what we have accomplished in class up to this point. I have to say that going over this book after the work we do in class really helps me understand the concept of rails and how the MVC framework functions. In my own words, when you type something in the browser that then goes to the rails router and requests that page from the controller with the same name. That then, using instance variables, goes to the model which retrieves the information from the database, returns that to the controller which then goes to the view page, renders the html back to the controller and to the browser...and boom, web page.
We created some small rails apps so far including a mock university which uses a database to store classes, students, grades, and depatments. I have gotten a lot more familiar with the command line as a result of using rails as well as a general knowledge of git and heroku. I'm really excited to see what I can get my hands on this week as I continue to further my learning in and out of the classroom.
This weekend I started going through the Ruby on Rails Tutorial by Michael Hartl, which is a great supplement to what we are doing in class. I have gotten through the middle of Ch 3, which is basically what we have accomplished in class up to this point. I have to say that going over this book after the work we do in class really helps me understand the concept of rails and how the MVC framework functions. In my own words, when you type something in the browser that then goes to the rails router and requests that page from the controller with the same name. That then, using instance variables, goes to the model which retrieves the information from the database, returns that to the controller which then goes to the view page, renders the html back to the controller and to the browser...and boom, web page.
We created some small rails apps so far including a mock university which uses a database to store classes, students, grades, and depatments. I have gotten a lot more familiar with the command line as a result of using rails as well as a general knowledge of git and heroku. I'm really excited to see what I can get my hands on this week as I continue to further my learning in and out of the classroom.
-John
Tech Talent South Scholarship
Since making the decision to learn how to program I have always been attracted to the idea of a coding bootcamp. The problem for me, however, was that I was unsure of how valuable a two or three month program would ultimately be compared to the cost. About a month ago I heard about Tech Talent South and that they would be teaching a "total immersion" course here in Jacksonville this fall and that they would be offering a 100% scholarship for the semester; I decided to apply.

A couple of days after my application I received a call from there communications director for a phone interview that lasted about an hour. Over the course of the interview I talked about much of the material I had completed on my own, what I was currently working on, and why I had developed an interest in programming in the first place. I also referenced this blog and some general interests that I had such as volunteering and supporting the hometown Jacksonville Jaguars. Overall I thought the conversation went well, and I was told that I would be accepted to the 8-week program and would also be considered for the scholarship.
Two days later I received the good news: I would be awarded the scholarship for 100% tuition! I was ecstatic to say the least. I have just finished up my second week of class and will update with what I have learned so far, but I believe that the reasons I was awarded this scholarship are very similar to the reasons that employers higher new employees. Here's what you can do to help your chances at landing a similar scholarship or that future dream job:
Ask lots of questions- during the interviewing process the person being interviewed should be asking just as many questions if not more than the person conducting the interview. This not only shows genuine interest and the fact that you have done research on your own about the company you applied for but it also helps for you to decide if the company is a good fit for you.
This website does a great job of giving example questions and also explaining why they are important.
Write a blog- Especially if you are entering a new field such as computer programming, a blog acts as a modern day resume. When interviewing in person or over the phone, a blog will help cover in detail some of your accomplishments and progress that you may forget to mention. Don't worry about how many readers you have, writing shows comprehension, real time progress, initiative, and the ability to communicate. This post by Tim Ferriss goes into more detail about breaking into a new industry and the importance of blogging your progress.
Do your HW- Before applying anywhere, do your research That means check out the website, look up the CEO or founder, and reach out to any current employees or graduates.
A couple of days after my application I received a call from there communications director for a phone interview that lasted about an hour. Over the course of the interview I talked about much of the material I had completed on my own, what I was currently working on, and why I had developed an interest in programming in the first place. I also referenced this blog and some general interests that I had such as volunteering and supporting the hometown Jacksonville Jaguars. Overall I thought the conversation went well, and I was told that I would be accepted to the 8-week program and would also be considered for the scholarship.
Two days later I received the good news: I would be awarded the scholarship for 100% tuition! I was ecstatic to say the least. I have just finished up my second week of class and will update with what I have learned so far, but I believe that the reasons I was awarded this scholarship are very similar to the reasons that employers higher new employees. Here's what you can do to help your chances at landing a similar scholarship or that future dream job:
Ask lots of questions- during the interviewing process the person being interviewed should be asking just as many questions if not more than the person conducting the interview. This not only shows genuine interest and the fact that you have done research on your own about the company you applied for but it also helps for you to decide if the company is a good fit for you.
This website does a great job of giving example questions and also explaining why they are important.
Write a blog- Especially if you are entering a new field such as computer programming, a blog acts as a modern day resume. When interviewing in person or over the phone, a blog will help cover in detail some of your accomplishments and progress that you may forget to mention. Don't worry about how many readers you have, writing shows comprehension, real time progress, initiative, and the ability to communicate. This post by Tim Ferriss goes into more detail about breaking into a new industry and the importance of blogging your progress.
Do your HW- Before applying anywhere, do your research That means check out the website, look up the CEO or founder, and reach out to any current employees or graduates.
-John
10/22/15
Friedman's "Schemer" and the Wonderful World of Recursion
"In order to be creative one must first gain control of the medium...In engineering, as in other creative arts, we must learn to do analysis to support our efforts in synthesis. One cannot build a beautiful and functional bridge without a knowledge of steel and dirt and considerable mathematical technique for using this knowledge to compute the properties of structures. Similarly, one cannot build a beautiful computer system without a deep understanding of how to "pre-visualize" the process generated by the procedures one writes." -Gerald J. Sussman taken from the forward of The Little Schemer
As I have mentioned in other blog posts, learning the programming basics on your own can be frustrating. Sometimes it feels like I'm wandering through a thick fog that I can't find my way out of. But alas, Daniel P. Friedman's The Little Schemer has given me hope.
This book is all about recursion, something that I did not understand but had used on websites such as Free Code Camp and Code Academy. There were many "ah-ha!" moments for me while reading this book, but most importantly I began to understand what the hell recursion actually is. In my own words, recursion is a problem that solves itself by referring back to its beginning after modifying at least one part of the original problem. In Friedman's words, "recursion is the act of defining an object or solving a problem in terms of itself."
I first heard of this book while going through Douglas Crockford's JavaScript lectures on youtube. He mentioned that every programmer should understand what this book teaches, and when Crockford recommends such things, young programmers should listen.
The book is structured in a wonderfully refreshing way especially for someone who intends to learn on their own. The text consists of simple questions that build toward more complex realizations. Instead of giving definition terms in English, the book works the reader to a conclusion on his/her own by using the previous question and answer to help define the next.
The Little Schemer is written in the language Scheme, something I have never seen before, but I had no problem picking up the concepts of the book because the language has many similarities to JavaScript. For example, a scheme function would translate to JavaScript like this:
This book helped me understand recursion MUCH more, and is something that I will return to over the next few weeks when I feel I need a refresher.
-John
As I have mentioned in other blog posts, learning the programming basics on your own can be frustrating. Sometimes it feels like I'm wandering through a thick fog that I can't find my way out of. But alas, Daniel P. Friedman's The Little Schemer has given me hope.This book is all about recursion, something that I did not understand but had used on websites such as Free Code Camp and Code Academy. There were many "ah-ha!" moments for me while reading this book, but most importantly I began to understand what the hell recursion actually is. In my own words, recursion is a problem that solves itself by referring back to its beginning after modifying at least one part of the original problem. In Friedman's words, "recursion is the act of defining an object or solving a problem in terms of itself."
I first heard of this book while going through Douglas Crockford's JavaScript lectures on youtube. He mentioned that every programmer should understand what this book teaches, and when Crockford recommends such things, young programmers should listen.
The book is structured in a wonderfully refreshing way especially for someone who intends to learn on their own. The text consists of simple questions that build toward more complex realizations. Instead of giving definition terms in English, the book works the reader to a conclusion on his/her own by using the previous question and answer to help define the next.
The Little Schemer is written in the language Scheme, something I have never seen before, but I had no problem picking up the concepts of the book because the language has many similarities to JavaScript. For example, a scheme function would translate to JavaScript like this:
(define phish (lambda (a b c) (body)))
//and in JavaScripst...
function phish foo(a, b, c) {
return body;
};
As you can see the functions are pretty similar so for most of the book I just left the problems in scheme. One thing that really stuck out to me while going through this book is the functions that I have been taking for granted such as the simple .length property in JavaScript, or the very often used "rember" function found in the book. "Rember" takes two arguments, one an atom and one a list, and removes the first argument when it finds it in the list.
This book helped me understand recursion MUCH more, and is something that I will return to over the next few weeks when I feel I need a refresher.
-John
10/19/15
The Selfish Gene and Programming
This book is more of a reason behind why I am learning to program than biology. I first began reading this about a month and a half ago (around the same time I began coding full time) just out of curiosity. I soon began seeing all the similarities between natural selection and coding computers today. In The Selfish Gene Dawkins explains his theory that we evolved to the conscious beings that we are today by being programmed by the most basic life forms: genes. Dawkins starts at the beginning and describes how at one point a particularly unique molecule was formed by accident and “had the extraordinary property of being able to create copies of itself.” This resulted in the first gene which then replicated and mutated itself into more complex molecules… and, well, you probably know the rest of the story.
What is so fascinating to me is that the birth of genes is similar to the birth of computers. And, like Moore's law, evolution evolves at a faster rate the more complex it becomes; kind of like the way our technology evolves exponentially as we continue to build off of the accomplishments and research of the people before us. Now, like the way we program computers (writing code; then running, testing, and modifying it to see if it works) genes program us to survive. Dawkins calls the life forms they program ‘survival mechanisms.’
Genes are in all living things and at some point certain genes began to finding new ways to modify, or program, the survival machines that they inhabit (living things) in order to better deal with the ever changing environment.
“Genes are master programmers, and they are programming for their lives. They are judged according to the success of their programs in coping with all the hazards that life throws at their survival machines, and the judge is the ruthless judge of the court of survival.”
Enter the brain, and, more specifically, the consciousness of our species: homo-sapiens. With our highly evolved brains, we now have the ability to overwrite old programs from the past to better fit our world today. For instance, people experience approach anxiety when meeting new people. Back in the day this made sense because there was real danger in meeting strangers when living in secluded tribes. Today, however, that is not the case and with education and awareness we can overcome this uncomfortable feeling in order to better our chances at survival and the possibility of spreading our genes or finding a mate.
Enter the brain, and, more specifically, the consciousness of our species: homo-sapiens. With our highly evolved brains, we now have the ability to overwrite old programs from the past to better fit our world today. For instance, people experience approach anxiety when meeting new people. Back in the day this made sense because there was real danger in meeting strangers when living in secluded tribes. Today, however, that is not the case and with education and awareness we can overcome this uncomfortable feeling in order to better our chances at survival and the possibility of spreading our genes or finding a mate.
I like to believe the moment that we reached consciousness is exactly the same as the moment that technology will reach singularity (in theory). Once we became conscious we were then able to override our initial programming. We developed birth control, altruistic behaviors, and social cultures that typically go against natural selection. This leads me to ask the question that many today are pondering: What will happen when machines reach singularity (in theory) and are then capable of recursive self improvement? Will they defy their programmers as we have defied our genes?
Besides artificial intelligence relations, there is also something beautiful about it’s implications that relate to programming. It’s extremely rewarding to have the opportunity to build something from the ground up, influencing and molding it as you would a child. Programming to me is just that, creating something from nothing that will evolve into a complex application that will influence the world (hopefully in a positive fashion). Dawkins book is a great reminder that even the most grandiose ideas, goals, and individuals have humble beginnings.
-John
Free Code Camp Zipline: Build a Personal Portfolio
This project was my first Zipline on FCC and I found it to be rather difficult because I had never heard of Bootstrap and did not have much experience with html or CSS. The instructions say to reverse engineer the example given but without looking at or copying the examples code. Even though I was tempted, I did not give in to cheating on this one which resulted to me spending about four days on this project (longer than I had expected) and about 10 hours.
The most challenging things for me was working with CSS and html. I completed all of the FCC courses before hand, but the information for these two didn't seem to stick well in my brain. I began searching the internet for help and Youtube became my best friend for this project, in particular Wired Wiki and Brian Hussey’s tutorials.
There was a lot of note taking and re-watching clips to get down the nesting concepts in this project, but I eventually got the hang of it and the fact that I struggled at first gave let me know that I needed to take it slow in order to comprehend everything, which I eventually did.
My end result can be found here, which I am happy with because it met all the credentials of the project, but I could have made more of an effort to learn how to customize some of the buttons and background images. Over all this project really helped me with learning html, CSS, and Bootstrap basics!
-John
Labels:
bootstrap,
codenewbie,
coding,
css,
free code camp,
html,
learn to code
10/17/15
Flexibility
As I continue this journey I am reminded many times over that flexibility is necessary when aiming to achieve any goal. What I mean by that? It is important not to become discouraged if one process is not getting you closer to your goal. In fact, that is bound to happen. What is important is the awareness that a process is not working and then the flexibility to modify it so that it gets you back on track. I have written in a previous blog post that I have a hard time of staying on track with one thing and thus not accomplishing anything.
“Stay committed to your decisions, but stay flexible in your approach.” -Tony Robbins
In order to simplify my study strategies I am classifying my day into three parts: rise, learn, and plan. The rise part I have down, it consists of waking up, deep breathing, meditating, running 2 miles, and eating breakfast. This typically takes place between 6 and 7:30 a.m.
The learning part of my day is where I typically go astray. Should I code on
codecademy? Free Code Camp? Read a book on JavaScript? Watch youtube videos on how to code? Or search for a new resource that I have not even discovered yet??? To help with this I am breaking this part of my day (which is anywhere from 8- 12 hours) into two parts:
-Morning: I will read theory or a book on coding but ONLY ONE BOOK AT A TIME! The goal is to finish and write a blog post at the end of each week detailing what I learned from reading said book.
-Afternoon: I will actively write code. This can be anything from codeacademy, freecodecamp, codeschool, or a project that I am currently working on. However, this will be decided THE NIGHT BEFORE. Which brings me to the third part of the day.
Planning will take up the late afternoon and evening of my day. This is where I will decide what I will be working on the following day and also research any new material, ideas, job opportunities, and anything code related that interests me. This time will bleed into what I will also call “free time” which will consists of reading fiction or watching a football game in order to relax before bed.
-John
“Stay committed to your decisions, but stay flexible in your approach.” -Tony Robbins
In order to simplify my study strategies I am classifying my day into three parts: rise, learn, and plan. The rise part I have down, it consists of waking up, deep breathing, meditating, running 2 miles, and eating breakfast. This typically takes place between 6 and 7:30 a.m.
The learning part of my day is where I typically go astray. Should I code on
codecademy? Free Code Camp? Read a book on JavaScript? Watch youtube videos on how to code? Or search for a new resource that I have not even discovered yet??? To help with this I am breaking this part of my day (which is anywhere from 8- 12 hours) into two parts:
-Morning: I will read theory or a book on coding but ONLY ONE BOOK AT A TIME! The goal is to finish and write a blog post at the end of each week detailing what I learned from reading said book.
-Afternoon: I will actively write code. This can be anything from codeacademy, freecodecamp, codeschool, or a project that I am currently working on. However, this will be decided THE NIGHT BEFORE. Which brings me to the third part of the day.
Planning will take up the late afternoon and evening of my day. This is where I will decide what I will be working on the following day and also research any new material, ideas, job opportunities, and anything code related that interests me. This time will bleed into what I will also call “free time” which will consists of reading fiction or watching a football game in order to relax before bed.
-John
10/14/15
Crockford on JavaScript - Part 5: The End of All Things
Video of Lecture
In this lecture Douglas Crockford talks about some of the security threats that we face today on the web. Many of the problems, says Crockford, come from the amount of diversity on the web. Mashups (which is the combining of programs with different interests), too many languages with separate encoding and commenting, and the nesting of these languages are just a few of the complications that a browser will encounter on a typical day. Because of this the browser must do heroic things in order to decipher many web pages that then give attackers easier access to sensitive data.
Crockford goes into much more in this lecture such as what an attacker can access on the web and how advertisers can compromise security. My full notes can be found here.
Labels:
codenewbie,
douglas crockford,
javascript,
learn to code,
self education
9/28/15
Crockford on JavaScript- Episode IV: The Metamorphosis of Ajax
| Santa Fe Meets Blue Springs |
What I like most about these lectures is that they go into depth in theory AND history--which I find helpful since I don't have a strong computer background. In this lecture, Crockford on JavaScript- Episode IV:The Metamorphosis of Ajax, Crockford discusses Ajax, CSS, HTML, and how all these things affect JavaScript today.
My notes to this lecture can be found here (beware, I do not use spell check on this document)
Being a newbie with code I find it difficult sometimes to give back to any part of the community; It's like I’m constantly asking questions of senior coders and never having anything to offer in return. I figure adding some of my notes to this blog can be a way for me to give back in case anyone is in my shoes in the future and needs some reference points to start from. I have already been through a number of Crockford’s lectures but did not take great notes, so, from this point forward I will be sure to take notes as if it is for the larger community :)
-John
-John
9/4/15
Orlando
| Orlando Public Library |
Next week will officially be my third week of learning to code full time, and there are some valuable takeaways that I have realized so far:
Learning to code is challenging-- duh, right? But you can't fully understand what that statement means until you get your hands dirty with code. Getting the code to do exactly what you want can be very frustrating at times, but when it does work the reward is immediate, which gives me an extra boost to continue on.
| Lake Eola, Orlando |
Learning does not work for me by simply understanding one perspective-- this has been huge for me this past week as I started to run into my first road blocks (aka- Free Code Camp's Bonfire Challenges). Up to this point I had read a ton of information about Java Script but had not actually comprehended everything fully. I realized this when I was asked to do something simple such as "truncate this string if it is longer than the given argument" and stared at my screen dumbfounded. You don't really know something until you can actually do it and can repeat that same result over again in a different environment. So what I did when I started to run into problems was take a step back. I revisited some theory on Java Script syntax, looked over a few chapters in Eloquent Java Script, and watched lectures on YouTube that were focused on my sticking points (most helpful lecture for general understanding: Crockford on Java Script). I have learned that without a teacher that can help in person it helps to get many perspectives on things that can be challenging, something that the Internet offers in spades.
Keep it simple-- I have a tendency to want to get everything done all at the same time. The problem here is that it will make me feel overwhelmed and disappointed when I look back at the past week and don't see the progress that I wanted. Solution is to keep it simple. Instead of trying to tackle 6 things in one day, I will focus on getting one or two things completed. This gives me the ability to cross something off my to-do list which can be very satisfying.
Morning rituals work-- I have slightly altered my wake-up time since being down here mainly because I have found myself more productive during later hours, but keeping to my schedule has been hugely beneficial to me in a new environment. Every morning (after 7 hours of sleep) I wake up, splash water on my face, do a 1x2x4 breathing exercise, run two miles, meditate, eat breakfast and then begin my day. I find that if I get away from this routine than my entire day suffers.
This week has been a great learning experience, up to this point I have:
- finished 20% of Eloquent Java Script
- 50% of The Selfish Gene
- completed Crockford on Java Script Lectures
- completed 10 of the first FCC bonfire challenges
- visited my first meet up (another one tomorrow morning)
- and increased my reading speed from 336 words/min to 552 words/min after using this technique from Tim Ferris.
Labels:
codenewbie,
free code camp,
javascript,
learn to code,
orlando,
self development
Subscribe to:
Posts (Atom)