Skip to content

middilman/study

 
 

Repository files navigation

mi study group

Start in the NOTES directory (the box above this one, if you're on github). That's where all notes for past lessons can be found. Also, the notes for the next lesson will be there.

Goal

improve our programming skills by meeting weekly and working on programming stuff.

Topics

  • ruby
  • ruby on rails
  • rspec, cucumber
  • coffeescript
  • git: forking on github
  • unix/linux command line
  • development tools / IDEs: RubyMine, vim, sublime text
  • managing / setting up a webserver

Schedule

When: Every Saturday morning 8-9:30

week 5

Who: Stephen
When: Sat Apr 13 8:00-9:30 2013
Where: DevCave
What: Programming, from the beginning

  • computers are dumb
  • people are smart
  • programming is just telling the computer what to do
  • (miles) exercise
    • can make you smarter
    • can help you solve stumper problems

week 4

Who: Stephen
When: Sat Apr 06 8:00-9:30 2013
Where: DevCave
What: Classes and Objects and Vars, Oh My!

  • Ruby: instance variables
  • Ruby: static variables and methods
  • Ruby: global variables (why are they evil?)
  • Ruby: arrays and all their nifty functions
    • a1="this is a bunch of words".split
    • a2=%w{this is a bunch of words}
    • a1.join ', '
  • Lots of great stuff last week. Review!

week 3

Who: Stephen
When: Sat Mar 30 8:00 AM 2013
Where: DevCave
What:

  • Ruby: what does initialize method do?
    • how is it invoked?
    • how is it useful?
  • Ruby idiosyncracies part 1
    • what does ! do?
    • when ! is part of a method name, what does that usually mean?
    • what does ? do?
    • when ? is part of a method name, what does that usually mean?
  • Constants: any string that starts with upper-case letter
    • legible constants use underscores: ICE_CREAM_FLAVOR = "pralines and cream" Variables
    • start with lower-case letter
    • by convention, use underscore: current_ =
  • Ruby: how are variables like pointers?
  • git: diff and git diff --staged
  • git: log and git log -p
  • git: man git-log (note the hyphen)
  • Garbage Collection
    • sweep, reference counting
    • memory leaks: (anti pattern) how can one leak memory in Ruby?
  • symbols Prep:
  • read symbols 1 or
  • read symbols 2 or
  • pick a better explanation for symbols :-)

week 2

Who: Stephen
When: Sat Mar 23 8:00 AM 2013 Where: DevCave
What: Ruby and RTanque: Battle day
Prep:
ruby-doc.org ::: Bookmark it!
If you didn't do the quick start (below) before, do it for this time.
Fork steptan's RTanque github repo so you can share your bot via pull request
(actually, the study repo has the bots in subdirectory called tank_bots)
[email protected]:steptan/RTanque.git
come ready to battle

week 1

Who: Stephen
When: Tue Mar 5 6:30 AM 2013
Where: DevCave
What: Ruby and RTanque
Prep:
Do RTanque (aka tank) Quick Start: (below)

What we've learned

command line

ln -s
  • create a symbolic link, aka, shortcut
  • ln -s ../study_group/tank_bots

git

History:

git log  

History with changes:

git log -p  

Ruby basics

  • everything in Ruby is an Object
  • Object are created from Classes
  • every Class extends another class, all the way back to Object
    For example, numbers are objects, too
    arithmetic operators are just method calls
    so + is a method on the Number class
3 + 3 #(is the same as) 
3.+(3)  
  • Magic numbers are evil: use Constants instead
  • Constants should not change, though Ruby seems to allow it, complains
    • Class names are constants (everything in Ruby that starts with upper-case letter is a constant.

Classes

  • :: Class-wide edit: see :: "Scope Operator"

    • Class Values accessed by appending :: to class name
    • Static constants: Math::PI
    • Package Declaration
  • Classes can be "instantiated" to create "instances" which are Object

  • Variables point to Object

  • Instance variables persist across method calls and have a @ prepended @lives = @lives - 1

  • ruby constructor: initialize

  • each time a Class is instantiated

    • a new Object is born
    • its initialize method is called
    • initialize method takes 1 argument
    def initialize(blah)
      @radar = 0.0
    end
  • every Class inherits from the Object class
  • ruby returns the last thing in your method
  • duck typing
  • + is actually a method (same for *, -, / etc)
  • every method returns the last thing
  • irb is a great way to quickly test stuff and learn Ruby from the command line __ Try this in irb:__
    you can concatenate Strings in Ruby
    "Hi," + " there"

you cannot do this:

    5 + " little monkeys"

why not? duck typing. Ruby finds 5, wants to do arithmetic

    5 + 5

this works:

    5.to_s + " little monkeys"

because now Ruby can concatinate 2 Strings: "5" and " little monkeys"

markdown

markdown cheat sheet

  • to force a line break, end a line with two spaces
  • to make a link,
    • put the text of the link in square braces
    • put the link inside parenthesis

RTanque (aka tank) Quick Start:

(run from the command line)

mkdir rtanque; cd rtanque  
echo '1.9.3' > .ruby-version  
bundle init  
echo "gem 'rtanque'" >> Gemfile  
bundle  
bundle exec rtanque new_bot my_bot  
bundle exec rtanque start bots/my_bot sample_bots/keyboard sample_bots/camper:x2  

Drive the Keyboard bot with asdf. Aim/fire with the arrow keys
http://awilliams.github.com/RTanque/

next subjects

  • blocks in ruby
    (1..5).each {|num| puts 2*num}  

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%