Skip to content

Instantly share code, notes, and snippets.

View jamesmichiemo's full-sized avatar
☯️
casting lots

Mana jamesmichiemo

☯️
casting lots
  • University of North Carolina
View GitHub Profile
//Git Commands
# NOTES: Lines starting with // or # are comments and should not be typed into terminal. Please be careful of your spelling, spacing, and case before initiating a command in terminal.
//Standards Commands to push to github (in order)
git add .
# adds all files and folders that contain files to be commited
git status
# shows what changes are going to be commited
@jamesmichiemo
jamesmichiemo / gist:5329559
Created April 7, 2013 08:23
Useful Commands for Mercurial
//Mercurial commands for Terminal
# NOTES: Lines starting with // or # are comments and should not be typed into terminal.
#For additional help use the wiki at http://mercurial.selenic.com/wiki/
//Help for Commands
#<command> help:
$ hg help <command>
or
$ hg <command> - -help
@jamesmichiemo
jamesmichiemo / rubyExpressions1.rb
Last active December 18, 2015 05:59
expressions in Ruby language
# Dog Years
# Calculate the age of Spike in dog years bases on his actual age
#
print "What age is Spike?: "
actualAge = gets.chomp().to_i
dogAge = actualAge * 7
puts "Spike's actual age is #{actualAge} but his age in dog years is #{dogAge}."
@jamesmichiemo
jamesmichiemo / rubyExpressions2.rb
Last active December 18, 2015 05:59
expressions in Ruby language
# Pie Slice exercise
# Calculate how many slices each person will receive
#
print "How many slices are there per pizza? "
slices = gets.chomp.to_i
print "How many people are eating? "
people = gets.chomp.to_i
print "How many pizzas pies are there? "
@jamesmichiemo
jamesmichiemo / rubyExpressions3.rb
Last active December 18, 2015 05:59
expressions in Ruby language
# Shopping Bill exercise
# Calculate the average amount spent on groceries over 5 weeks
#
print "How much was spent on groceries for week 1? "
week1 = gets.chomp().to_f
print "Week 2? "
week2 = gets.chomp().to_f
print "Week 3? "
@jamesmichiemo
jamesmichiemo / rubyExpressions4.rb
Created June 9, 2013 01:48
expressions in Ruby Language
# Discount exercise
# Calculate the discounted price for an item
#
print "What is the name of the item you would like to buy? "
itemDescription = gets.chomp()
print "What is the price of one #{itemDescription}? "
price = gets.chomp().to_f
print "At what percent is the discount offered? "
@jamesmichiemo
jamesmichiemo / rubyExpressions5.rb
Last active December 18, 2015 10:09
expression in Ruby language
# Exam
# Problem: Matt is a teacher grading the last exam taken for his course and he needs to log the progress of his students in his roll boo.
# There are 16 students in his class. If 10 of those students passed the exam, what percent failed the class
# Calculate the percent of failures in Matt's class.
#
print "Matt is a teacher grading the last exam taken for his course and he needs to log the progress of his students in his roll book. There are 16 students in his class. If any of these students fail the exam, they will fail the class. Only 10 of Matt's students passed the exam. Calculate the percentage of failures.\n\nEnter the total amount of students in Matt's class. "
studentTotal = gets.chomp().to_f # <= 16 students
print "Enter how many students passed Matt's class. "
studentsPassing = gets.chomp().to_f # <= 10 students
@jamesmichiemo
jamesmichiemo / rubyExpressions6.rb
Last active December 18, 2015 10:10
expressions in Ruby language with Rails support
require 'active_support/core_ext/enumerable.rb' # <= enables the use of array.sum with rails installed. (bit.ly/mCblb)·
# Marathon
print "Jon, Carla, Jim, and Harry won lottery tickets to run the NYC marathon. The runners now need to get sponsers so together they've g athered their running stats to see if they qualify for the money. The money people would like to know the average pace between the lotter y winners to get an idea of how fast their team is. Calculate the average time it takes for athlete runners to finish a marathon.\n\n"
distance = 26.2 # <= marathon distance in miles
runnersPace = []
print "At what pace(minutes per mile) does Jon run a marathon? "
@jamesmichiemo
jamesmichiemo / rubyExpressions7.rb
Created June 15, 2013 14:34
Another expression using Ruby with a Rails lib
require 'active_support/core_ext/enumerable.rb' # < array.sum with rails installed. (bit.ly/mCblb)
# Podcast
#
print "Terrance has a weekly podcast and he would like to know the total amount of listeners last weekend. Calculate the sum of downloads for the week.\n\n"
downloadsWeek = []
print "How many downloads were there on Sunday?"
sunDL = gets.chomp().to_i
@jamesmichiemo
jamesmichiemo / rubyConditionals1.rb
Created June 19, 2013 23:59
Conditional expressions in Ruby language
# Temperature Converter
#
print "How many degrees is the temperature right now? "
degrees = gets.chomp().to_f
print "Fahrenheit(F) or Celsius(C)? "
unit = gets.chomp().to_s