Skip to content

Instantly share code, notes, and snippets.

@Rhoxio
Created December 16, 2019 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rhoxio/7de66f79a6f197e03ac23321c7e72637 to your computer and use it in GitHub Desktop.
Save Rhoxio/7de66f79a6f197e03ac23321c7e72637 to your computer and use it in GitHub Desktop.

Introduction

This file is meant to hold links and information that might be useful in your post-bootcamp job search. I would highly recommend doing the suggested exercises - they will progressively get more challenging, but it's nothing that's out of your reach if you understand the previous section in the list! This stuff is absolutely at the core of being able to work as a web developer. Give it a shot!

Rails is awesome, but knowing how Ruby works is a much more valuable usage of your time right now. This is how you are going to be able to pass technical interviews and provide value almost immediately (one of the most enticing things for any company looking to hire juniors) at your job-to-be. This is also a precursor to being able to learn other languages, as enough mastery of the first makes a huge difference in the long run as you can more easily draw parallels and get functionality rolling.

The challenges are meant to be hard and require you to do your own research outside of the links provided. Use your past exercises from the course as a reference if you need to!

This doesn't mean that you should meter yourself by your progress through this - you should really be looking at your confidence level with each of the sections and asking yourself if you want to dive deeper than simple implementation of each thing. If you want to build a chat app, go for it! If web scraping for a better price strikes your fancy, follow that inclination until you are satisfied. Follow your curiosity, and it will take you much farther than any structure ever could.

With that in mind, let's get started.

General Tips

Logging

Remember to log things out to the console as you go. You'll find it gives you a visual medium in which you can interact with it instead of keeping it all in your head. You can 'p' almost anything out, so just try it on stuff!

name = "Kevin"
p name
#=> "Kevin"

Use this to work through the steps of solving a problem one at a time. For example, if I am trying to see what is inside of an array I might do:

# Creating an array of random numbers from 1 to 100
numbers = (1..100).to_a.shuffle!
numbers.each do |number|
	p number
end

# Or with a one-line twist...
numbers.each {|number| p number }

These will output the elements in 'numbers' one at a time so you can see them in the console.

Working Environment

Get yourself a proper desk and chair. They make a huge difference in the long run, and your back will thank you. This is doubly true if you are thinking about pursuing remote work.

In order to get the most out of your time, I would highly recommend giving yourself long periods with as little interruption as possible.

Take 4 hour blocks at a time and strictly dedicate it to coding if you'd like to improve your understanding quickly. I would recommend loosely breaking it into 1 hour blocks - 50 minutes on and 10 off.

If you've heard this kind of thing somewhere before, it's a slightly amended version of the Pomadoro Technique. I have found it to be useful for myself personally, but you may need to make adjustments for yourself and your schedule.

You should take a break when:

  • You are feeling extremely frustrated.
  • It's been over 50 minutes.

That's it. Super simple to follow and manage.

Ruby Revisited

Syntax Refresher

It is a good idea to freshen up on how basic Ruby syntax and operations work. This is a good article to jog your memory about some of the things you can do: https://medium.com/the-renaissance-developer/ruby-101-the-basics-f10961f990ac

Dealing with Errors

I'm sure you have run into some bugs when trying out the code above - so it would really help to know how to read error messages more efficiently. It takes practice to be able to quickly debug issues, so don't feel discouraged if you can't decipher them naturally yet. This article is a good overview of the most common ones you may run in to: https://learn.co/lessons/ruby-lecture-reading-error-messages In lieu of following their instructions, you should be able to just open up irb or make a new ruby file and run it to see the error outputs. You can do the testing stuff if you want, but it's not the main focus of this exercise. The beginning of the video has a good directory structure for ruby projects in general.

Data Structures

Next, you should remind yourself about what data structures are available to you in Ruby. You should be comfortable setting up Arrays and Hashes, as you will be using them all the time in web development. Let me reiterate: All. The. Time. I would suggest playing with some of the code in this article and making your own sets of data instead of copy-pasting: https://medium.com/the-renaissance-developer/ruby-101-data-structures-7705d82ec1

Strings
# String
name = "Thor"
name.last #=> "r"
name.first #=> "T"
name.split #=> ["T", "h", "o", "r"]
name.split.reverse #=> ["r", "o", "h", "T"]
name.split.reverse.join #=> "rohT"
Integers
# Integer
age = 29

age += 1
p age #=> 30

age = age / 2
p age #=> 15
Arrays
# Array
animals = ["dog" "cat", "rat"]
# Assign Value in Array
animals[0] = "doggo"
p animals #=> ["doggo" "cat", "rat", "tiger"]

# Pushing
animals << "whale"
p animals #=> ["doggo" "cat", "rat", "tiger", "whale"]
Hashes
# Hash
book = {
	title: "Moby Dick",
	author: "Herman Melville",
	pages: 758
}

# Accessing Values
book[:title] #=> "Moby Dick"

# Creating New Kay-Value Pairs
book[:difficulty] = :challenging
p book[:difficulty] #=> :challenging

# Setting new values
book[:title] = "The Silmarillion"
book[:pages] = 856
book[:author] = "J.R.R. Tolkien"

