Skip to content

Instantly share code, notes, and snippets.

@jvns
Last active August 29, 2015 13:58
Show Gist options
  • Save jvns/9966902 to your computer and use it in GitHub Desktop.
Save jvns/9966902 to your computer and use it in GitHub Desktop.

Hello! Welcome to RailsBridge!

We're so happy you're here. We're going to start out with some basic things you'll need to know before getting started with programming.

By the end, we'll have run our first program!

Step 1: Open a terminal!

We'll need to run programs from a terminal. Mine looks like this. Yours might looks a little different.

Step 2: Run our first command! (ls)

The first command we're going to learn is ls. ls is short for "list", and lists all the files in a directory. For me, this lists all the folders I have:

bork@kiwi $ ls
bin     dat   Desktop    Dropbox  stripe  work
clones  data  downloads  media    tmp     www

Step 3: A few more commands

We can make a new directory using mkdir. All of the commands we're going to use will be shortened in this way -- they were named in the 70s when people thought saving characters was really important.

Let's make a directory called "railsbridge"!

bork@kiwi $ mkdir railsbridge
bork@kiwi $ ls
bin     dat   Desktop    Dropbox  stripe  railsbridge work
clones  data  downloads  media    tmp     www

Excellent! We now have a "railsbridge" directory! We can now change to this directory using cd. This stands for "change directory".

bork@kiwi $ cd railsbridge
bork@kiwi:~/railsbridge $ ls

This time ls doesn't print anything. But that's okay! It's because the directory is empty!

Step 4: Making a file!

Okay, let's make a file!

We'll need to use a text editor to do this. This means something like Sublime Text 2 or TextEdit, not Word.

  1. Open your text editor
  2. Create a new file and save it as "yay.txt" in your railsbridge directory
  3. Go back to your terminal and run "ls" again. You should see your file!
bork@kiwi:~/railsbridge $ ls
yay.txt

Step 5: Making a program!!!

NOW WE CAN WRITE OUR FIRST PROGRAM. In Ruby!

This is basically the same as the last step.

  1. Open your text editor
  2. Create a file and save it as "hello.rb"
  3. Go back to your terminal and run ruby hello.rb

You file should say this:

puts "I am at Railsbridge!!!"

Run your program!

bork@kiwi:~/railsbridge $ ls
hello.rb  yay.txt
bork@kiwi:~/railsbridge $ ruby hello.rb
I am at Railsbridge!!!

If it works, you are now a programmer! Congratulations.

Recap

Terminal commands:

  • ls lists files
  • cd changes directories. You can do cd .. to go into a parent directory
  • mkdir creates directories
  • ruby runs Ruby programs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment