I had some kind of screw up with my branching when trying to push to my github repository. I never really figured out the exact issue, but since the repository had really minimal history i just removed it. Here is what I did for the local repository;
From the terminal while in the correct directory i typed: rm -rf .git
Then I reinitialized the local repository with: git init
In github I removed the repository by going under settings when in the said repository and choosing remove. I then created a new github repository and went back to the terminal to push files and all seems well. It was an hour or two of cursing before i figured out what to do.
Sunday, October 27, 2013
Saturday, October 5, 2013
inject method
I came across this method when doing a google search for how to sum in an array. I'm using it now to try and build my blackjack game. It seems to be working fine for what I want it to do for now. I'm not too sure yet on what all this method can do or problems that can arise. I took the info from a stack overflow post,
http://stackoverflow.com/questions/1538789/how-to-sum-array-members-in-ruby.
My blackjack game is a work in progress. I tried building this mostly on my own before looking at the tealeaf videos that show building the program up. I don't know if i'll get a chance to totally finish my own version of it. Here is where i'm at to show how i'm using inject. Note that this will run for most instances, but i haven't fixed a couple issues yet. Note inject returns a fixnum.
deck = [1,2,3,4,5,6,7,8,9,10,10,10,10,'Ace']
deck.shuffle!
ph = []
dh =[]
2.times do
ph << deck.pop
dh << deck.pop
end
puts 'Hand'
puts ph
puts
if ph.include? 'Ace'
puts 'Ace in hand'
end
puts
if ph.include? 'Ace'
puts 'Choose ace high or low' i'm expecting a 1 or 11 response here
ace = gets.chomp
ace = ace.to_i
ph.map! {|x| x == 'Ace' ? ace : x}
puts
puts ph
end
puts 'Hand total'
sum = ph.inject(:+) here i use inject to get the total for the players hand
puts sum
puts 'Would you like a hit or stay?'
reply = gets.chomp
puts
if reply == 'hit'
ph << deck.pop
puts ph
puts
puts 'Hand total'
sum = ph.inject(:+) new total for player after hit
puts sum
end
if reply == 'stay' and dh.inject(:+)<17
dh << deck.pop
puts 'Dealer hand'
puts dh
puts
puts 'Dealer total'
sum = dh.inject(:+) dealer total. need to fix for aces
puts sum
end
puts
if ph.inject(:+) > dh.inject(:+) comparing hands
puts 'You win!'
elsif dh.inject(:+) >=22
puts 'You win'
else
puts 'Dealer wins :('
end
http://stackoverflow.com/questions/1538789/how-to-sum-array-members-in-ruby.
My blackjack game is a work in progress. I tried building this mostly on my own before looking at the tealeaf videos that show building the program up. I don't know if i'll get a chance to totally finish my own version of it. Here is where i'm at to show how i'm using inject. Note that this will run for most instances, but i haven't fixed a couple issues yet. Note inject returns a fixnum.
deck = [1,2,3,4,5,6,7,8,9,10,10,10,10,'Ace']
deck.shuffle!
ph = []
dh =[]
2.times do
ph << deck.pop
dh << deck.pop
end
puts 'Hand'
puts ph
puts
if ph.include? 'Ace'
puts 'Ace in hand'
end
puts
if ph.include? 'Ace'
puts 'Choose ace high or low' i'm expecting a 1 or 11 response here
ace = gets.chomp
ace = ace.to_i
ph.map! {|x| x == 'Ace' ? ace : x}
puts
puts ph
end
puts 'Hand total'
sum = ph.inject(:+) here i use inject to get the total for the players hand
puts sum
puts 'Would you like a hit or stay?'
reply = gets.chomp
puts
if reply == 'hit'
ph << deck.pop
puts ph
puts
puts 'Hand total'
sum = ph.inject(:+) new total for player after hit
puts sum
end
if reply == 'stay' and dh.inject(:+)<17
dh << deck.pop
puts 'Dealer hand'
puts dh
puts
puts 'Dealer total'
sum = dh.inject(:+) dealer total. need to fix for aces
puts sum
end
puts
if ph.inject(:+) > dh.inject(:+) comparing hands
puts 'You win!'
elsif dh.inject(:+) >=22
puts 'You win'
else
puts 'Dealer wins :('
end
Thursday, October 3, 2013
Git it!
A reminder for me about pushing to github. I'm sure this will become something i'll have memorized shortly, but i've already looked this up a couple times in the video from the precourse materials. Now that it's posted here it will be much easier to get to.
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:jheaden/tealeaf.git
git push -u origin master
Push an existing repository from the command line
git remote add origin git@github.com:jheaden/tealeaf.git
git push -u origin master
Initial commit
Hello world. I'm officially in week one of my Ruby on Rails online bootcamp! This is an exciting, and a wee bit stressful, time. I'm embarking and path to change careers from teaching mathematics to becoming a ruby/rails web developer.
This blog is set up to document my progress over the next 4 months through the Tealeaf bootcamp. I hope this turns out to be a useful way to keep notes on what i'm learning as I go. My intention is to do some brief summaries of topics each week and what i've learned or am struggling with. While this bootcamp will take a lot of time i hope to keep myself fit and active. So i'll also post my weekly workouts, mostly running, as I go. My weeks start on Monday.
Mon Sep 30 AM Easy run with Zola (2.5 miles). PM Easy track. 4 400's between 6:15 and 5:45 effort (3 miles)
Tues Oct 1 PM CC practice. Ran with kids (4 miles)
Wed Oct 2 AM Shevlin run with Zola (5.5 miles)
Thurs Oct 3 AM 45 min lap swim. Running around cheering kids on at meet. My first meet as cross country coach! Tons of fun, very proud of my runners.
Fri Oct 4 AM Shevlin run with Zo (4 miles)
Well i doubt anyone will find and read this blog, but hey if you do comments are great!
Cheers
This blog is set up to document my progress over the next 4 months through the Tealeaf bootcamp. I hope this turns out to be a useful way to keep notes on what i'm learning as I go. My intention is to do some brief summaries of topics each week and what i've learned or am struggling with. While this bootcamp will take a lot of time i hope to keep myself fit and active. So i'll also post my weekly workouts, mostly running, as I go. My weeks start on Monday.
Mon Sep 30 AM Easy run with Zola (2.5 miles). PM Easy track. 4 400's between 6:15 and 5:45 effort (3 miles)
Tues Oct 1 PM CC practice. Ran with kids (4 miles)
Wed Oct 2 AM Shevlin run with Zola (5.5 miles)
Thurs Oct 3 AM 45 min lap swim. Running around cheering kids on at meet. My first meet as cross country coach! Tons of fun, very proud of my runners.
Fri Oct 4 AM Shevlin run with Zo (4 miles)
Well i doubt anyone will find and read this blog, but hey if you do comments are great!
Cheers
Subscribe to:
Posts (Atom)