p book #=> {title:"The Silmarillion", author:"J.R.R. Tolkien", pages: 856, difficulty: :challenging}
Iteration and Handling Data

Check out the Ruby enumerable module and try to figure out a use for each of the methods. Most of the time, they will work on arrays or hashes. Some of them may seem really confusing (because they are - trust me), so don't feel ashamed to skip around and try things that look easy or cool. The idea is to get you used to thinking about and executing against the types of operations you can do on sets of data: https://ruby-doc.org/core-2.6.5/Enumerable.html The more you understand about this section, the faster you'll find yourself being able to build functionality in your apps.

animals = ["dog", "cat", "rat", "bat"]

animals.map do |animal|
	# Changing the string for each....
	animal = animal.capitalize + " is an Animal"
end
p animals #=> ["Dog is an Animal", "Cat is an Animal", "Rat is an Animal", "Bat is an Animal"]
Object Oriented Programming

I would then suggest creating an analogue of a real-life object that interacts with another object in Ruby. A familiar example would be something like the 'Animal that can Eat' found here: https://github.com/Rhoxio/teaching-materials-2019/blob/master/object_oriented/animal_that_can_eat.rb Give it some advanced functionality - it should have at least one array and hash as an instance variable that you use fairly regularly. Methods that group together instance variables like #stats in the Animal class or #nutrition in Food work, too.

Data Persistence

Make sure you understand how to read and write to files using Ruby. This is a key skill and is considered basic knowledge when it comes to job hunting, so make sure you understand how to read, write, and append to files. This is the base concept of how databases work (reading and writing to a file in an efficient and structured manner): https://www.rubyguides.com/2015/05/working-with-files-ruby/

Saving, Reading, and Initializing Data in Ruby

Using your custom class (Animal & Food in my case) you set up earlier, you should practice saving certain data to a JSON file as a sort of pseudo-database. You will need to implement #save functionality, and should be able to #load all of the saved models with the correct data in them. You can convert Ruby Hashes (you will need to pull relevant data from the model itself) into JSON format, which can be saved and pulled from a file and parsed immediately - here's an example: https://stackoverflow.com/questions/3183786/how-to-convert-a-ruby-hash-object-to-json #to_json will return a string, so it may just be a matter of writing that string directly to a file to mirror #save functionality in Rails.

Understanding Query Parameters in URLs

Before diving further into basic web functionality, it is important to understand query parameters and their function in in the URL. Read through this first - I'm sure you've seen these in URLs before on random websites on the internet: https://en.wikipedia.org/wiki/Query_string Essentially, they are a way to pass data to some place on the internet so the server on the other end can do something with it. For example, you can use Google by changing the 'q' (query) parameter right in its URL! Searching for dogs on Google: https://www.google.com/search?q=dogs Searching for Pancakes on Google: https://www.google.com/search?q=pancake

Using an API

It is crucial that you have an understanding of how API services work, as you will not only be consuming them on a daily basis as a developer, but lays the foundation for your understanding of how data tends to get around the internet. So, to gain an understanding of how they work, it is best to dive right in to one that you might like to use! Check out this Reddit thread for some inspiration: https://www.reddit.com/r/webdev/comments/3wrswc/what_are_some_fun_apis_to_play_with/

My personal favorite is this Pokemon API: https://pokeapi.co/

Once you have one chosen, make sure you get an API key from them. You will then need to start making some requests! You can do this with a tool like Postman, or using the HTTParty gem in Ruby. Some good examples can be found here: https://github.com/jnunemaker/httparty/tree/master/examples

--

If you are able to complete the exercises above, I would say you are good to start working on Rails apps again!

However... I really want to stress how important it is to have a certain level of confidence and efficacy in one language (Javascript being the only exception, as you need it for the front-end) as this builds a baseline for everything else. I would recommend you start brainstorming a Rails app you'd like to build as a post-bootcamp stretch challenge. If you understand the information given above, you will find that building functionality is exponentially easier and your app will have the capacity to be much more than just a set of webpages.

Choose an API service or find some data you'd like to consume on the internet, and start thinking of an app idea. Do something that's fun or you're passionate about! It makes learning a lot more fun if you can see yourself using whatever you're going to build, too.

Rails

Now, it's time to set up a professional-grade web app. In these sections, you'll find information on setting up Redis, rendering partials, using Websockets, and much more. This is all more advanced functionality, but if you are using an API you should have no issues getting of data to use here.

Most of it is configuration when it comes down to it. I found most of the articles covered as much as you'd need to know if you have an understanding of the previous section.

Be sure to test your code! This is very important, and will be something that potential employers will look for in your projects. I would look at them as the first thing when assessing competency - so make sure you have tests written and passing.

Partials and Rendering

Rails allows you to do a lot more than just render single pages from one file - there is a whole ecosystem of including HTML in multiple places under many circumstances. If you have a sidebar on some pages but not others, partials make it so you don't have to 'copy-paste them all over the place' as well as provides a layer of organization for such elements. To be able to navigate this landscape, I would suggest reading through and following the examples laid out in this article in your new Rails app. You can always take it out later if you want to: https://www.rubyguides.com/2019/04/rails-render/

