Day two was little faster pace and we saw Ruby's magic and sugar according to to the author. We dove into working with structures, arrays and built a simple class. So far Ruby seems pretty easy and a little fun and its very easy to find help via google.
Read more...
For Christmas 2010 my wife bought me Seven Languages in Seven Weeks which I ask for after seeing it on Ben Nadel's blog.
I Finished Day 1 of Ruby, so far its a very easy read. I learned how to output strings, a couple of different loops (while and until), Decisions (if and unless) and a little more. One of the things that I like about Ruby is the way it reads.
Example 1:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
x = 4
unless x == 4
puts("This appears to be true");
else
puts("This appears to be false");
end
1x = 4
2unless x == 4
3 puts("This appears to be true");
4else
5 puts("This appears to be false");
6end
Day 1 HW
Print the string "Hello, World."
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
#Print the string "Hello, World."
print "Hello, World."
1#Print the string "Hello, World."
2print "Hello, World."
For the string "Hello, Ruby." find the index of the word "Ruby."
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
#For the string "Hello, Ruby." find the index of the word "Ruby."
phrase = "Hello, Ruby."
puts phrase.index("Ruby.")
1#For the string "Hello, Ruby." find the index of the word "Ruby."
2phrase = "Hello, Ruby."
3puts phrase.index("Ruby.")
Print your name ten time
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
#Print your name ten time
i = 0
while i <= 10
puts "Matt Graf"
i +=1
end
1#Print your name ten time
2i = 0
3while i <= 10
4 puts "Matt Graf"
5 i +=1
6end
Print the string "This is sentence number 1," where the number 1 changes from 1 to 10
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
#Print the string "This is sentence number 1," where the number 1
#changes from 1 to 10
i=1;
until i > 10 do
puts ("This is Sentence number #{i},")
(i+=1);
end
1#Print the string "This is sentence number 1," where the number 1
2#changes from 1 to 10
3i=1;
4until i > 10 do
5 puts ("This is Sentence number #{i},")
6 (i+=1);
7end
Run a Ruby program from a file.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
#Run a Ruby program from a file.
ruby /users/foobar/rubydemo/foo.rb
1#Run a Ruby program from a file.
2ruby /users/foobar/rubydemo/foo.rb
Bonus problem: If you're feeling the need for a little more, write a program that picks a random number. Let a player guess the number, telling the player whether the guess is too lower or too high.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
#Bonus problem: If you're feeling the need for a little more,
#write a program that picks a random number. Let a player
#guess the number, telling the player whether the guess is too
#lower or too high.
#lets go head and build a randRange function because we can
def rand_range(min,max)
min + rand( max - min )
end
# define a function, for the heck of it
def guess_number_game
#create a random number
start_num =9;
end_num=10;
random_number = rand_range( start_num, end_num );
#create a variable to track how attempts it take
#the user to guess the number
user_attempt = 0;
#prompt the user to guess a number between 1 and 10
puts("Guess a Number? Between #{start_num} and #{end_num}. ");
puts("Guess: ");
#use the begin while loop
begin
#Get the users input and make it an integer
user_guess = gets.chomp.to_i;
#Here I am using one of the ways to
#make a decision with an if
puts "Guess higher: " if user_guess < random_number
#Here I wanted to use another decisions method unless
puts "Guess lower: " unless user_guess <= random_number
#Track the users attempts
user_attempt += 1;
#Loop while the user's guess does not match
#the random number
end while( user_guess != random_number )
#Output a message along with the user's attempts
puts("Guessed it on #{user_attempt} try's");
end
#call the number game
guess_number_game
1#Bonus problem: If you're feeling the need for a little more,
2#write a program that picks a random number. Let a player
3#guess the number, telling the player whether the guess is too
4#lower or too high.
5#lets go head and build a randRange function because we can
6def rand_range(min,max)
7 min + rand( max - min )
8end
9# define a function, for the heck of it
10def guess_number_game
11
12 #create a random number
13 start_num =9;
14 end_num=10;
15 random_number = rand_range( start_num, end_num );
16
17 #create a variable to track how attempts it take
18 #the user to guess the number
19 user_attempt = 0;
20
21
22 #prompt the user to guess a number between 1 and 10
23 puts("Guess a Number? Between #{start_num} and #{end_num}. ");
24 puts("Guess: ");
25
26 #use the begin while loop
27 begin
28
29 #Get the users input and make it an integer
30 user_guess = gets.chomp.to_i;
31
32 #Here I am using one of the ways to
33 #make a decision with an if
34 puts "Guess higher: " if user_guess < random_number
35
36 #Here I wanted to use another decisions method unless
37 puts "Guess lower: " unless user_guess <= random_number
38
39 #Track the users attempts
40 user_attempt += 1;
41
42 #Loop while the user's guess does not match
43 #the random number
44 end while( user_guess != random_number )
45
46 #Output a message along with the user's attempts
47 puts("Guessed it on #{user_attempt} try's");
48
49end
50#call the number game
51guess_number_game
I have 2 more days to go on Ruby.
So today I was chugging alone and all of a su dden I had all of these Whitespace characters in my CFBuilder.

I could not for the life of my figure out how to remove them well thanks to Google and Raymond Camden I was able to fix it. To fix it you simple use these key commands "ctrl" + "." or if you are a Mac user "Command" + ".".

I saw these over at forgetfoo.com and thought that the techies out there would like them.
How to setup your CFBuilder project to use virtual host mappings. I am making the assumption that you have already setup your CFBuilder to talk to your local CF Server. Ok lets start.
First you need to make sure that you have the servers panel open in you workspace in CFBuilder, if you already have you local server setup you should see it in the server panel.

Now right click and select Edit Server. Now you should have the Modify ColdFusion Sever Setup Dialog window

Click next, and then click the Virtual Host settings button as you
can see I already have two virtaul host set up. So what you need
to fill out fields all of them are required. The name Field is the name
that you identify the virtual host with. The Host name is the actual
virtual host which should match your apache virtual host example
"coldfusion.dev". port which port is this going to run on I use 80 on all
of my local sites. Type is either http or https. Document Root is
the absolute path to your project. Once you have filled out all of the
fields click the apply button.

Once you have your virtual host setup go to the project or navigator
panel select the project that you would like to associate the virtual
host with. Right click and select properties.

Once the Properties window pops up select ColdFusion Server Settings
and in the servers drop down find the virtual host that you just setup.
Click apply and then Ok

Now select the project again and right again but this time select Set URL Prefix.
Now in the URL Prefix dialog box type the name of your virtual host again.

Now should be able to preview your CFM pages in CFBuilder.