This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Just copy and paste the lines below (all at once, it won't work line by line!) | |
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY! | |
function abort { | |
echo "$1" | |
exit 1 | |
} | |
set -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Difference between p and PUTS = Puts results in the value output as a string, whereas p simply outputs the true value of the object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Difference between p and PUTS = Puts results in the value output as a string, whereas p simply outputs the true value of the object | |
Variables must start with lower case letter: | |
my_string_variable = "hello world" | |
p my_string_variable | |
will print out | |
hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I decided to try my luick and see how much I remebered from my first depoyment to heroku: luckily I had already installed heroku to the system in 2013, and had an account with a functioning app: | |
http://shielded-river-4844.herokuapp.com | |
Deploying to heroku requires we change the gem file: Gems are as follows: | |
Gems can be used to extend or modify functionality within a Ruby application. Commonly, they're used to split out reusable functionality that others can use in their applications as well. Some gems also provide command line utilities to help automate tasks and speed up your work. | |
So for the first-app in rails, we have to add postgres functionality |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Working on deploying to new relic as it is the first time I have used it, but have heard about it for the last year. | |
it started with entering from the command line within the app director the following code | |
$ heroku addons:add newrelic:stark | |
at first it wouldnt perform the add on: however after I verified by using my credit card it worked out fine. | |
The following was the output. | |
Joses-MacBook-Air:first-app JRV$ heroku addons:add newrelic:stark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To get this started, i opened the terminal and entered IRB for the interactive ruby shell. I entered the requried methods | |
Joses-MacBook-Air:first-app JRV$ irb | |
2.0.0-p451 :001 > def add(a,b) | |
2.0.0-p451 :002?> a-b | |
2.0.0-p451 :003?> end | |
=> nil | |
2.0.0-p451 :004 > p add(5,4) | |
1 | |
=> 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reiterting that no one is perfect, the lesson is trying to stress the importance of understanding the terms used when dealing with bugs. | |
The three given first are | |
"Throw - when an interpreter returns an error, it is known to "throw" the error. | |
Catch - when your code pro-actively accounts for the possibility of an error. An interpreter can throw errors, and you can write code to catch errors in your methods. | |
Handling - the act of catching an error in your code, and then doing something based on that error." | |
The lesson advises that when you get an error, read the message carefully to try to glean the solution from the statement. Ruby is supposed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SO sometimes we have to as a question, and have a result based on that answer. For example | |
"I Mary doesnt have two shoes on, ask her 'why'" | |
For assignment is the following quesiton is given | |
"If Mary has more than $5, then give her an apple." | |
So the following code is given as an example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ok, brief overview | |
1) true and false, do not need quotes, as they are psudo-variables and native ruby values | |
2) || is the same as saying "or", and && is the same as saying "And" in a method argument | |
3) ou can use elsif on mlutple lines, or try using difference arguments in parenthesis | |
4) | |
more to follow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now I know what classes are in CSS and HTML. But now for ruby....ouch | |
So, according to the lesson, Ruby is an Object-Oriented language. In an OO language, objects communicate with each other via messages. Thats to say, messages containing instructions are sent to objects, then something happens. Here's an example they give: | |
numbers#This is a variable = [1,2,3] #This is the Object | |
numbers.length #Length is a method with a very explicit set of instructions, which for this is to query the object for its length | |
#=> 3 #the answer the object returns from the method that asked the question in the first place (its a nosey bitch, MYOB) | |
SO in this, its declaring a variable named NUMBERS and setting it equal to an array consisting of 1, 2 and 3. Our numbers array is in fact, an object. On the next line, we are sending our numbers object a message. The message is basically asking the object for its length. As you know, length is also a method, but in the abstract it's really just a message with an explicit set of ins |
OlderNewer