Websockets and Redis

Sockets are a way to make it so your front-end can openly communicate with your back-end Ruby code to keep data in all connected clients (people in a chatroom, for example) up-to-date. You will run into the need for a Redis server, though. Redis is a lightweight key/value storage system (think JSON data) that is lightning fast and used in almost every professional Rails project. Below is a good example of a basic Rails chat app that comes with some decent initial styling. I would recommend not copy-pasting this all in and try to understand what's actually going on - you will pick up some cool tricks naturally if you do! https://iridakos.com/programming/2019/04/04/creating-chat-application-rails-websockets

Sidekiq

In order to keep a clean and fluid user experience or run tasks to grab a lot of data, it is sometimes necessary to delegate tasks out to workers. Since Ruby executes from top to bottom, you wouldn't want your page to hang for 30 seconds while a PDF document renders.

These are some things that Sidekiq does for us, and I have used it in the past for things like document rendering, email campaigns, web scraping, api data-mining, web crawling... the list goes on. What it allows you to do is run tasks outside of the server, essentially, meaning you don't have to wait for other Ruby code to be run to run the code that Sidekiq is using. I would recommend understanding how this works and writing some code to do something useful. Think about web scraping, api querying, or sending emails on a schedule. You will need Redis to get this to work! https://github.com/mperham/sidekiq/wiki/Getting-Started After, check this out: https://josh.works/sidekiq-and-background-jobs-in-rails-for-beginners And then this: https://medium.com/@t2013anurag/configuring-rails-5-with-sidekiq-adapter-and-redis-queues-e32c7050d204

Web Scraping with Nokogiri

Web scraping is similar to an API call, but you are asking for HTML from a particular webpage and finding it somewhere in there instead. This is useful if you are wanting to get information not present in a structured API. I've used this to grab information from sites like Metasrc or . Choose a webpage you like and try grabbing some data from it: https://dev.to/kreopelle/nokogiri-scraping-walkthrough-alk You may want to do this in a separate Ruby file and not in your app.

React with Rails

You should familiarize yourself with React and how it works. This is the most popular front-end framework currently and will give you a better idea of how front-end frameworks actually work. I would make an app separate from your other project for this - unless you really want to integrate it! https://www.sitepoint.com/react-rails-5-1/

After....

If you have completed the exercises above and have built something you feel proud of, you should have no issue with finding a job, building an app for your business, or just generally doing anything you'd like to! A great thing about programming is that as soon as you get past the initial learning stages, the sky really does become the limit.

Wrap-Up

There are plenty of cool resources out there for you to use to keep learning! Don't be afraid to Google around. Log code out to the console, and invest time in learning how the solution you pulled from Stack Overflow works at least on a basic level. Understand how to use it and what it is doing, and move on. You are looking for a breadth of knowledge initially, not to deep-dive into every method and class.

I would also like to impress upon you what exactly it is you're going to be doing if you are wanting to find a job in this field. There are some harsh realities, but I promise you that the payoff is there if you apply yourself and keep working to better your skills:

First - Understand that this is a technical field that sometimes requires long hours of mentally taxing work. This seems obvious, but I mention it because this profession can be surprisingly draining when you are trying to both learn and be productive at a new job. Understand that you will never know it all - and that's perfectly fine. Do everything one step at a time, and you'll eventually get the problem solved! Take care of your body, too. Eat good wholesome food, drink plenty of water, and remember that working out a few times a week is the best way to stave off the side effects of sitting down for long periods of time.

Next - Work on improving your understanding of how code works and why certain solutions are better than others, and you'll soon find that syntax means very little and expressing ideas efficiently and effectively becomes paramount. Syntax is easy and a means to an end - the code design decisions are of much more importance once you understand how to manipulate data.

Then - Learn a new language (I would suggest Golang or Java, as you should know how statically-typed languages work). Keep building your skills, and it will pay dividends of the greatest kind when it comes to coding efficacy.

Getting frustrated is a normal part of the process - especially in the beginning. There will be times where you simply can not figure out what is going wrong, and the biggest piece of advice I would give is to comment things out one line at a time in the problem area and diagnosing it that way. If you know the problem piece of code by line, Google around for alternative solutions. You should get good at reading error messages quickly if you've gone over the content above, so realize that it will pass and you'll come up with a solution eventually. Give yourself breaks, and you'll be constantly surprised at what floats to the top.

Code is challenging, but it's not hard. If you find yourself drawing blanks, it just means you have a gap in your knowledge that needs to be filled before moving on. It doesn't mean you are stupid or bad at it, just that you don't know that answer yet. If you can put it to words and can find a resource to help you, the spooky fog of unknowing will dissipate and you'll realize that it was just because you hadn't taken the time to walk through it to the light, no matter how faint, at the center.

Most importantly though, remember to have fun with it all. Although code seems really technical, it is much more of a creative process than anything. You have the ability to model any reality in any context with code, and the only limiting factors are time and understanding. I personally treat it like writing, but the framing is less important than the end-result and the dividends it brings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment