Skip to content

Instantly share code, notes, and snippets.

@bdougie
Last active August 29, 2015 14:00
Show Gist options
  • Save bdougie/11261930 to your computer and use it in GitHub Desktop.
Save bdougie/11261930 to your computer and use it in GitHub Desktop.
Ruby Newbie Odin Gist

#Getting Started Guide

I have outlined a few things to do to get started in Ruby.

  1. Sign up for the Odin Project, Join the Odin Google Group

  2. Read through section 1 of Web 101

  3. Install Ruby if you havent already

  4. Watch this video on How to Learn a language fast

  5. More stuff to do: some of you might have completed some of all of these. If you havent try to start Chris Pine's or Codecademy. Ruby Monk is great but a lot more info a newbie.


Begin Chris Pine's [Learn to Program](https://pine.fm/LearnToProgram/) chapter 1-10 or 
[Ruby Monk Primer](http://rubymonk.com/learning/books/1-ruby-primer) or 
[Codecademy "Ruby"](http://www.codecademy.com/tracks/ruby). 
  1. Ask a question if you are stuck. Use the Ruby Newbie Community or The Odin Project. Everyone is nice and helpful.

Please fill free to reach out if you have any questions/issues installing Ruby or getting your environment set up.

#Week 0 Transcript

My Brief Intro:

I am Brian and I have been learning Ruby/Rails specifically for about 7 months. My main focus has primarily been Rails after completing the 12 week online bootcamp, Bloc.io where I learned how to build working Rails apps start to finish. At the moment I am still at my day job but coding at night, and planning on making the switch into a dev job soon.

I have been on a few programming interviews but find that one, a lot of people looking for people with the basic programmign experience in problem solving. I was recently given the task of building Conway's Game of Life which I could not complete in less than a week due to my lack of practice in basic Ruby.

Ruby Intro:

Ruby is a simple, yet powerful, object-oriented programming language. It was developed in the mid-nineties by Yukihiro ‘Matz’ Matsumoto with the aim of making programming more enjoyable and productive. Ruby always had a devoted following in Japan, along with a small but loyal following in the West. After David Heinemeier Hansson(DHH) released the Ruby on Rails web framework in 2005, Ruby’s popularity soared almost overnight.

One of the key priciples of Ruby is that every part of the language is an object. An object in programming is something that has its own properties and actions. This might not mean much at the moment, but it is something that we will keep coming back to as we delve deeper into learning about the language.link to source: sitepoint

Odin Intro:

The Odin project is a tool created for individuals like us to learn the skills of web development without needing to do it on our own. There is a multitude of information out oon the web to help get us up to web development speed and it is all neatly organized in this single source. The study groups, such as this one, is in place to help provide free support to get hurdles in our learning.

The project is entriely open sourced and available for you to contribute. Daily SCRUMS are held and open for anyone to attend. The curriculum itself is a living a document and able to be updated with new material and suggestions by the students. So if you see a typo or have a suggestion for new material, please feel free to bring it foward.

####Objectives

  • To provide value above and beyond what you'd get if you were to go through the material purely on your own. There is opportunity to leverage each other for pairing, answering questions, and venting!

  • My recommendation for pair programming would be Screenhero, but it is not on Linux and it looks like a lot of us are on Linux. I do recommend become familiar with Google Hangouts if you are not already and practice this week with by pairing with a group, preferably 2 or more (that's a group). Also become familiar with the pair program methods.

  • Use the Google Odin Community page to get in touch with other Odinators! If it gets too crazy I do have a Ruby Newbies Community where I will try throw some problems out there to solve, most likely Koan or Kata but more on that in a future studygroup. For the next 10 weeks most info will be posted and available on both groups.

  • Do no suffer in silence.

  • Lets break the ice and set our pairing sessions to be sent to Ruby Newbie group. Create a hangout where others in the gorup can join. We can get good at this together faster. I'm serious set a time and people will join, step out of your element and let try it out. I come from a different industry where netoworking is higly important to make connections - If Steve Jobs was not introduced to Steve Wozniak we would not have Apple.

####Expectations from the group

  • I will unfortunately not be reading the entirety of Odin Curriculum to you in these meetings and you will be responsible to read through it on your own prior to each week.

  • I will be here to facillitate the discussion and assist in getting the group. Please assist by providing insights and new discoveries to our meetings. These could be tools, blog post, current events in Ruby, etc..

  • There will be a time commintment of at least 6 hours, but 12-15 is recommended. I personally recommend not to study on your own longer 3 hours in one sitting. I recommend toggl to track your time, it might come in handy in a future interview.

  • We are going to meet weekly to go over efforts of the previous week, and discuss Ruby in greater detail as we breeze through the curriculum. Please post questions on the Ruby Newbie group during the week so the group can assist. Set your limit to solving an issue or problem on your own to one hour, anytime after that reach out for help from the group. We are here to assist, do NOT struggle in silence.

  • This Odin Group will cover a lot of material, so do not become discourage if you do not complete all of the workload at the same pace as everyone else. The important part is that you are putting in the time, We will move at a steady pace but a lot of info will be repeated. Stay connected and attend the meetings and you should have no problem.

####Rough Schedule

Each step in the Ruby curriculum will take 1 week, but some will be quicker. The first 10 weeks looks like it will take us through the Ruby on theWeb section. Depending on the group engaement I would like to get through the Testing section, but if need we might do a second cohort at the end of the summer.

####Extra Stuff

*All notes and schedules are subject to change

#Week 1 Transcript

####Intro: Sign Up for the groups:Ruby Newbies Odin Community Sign up for the Odin Project

####Everything is an object:

"Everything in Ruby is an Object" is something you'll hear rather frequently. "Pretty much everything else is a method" could also be said. In Ruby is an Object, every object has a class, and being a part of that class gives the object lots of cool methods that it can use to ask questions or do things. Being incredibly object-oriented gives Ruby lots of power and makes your life easier.

cited from Erik's blog

####Car example A car is an object. Inside the car there are many objects and within the car there are even more objects and those objects can do things or have "methods". Once you get the idea Object Oriented Programming it will make it easier to approach problem solving.

class Car
	def initialize # method
		@engine = Engine.new
	    @wheels = 4.times.map { Wheel.new }
	end
end

The class create the object and the code lives inside. Each part of the car can be identified as a variable or in a method. There is indeed. If you are curious to find out on what the Ruby best practices are, check out Unoffical Ruby Style Guide

For more on this there is a video of last years Rubyconf in Miami. Jim Weirich gave his talk which that goes more into objects. Watch the first 15 minutes.

####Procedural:

How do you approach solving a problem in Ruby?: There are many ways to approach a problem in Ruby and it's due to the flexibilty in writing Ruby code. With Python and Javascript there are colons and special indentation needed in order to compile the code without error. Compare Python to Ruby?

What are your steps?

  1. Write Pseudo
  2. Open IRB
  3. Test first

My recommendation is for planning and explore the Ruby documentation or Stack Overflow if you get stuck. Also reach out to the group if you find yourself spending too much time on one problem.

I also begin with writing Pseudo code to help my brain understand which way to begin. I am little scattered in my approach, and since I still learning I might use certain shortcuts that I not aware of previously.

For example: I completed the first 5 exercises in the Project Euler set and solved exercise 1 by placing everything in a class and methods, everything was straight forward. Then when I completed exercise 5, I was able to completed only using variabls and the lcm method, which I only found in the Ruby Doc after much googling and general research on Least Common Multiples.

####Tools and Tips:

Ruby Koans - A great tool to get actual practice simple problem solving in Ruby. How to Learn a language fast - I already recommend this but want to mention it again, but its a video that explains the best practice towards learning a new language.

####Assignment for the week:

  1. Complete step 1 & 2 of the Odin Ruby Curriculum. This will prepare us to complete out first project together next week.
  2. Try out Ruby Koans (Download it)

#Week 2 Transcript

####Intro: Sign Up for the groups:Ruby Newbies Odin Community Sign up for the Odin Project

####The Assignment - Building Blocks

Each project should be contain in its seperate file and submitted using the pull request method. This is god practice and an easy way to submit to an open source project. There are also options to add your link directly within the github fork.

Returns a new, empty hash. If this hash is subsequently accessed by a key that doesn’t correspond to a hash entry, the value returned depends on the style of new used to create the hash. In the first form, the access returns nil. If obj is specified, this single object will be used for all default values. If a block is specified, it will be called with the hash object and the key, and should return the default value. It is the block’s responsibility to store the value in the hash if required.

h = Hash.new("Go Fish")
h["a"] = 100
h["b"] = 200
h["a"]           #=> 100
h["c"]           #=> "Go Fish"

####REGEX

Please take the time to complete this REGEX tutorial

For more info, please check out this changelog article and watch the video: GoGaRuCo 2013 - Beneath the Surface: Regular Expressions

String.=~(/^[\w]/) returns the starting position of the first matched word or nil if no match was found:

/a/           character 'a' 
/\//          character '/' (/\?*+{[.|()^$ need to be escaped with \)
/./           any character (including newline for /.../m)

/a?/          0..1 'a'
/a*/          0..n 'a'  
/a+/          1..n 'a'   
/a{2,7}/      2..7 'a'    
/a{2,}/       2..n 'a'    
/a{,7}/       0..7 'a'    

/a?bc?/       'b' or 'ab' or 'bc' or 'abc'
/a|bc/        'a' or 'bc'
/(a|b)c/      'ac' or 'bc'

/[abc]/       a or b or c
/[^abc]/      any character except a or b or c
/[a-cF-H]/    a or b or c or F or G or H

/\d/          any digit [0-9]
/\w/          any letters, numbers or underscores [a-zA-Z0-9_]
/\s/          any whitespace character (including newline for /.../m)

/\D/          any character except digits
/\W/          any character except letters, numbers or underscores
/\S/          any character except whitespace

/^abc/        abc after line start
/abc$/        abc before line end

####Assignment for the week: Complete the Building Block assignment and begin rebing readin through Advanced Building Blocks

#Week 3 Transcript

####Whats is you Ruby?

First, what is "MRI"

To many, 'MRI' is Ruby -- it stands for "Matz's Ruby Implementation", and is the standard version of Ruby. It's written in C, and is the only version that the Ruby founder Matz works on.

When Ruby "2.0" is released, that means MRI. Sometimes, people call it "c-ruby", but it's all the same thing. ProTip: If someone is talking about Ruby, it's MRI. If it's something else, they'll let you know.

JRuby

The J in JRuby standard for Java; JRuby runs on the JVM (java virtual machine), and can interface and run any language on the JVM (like Java or Clojure). JRuby's main benefit is the JVM, which means it can take full advantage of millions of dollars of investments making the JVM run in parallel and on Windows, Unix, and Linux machines.

With JRuby, you can use more than one core on your machine (multi-threading). Right now, MRI cannot do CPU intensive multi-threading. JRuby also runs nearly all Ruby code and Gems -- the exception being any c-extensions (calling out to pure c-code), and any UNIX specific commands like Forking.

But, JRuby is making a huge resurgence, and is definitely a project to watch and take part of. With the Ruby version managers, using JRuby is the same as switching to version 1.9.3 -- very exciting times! It's also very easy to run JRuby on Heroku.

Rubinius

Rubinius started as a way to write Ruby in Ruby (since MRI is written in C). It ended up as a powerful virtual machine with fast garbage collection and multi-threaded capabilities that rival JRuby.

Rubinius announced in its version 2.0 launch that it would focus on writing fast, concurrent web applications. This focus could make Rubinius THE variety to use when creating APIs that need to be 10ms-50ms fast.

####More Reading

It is highly recommend to read all of theRuby Explained. Erik has doen a great job explaining a lot of Ruby in plain english.

Review Problem Set

My answer is here

If you would like to add a solution to one of the projects, first save it in your own repository and then just make a link to it in the appropriate project's section. Be sure to give your partner acknowledgement if you have one and they want it.

If you're unfamiliar with the Markdown (.md) syntax that's used in these files, it's really straightforward and there's a great guide for it from Daring Fireball here.

####Assignment for the week: Complete the Advanced Building Blocks assignment. Also begin reading the Object Oriented Programming section.

#Week 4 Transcript

####Enumerables

The Enumerable mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method each, which yields successive members of the collection. If Enumerable#max, #min, or #sort is used, the objects in the collection must also implement a meaningful <=> operator, as these methods rely on an ordering between members of the collection.

Some more info on Enumerables

Procs, Lambdas, and Blocks defined

This section is by far a lot of advanced information and there is no pressure to learn all of the information. At the very least skim through most, because these concepts will come up in the next section and need to be referred to.

####Assignment for the week: Start the OOP section this week.

*also listend to this week's Thoughtbot Podcast where Aaron Patterson explains his troubles as a Java developer and finally switching to Ruby code was solved in less lines of code.

#Week 5 Transcript

When you start solving larger problems organization is key. You don't want 100 different methods and variables that do overlapping things. If you're trying to keep track of data (like a bunch of bad guys in a game you're building), you want to do so in the most organized way possible so you can recycle methods and only need to update that data in one place at a time. Erik's Ruby Explained.

Classes are very usefule when writing Obect Oriented Code, but as mentioned organziation is the key to the proper use of OOP.

During this section a book is introduced, Practical Object-Oriented Design in Ruby: An Agile Primer, this is a book written by Sandi Metz and inroduces the concept of Object Orient Desig(OOD). OOD is the thought of creating objects with only one purpose, for example within the in the "Door" class, there is one method to open the door and another to look through the peephole.

To find out more on this book and Sand Metz, check out the Ruby Rougues #87.

Some controversy comes with OOD, and some disagree with the limited approach on method and dependeices.

What are you thoughts on the issues?

Check out this link on learning on a new language.

####Assignment for the week: Finish the OOP section this week. Start the next two sections, Files and Ruby Online

#Week 6 Transcript

Lets review some code. Reading code seems to be a sneglected skill of mine, which is why I will be focusing on reading through code more in these video sessions, I also have less time these days to complete each project ;) I am extending this recommendation of reading the code of others as a great exercise to increase your skill. Just as if you wanted to be good at a sport you woudl view the skill of others, you will need to do the same in programming.

Watch this video on reading code.

Join the Code Newbie Community

This week's assigment was to complete the File/IO section.

#Week 7 Transcript

This week's assignment was to cover the Ruby on the Web section. This information is very good and neccessary to understand the process of getting your code into a browser. Some of the information is trivial but could come into handy while workign with API's.

This section is a great intro to how Rails works, if you already have experience with it.

#Week 8 Transcript

####Algorithms

Algorithms are programs built to solve problems.If you are using Rails, you are using already made algorithms from others.

####To learn algorithms I did suggest the following:

  1. Read through Introduction to Algorithms -Cormen
  2. Register and attend the lectures on algorithms on coursera
  3. See video lectures on algorithms on NPTEL

cited from Quora

"Recursion is considered both a fundamental precept of computer science and a litmus test that separates the decent programmers from the terrible ones." - Bastards Book

Recursion requires 2 things

  • A base case
  • And a process in which the task is reduced towards the base

#Week 9 Transcript

####Git Git is tool, that the Ruby community has openly accepted as its standard for version control. Aside from the Ruby-core team, which uses SVN, Git is the gold standard.

Github is an a social network for codetool to collaborate with teams, contribute to open source, and host repos. I higly recommend signing up for Github and practicing pushing all you projects there.

####Testing Test First Ruby is a great tool to use to practice the basics in testing. I also recommend Ruby Koans, and excerism.io.

Testing is an important tool and required for most jobs and projects. If you have either completed all the previous examples I highly recommend the TDD workshop by thought where you not only the basics in TDD, but also the basics use cases for Functional, Integration, Unit testing. However I do want to mention it is a Rails and not just a pure Ruby tutorial.

####Final Project We will not be going over the final project, but you should at this point have the skills to take it on, if not review the Tic Tac Toe example in that section.

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