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
Integer comparison | |
-eq | |
-ne | |
-gt | |
-ge | |
-lt | |
-le | |
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
# Extend the String class with a new method called my_new_method | |
class String | |
def my_new_method() | |
end | |
end |
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
1. Add disk space to the vm by adding another virtual disk. | |
2. In the linux VM, issue the following commands: | |
# List existing disks | |
fdisk -l | |
# Scan for the new disk created in step 1. | |
echo "- - -" >/sys/class/scsi_host/host0/scan | |
# List existing disks (should see the new disk) |
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
# This will get executed upon exit of a ruby process | |
at_exit { puts "Hello Sean" } |
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
# == Description | |
# the <=> operator returns 1, 0, or -1, depending on the value of the left arugment relative to the right | |
# This operator is good to use when you want to define how to compare two like object | |
# The operator must return -1 for less than, 1 for greater than, and 0 for equal to | |
class Expense | |
# Modules | |
include Comparable | |
# Accessors |
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
#!/opt/apps/ruby/ruby/bin/ruby | |
require 'date' | |
# The initial date format as a String | |
my_date = "2013-10-03 21:03:46Z" | |
# Convert the Date to a DateTime Object | |
date_obj = DateTime.strptime(my_date,'%Y-%m-%d %H:%M:%S%Z') | |
# Re-Format the date - returns a String |
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
#!/opt/apps/ruby/ruby/bin/ruby | |
require 'date' | |
# Hold the time differences to calculate averages | |
time_diffs = [] | |
# Get three time differences | |
1..3.times do | |
initial_time = DateTime.now() | |
sleep 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
# Ask use for input | |
# -e - if standard input is coming from a terminal, readline is used to obtain the line | |
# -p - display prompt on stderr without a trailing new line | |
default="/usr/locol/etc/" | |
read -e -p "Enter the path to the file [${default}]: " FILEPATH | |
FILEPATH=${FILEPATH:-${default}} | |
echo $FILEPATH |
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
if [[ $EUID -ne 0 ]]; then | |
echo "ERROR: The user must be root in order to execute this script." | |
exit 1 | |
fi |
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
# Get the current file | |
current_file = $0 | |
# Get the full path to the current file | |
full_file_path="$(readlink -f $(dirname $0))/$(basename $0)" | |
# Get the full directory path to the current file | |
full_dir_path="$(readlink -f $(dirname $0))" |
NewerOlder