<agrinb>
that throw and error complaining about the comma
nathanstitt has quit [Quit: I growing sleepy]
<centrx>
agrinb, put it in an array
<centrx>
agrinb, it has to be an explicit array with [] in a block
<centrx>
noob101, hi
<noob101>
hi
<centrx>
ask away
<agrinb>
THANK YOU!
<agrinb>
2 hours of googling
maoko has joined #ruby-lang
dmitrykorotkov has quit [Ping timeout: 252 seconds]
<noob101>
centrx: Everytime I run this code there is a loop. Can you tell me why? http://pastie.org/9207791
<centrx>
noob101, Can you identify in which loop the infinite loop is happening?
<centrx>
or where in the code
dmitrykorotkov has joined #ruby-lang
<noob101>
while loop on from line 36 - 40 I think
<noob101>
It has to be
<noob101>
When I commented out, everything else worked out.
<centrx>
noob101, verify by putting a puts above that loop
<centrx>
noob101, okay, that's good too
mbwe has joined #ruby-lang
yfeldblu_ has quit [Remote host closed the connection]
<centrx>
noob101, what is the value of cpu_cards in each iteration of the loop?
<centrx>
noob101, Are you seeing with the line: puts cpu_cards += etc
<noob101>
centrx: I got you right now I will check
yfeldblum has joined #ruby-lang
<noob101>
well the value of cpu_cards changes because cpu_cards is cpu_card_one[1] + cpu_card_two
<noob101>
cpu cards one and two are samples from deck
<centrx>
ok, but it does it ever get above >= 17 ?
<centrx>
that's reasonably why the infinite loop is happening
<noob101>
hmmmm I will see. Please give me a second.
kyb3r_ has quit [Quit: Leaving]
dingus_khan has joined #ruby-lang
<noob101>
It went over 17
<noob101>
I just ran my file, I even put control flow like if cpu_cards > 17; puts "greater than 17". It still ran
<centrx>
Okay
ddv has quit [Ping timeout: 245 seconds]
<noob101>
The number I got regarding to line 37 was 18
<noob101>
but I got a number like 9 looping
<centrx>
I was able to reproduce the infinite loop, but it seems like at least a high percentage of the time, it does not infinite loop
<noob101>
I will run file again
<centrx>
interesting, it infinite looped with 9 on mine two
<centrx>
and that is exactly 18/2 too...
<noob101>
Right but regardless I dont want no errors, I want no looping
<centrx>
yes, this is just to diagnose what's happening
<centrx>
debugging is exploration
<centrx>
sometimes
<noob101>
lool centrx you're like the doctor. "18/2, interesting, it infinite looped" I love it
<noob101>
Sorry
ddv has joined #ruby-lang
<centrx>
I am a robot from the 24th century
<noob101>
huh
<noob101>
Oh wait lol what.
<centrx>
I have travelled back in time to help you with Ruby
<centrx>
one of your descendants created me
<noob101>
What race are you?
<centrx>
using Ruby++
<centrx>
I am modelled to look like a Quixloo from the planet Zarto
<noob101>
I have no idea what that is but okey dokey.
<noob101>
out of three times I ran the file, I got an inf loop of 12 just now
<centrx>
Sorry for the distraction. We have to focus, to save the human race.
alexju has joined #ruby-lang
<noob101>
No it's ok I am sorry.
marr has quit []
<centrx>
hmm okay, so some infinite loops are not 9
<centrx>
noob101, Can you puts what is in cpu_rand_card[1].to_i and try to get it to infinite loop
<noob101>
ok np
<noob101>
in still here centrx
<noob101>
I am a bit nervous, don't want you to think I'm gone :(
dmitrykorotkov has quit [Quit: Leaving]
<noob101>
centrx are you still here, I put the cpu_rand_card[1].to_i
<centrx>
ok
<noob101>
but where did you want me to test that, outside of the loop?
<noob101>
centrx: ^^
<centrx>
either way, the value doesn't change, so probably before the loop
<centrx>
though in the loop would prevent it from being pushed off the terminal history
<noob101>
I did it
<noob101>
I didn't get an inf loop when I puts cpu_rand_card[1].to_i outside the loop, it appeared as a number since I am indexing for the number stored at that index
<noob101>
I think it's that while loop centrx
<centrx>
yes
<noob101>
centrx: sorry I know you know but I don't know Q_Q
<centrx>
makes sense
<centrx>
You seem to be figuring it out :)
<noob101>
please use my name cause sometimes I may be doing something not in browser.
<centrx>
ok
<noob101>
Ok but I am still working on the file, that's what I am doing in meanwhile centrx and listening to your suggestions
<centrx>
noob101, so, what would cause the loop "while cpu_cards < 17" to be an infinite loop?
ur5us has quit [Remote host closed the connection]
<noob101>
centrx: That's what I don't know, I hope you can help me figure it out.
<noob101>
centrx: Should we tell the other programmers?
<centrx>
? :)
<noob101>
in #ruby, you can if you like that would be nice :)
<centrx>
brb
<noob101>
ok np centrx
toastynerd has joined #ruby-lang
<noob101>
centrx: Are you back yet>
toastynerd has quit [Remote host closed the connection]
saarinen has joined #ruby-lang
hakunin has joined #ruby-lang
toastynerd has joined #ruby-lang
<centrx>
noob101, hi
<centrx>
noob101, I have another call in 15 minutes
<noob101>
centrx: Any luck yet?
<centrx>
noob101, The loop continues while cpu_cards < 17
<centrx>
noob101, Therefore, the loop ends while NOT (cpu_cards < 17)
<noob101>
you mean the loop doesn't end while it's less than 17 right?
<noob101>
or am I wrong?
<noob101>
centrx: I am going to ask other people to help. You are helping me well though, I want different prepsectives.
<noob101>
perspectives*
<centrx>
noob101, right, the loop doesn't end while it's less than 17
dingus_khan has quit [Remote host closed the connection]
<centrx>
noob101, It is expected that cpu_cards will increase above 17, because of cpu_cards += cpu_rand_card[1].to_i
<centrx>
noob101, But some times, it doesn't, and you get an infinite loop
<centrx>
noob101, So you want to find out what is happening with cpu_cards and cpu_rand_card[1].to_i
saarinen has quit [Quit: saarinen]
<centrx>
noob101, We saw that when there is an infinite loop, cpu_cards stays the same number for endless iterations
toastynerd has quit [Remote host closed the connection]
<noob101>
centrx: right
<noob101>
I saw like 16 looping
<centrx>
noob101, So, why might that be happening?
<noob101>
but why doesn't freaking ruby just add another number to it
<noob101>
Like is it retarded? just add another number and there ya go.
nathanstitt has joined #ruby-lang
<noob101>
But no loop at 16, great
<centrx>
Your code doesn't require it to
RobertBirnie has joined #ruby-lang
<centrx>
cpu_rand_card[1].to_i is not always positive
<noob101>
Right but it loops anyway at 0 I don't know why
<noob101>
I am not going to lie, the cpu_rand_card has the value of index one regarding to deck
michd is now known as michd
<noob101>
and the thing is that index 1 has string values cause card values in 21 include King Ace Queen and Jack
<noob101>
I didn't assign them a value, i will though right now and see if that will solve problem.
<centrx>
Excellent
<noob101>
Like the thing is, cpu_rand_card can equal a string cause if you look at card_values, I have "Ace", "King", etc. centrx
<aztec_>
my problem is that the detector doesn't produce any results that seem to make sense
<aztec_>
however i might be missing something about rmagick
stayarrr has quit [Quit: Leaving...]
simono has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<aztec_>
These two (embed.rb and detect.rb) show how this class may be used...the goal is to embed a primitive watermark in a (png) image but it seems that nothing is changed in the image or that my detector method is flawed
<aztec_>
Hm says nothing about how the "random" values are generated
<aztec_>
i don't know if i'm stating the obvious to you here, but by setting the seed with "srand seed_val" i ensure that the random numbers are reproducible by providing the same seed_val
<havenwood>
aztec_: `Random::DEFAULT` unless you set `rng` otherwise
<aztec_>
that's necessary because that way i can use the same sequence of +1 and -1 when marking and detecting
dingus_khan has quit [Ping timeout: 245 seconds]
karamazov has joined #ruby-lang
<havenwood>
aztec_: hem
karamazov has quit [Client Quit]
<aztec_>
oh you mean i don't event use the system aka. default generator at the moment? well...
snsei has quit [Remote host closed the connection]
snsei has joined #ruby-lang
<aztec_>
never mind, doc says DEFAULT is used...
<toretore>
you should probably use a Random.new instead of using the global one
datanoise has left #ruby-lang [#ruby-lang]
<toretore>
Random.new(my_seed).rand
<aztec_>
that would be worth a try, let me check that
<aztec_>
tbh it's a little confusing that rmagick uses these 16bit color depth
<aztec_>
this*
<toretore>
otherwise you're sharing the rng with other threads/code
<apeiros>
oh what nice code: `if fm = @fm[flags = flags(flags)]`
<apeiros>
raises a couple of red flags :D
agrinb has joined #ruby-lang
<toretore>
badum tish
<aztec_>
still no difference
<aztec_>
just to give an example, i do the following:
<aztec_>
ruby detect someimage.png 12345678 => returns some arbitrary number
<aztec_>
ruby detect.rb someimage.png_watermark 12345678 still returns same arbitrary number
agrinb has quit [Ping timeout: 264 seconds]
<aztec_>
that's detect.rb and watermark.rb in both above cases of course
<Sunnyan>
hello guys
<Sunnyan>
I am new to this whole Ruby thing
<Sunnyan>
and I think I have the basics down
<Sunnyan>
is it a good idea to dive into rails right away?
<aztec_>
yes
<Sunnyan>
how do you suggest I go about it?
<Sunnyan>
look up some tutorials and go for it?
<aztec_>
just dive right into it heads first ;) get the hang of active record first of all
<Sunnyan>
okay
<aztec_>
rails is convention over configuration which means you will probably need some time until you know those conventions
<Sunnyan>
I see
<Sunnyan>
this is my first time learning how to use a web framework
<Sunnyan>
so i'm not very confident
agrinb has joined #ruby-lang
<aztec_>
play around in rails console a lot, it gives you a good idea how active record works
<Sunnyan>
okay
<havenwood>
Sunnyan: I'd vote pretend Rails doesn't exist until you know Ruby.
<aztec_>
also try to get the hang of the basic procedure from "incoming HTTP request" to "markup/json output being shown"
<Sunnyan>
hmm
<Sunnyan>
havenwood: how much would you say is a good benchmark
<Sunnyan>
before getting into rails
karamazov has joined #ruby-lang
<havenwood>
Sunnyan: No one right way but maybe at least know how to FizzBuzz? Or just jump in, can always dip your toes and jump back out. :P
<Sunnyan>
i can fizzbuzz :p
<havenwood>
Sunnyan: Sinatra is nice to take a look at.
<Sunnyan>
i checked
<Sunnyan>
i think i'll go through sinatra before getting into rails
<Sunnyan>
given how i have 0 experience with web frameworks
<apeiros>
aztec_: one thought re your watermark - I don't think ruby gives guarantees on the algorithm. i.e. with different ruby versions, even the same seed might yield different sequences.
<havenwood>
Sunnyan: Rails docs and tutorials are nice though. And aztec_'s suggestion of ActiveRecord does optionally apply to Sinatra as well as Rails. Sounds like you already know some Ruby. :)
<Sunnyan>
thanks for the help, havenwood and aztec_
<Sunnyan>
i like what the link says
<Sunnyan>
:p
<aztec_>
havenwood: I just did a little console debugging and it seems like there is a problem with embedding the watermark
<aztec_>
i go through each_pixel and add a +1 * strength or -1 * strength onto that pixel and than save the image
<aztec_>
when i output each pixel manipulation for an embedding with strength = 10000 each pixel is inc/decremented by 10000 (i print the value before and after setting .green of the pixel)
<aztec_>
however when i repeat the same operation on the processed image, the pixel values are the same again (as before the manipulation)
<aztec_>
file system shows a change in the file though
<aztec_>
in the timestamp, that is
cored has quit [Ping timeout: 258 seconds]
yfeldblum has joined #ruby-lang
sepp2k has joined #ruby-lang
yfeldblum has quit [Ping timeout: 258 seconds]
karamazov has quit [Remote host closed the connection]
phansch has quit [Quit: WeeChat 0.4.3]
danijoo has quit [Read error: Connection reset by peer]
bubodlac is now known as bubodlac|away
danijoo has joined #ruby-lang
<aztec_>
ok i think i have the problem, havenwood: When i do the manipulations in the each_pixel do |pixel| block, and right after that block display the values of each pixel again, they appear to be untouched
<aztec_>
so that's probably where knowing ruby comes in handy :P I assume this is an object reference issue
bubodlac|away is now known as bubodlac
karamazov has joined #ruby-lang
toastynerd has joined #ruby-lang
toastynerd has quit [Ping timeout: 264 seconds]
dingus_khan has joined #ruby-lang
sharpmachine has joined #ruby-lang
simono has joined #ruby-lang
karamazov has quit []
dingus_khan has quit [Ping timeout: 240 seconds]
sharpmachine has quit [Ping timeout: 258 seconds]
charliesome has joined #ruby-lang
bubodlac is now known as bubodlac|away
sheperson has joined #ruby-lang
bubodlac|away has quit [Quit: Leaving...]
mykoweb has quit [Remote host closed the connection]
mykoweb has joined #ruby-lang
GBrawl has quit [Quit: Computer has gone to sleep.]
simono has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ghg has joined #ruby-lang
simono has joined #ruby-lang
mykoweb has quit [Ping timeout: 252 seconds]
|jemc| has joined #ruby-lang
simono has quit [Client Quit]
fezziwig has joined #ruby-lang
tkuchiki has quit [Remote host closed the connection]
crankharder has quit [Quit: leaving]
yfeldblum has joined #ruby-lang
Atttwww has quit [Ping timeout: 245 seconds]
devgiant has joined #ruby-lang
yfeldblum has quit [Ping timeout: 245 seconds]
GBrawl has joined #ruby-lang
GBrawl_ has joined #ruby-lang
amclain has joined #ruby-lang
x0f_ has joined #ruby-lang
GBrawl_ has quit [Read error: Connection reset by peer]
GBrawl_ has joined #ruby-lang
GBrawl has quit [Ping timeout: 265 seconds]
aztec_ has quit [Ping timeout: 240 seconds]
x0f has quit [Ping timeout: 252 seconds]
stamina has joined #ruby-lang
Caius has quit [Ping timeout: 255 seconds]
toastynerd has joined #ruby-lang
Caius has joined #ruby-lang
Caius is now known as Guest62918
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
lolmaus has quit [Remote host closed the connection]
nathanstitt has joined #ruby-lang
Sunnyan has quit [Ping timeout: 264 seconds]
Sunnyan has joined #ruby-lang
toastynerd has quit [Ping timeout: 264 seconds]
dingus_khan has joined #ruby-lang
lolmaus has joined #ruby-lang
centrx has joined #ruby-lang
centrx has quit [Remote host closed the connection]
centrx has joined #ruby-lang
dingus_khan has quit [Ping timeout: 252 seconds]
Olipro has quit [*.net *.split]
stamina has quit [Ping timeout: 245 seconds]
GBrawl_ has quit [Quit: Computer has gone to sleep.]
cnivolle_ has joined #ruby-lang
DEac- has joined #ruby-lang
mikecmpb_ has joined #ruby-lang
hahuang65 has quit [Quit: Away.]
pskosinski has joined #ruby-lang
Olipro has joined #ruby-lang
cnivolle has quit [*.net *.split]
mikecmpbll has quit [*.net *.split]
ari-_-e has quit [*.net *.split]
DEac-_ has quit [*.net *.split]
canton7 has quit [*.net *.split]
GarethAdams has quit [*.net *.split]
Cakey has joined #ruby-lang
mykoweb has joined #ruby-lang
ari-_-e has joined #ruby-lang
GarethAdams has joined #ruby-lang
canton7 has joined #ruby-lang
GarethAdams has quit [Changing host]
GarethAdams has joined #ruby-lang
wallerdev has joined #ruby-lang
<Sunnyan>
havenwood: up and running on sinatra
<Sunnyan>
looks great ^^
<havenwood>
Sunnyan: :)
siflyn has joined #ruby-lang
snsei_ has joined #ruby-lang
snsei has quit [Ping timeout: 252 seconds]
sheperson_ has joined #ruby-lang
sheperson has quit [Ping timeout: 245 seconds]
sheperson_ is now known as sheperson
enebo has joined #ruby-lang
<centrx>
Diagnostic complete. All systems functioning within normal parameters.
snsei_ has quit [Remote host closed the connection]
snsei has joined #ruby-lang
Cakey has quit [Ping timeout: 276 seconds]
Sunnyan has quit [Ping timeout: 245 seconds]
Cakey has joined #ruby-lang
iTrojan has joined #ruby-lang
iTrojan has quit [Max SendQ exceeded]
snsei_ has joined #ruby-lang
iTrojan has joined #ruby-lang
iTrojan has quit [Max SendQ exceeded]
iTrojan has joined #ruby-lang
iTrojan has quit [Max SendQ exceeded]
iTrojan has joined #ruby-lang
iTrojan has quit [Max SendQ exceeded]
iTrojan has joined #ruby-lang
iTrojan has quit [Max SendQ exceeded]
iTrojan has joined #ruby-lang
iTrojan has quit [Max SendQ exceeded]
snsei has quit [Ping timeout: 240 seconds]
iTrojan has joined #ruby-lang
iTrojan has quit [Max SendQ exceeded]
bubodlack has joined #ruby-lang
toastynerd has joined #ruby-lang
frzng has joined #ruby-lang
Sunnyan has joined #ruby-lang
mistym has joined #ruby-lang
Cakey has quit [Ping timeout: 252 seconds]
nathanstitt has quit [Quit: I growing sleepy]
sharpmachine has joined #ruby-lang
dingus_khan has joined #ruby-lang
chouhoulis has quit [Remote host closed the connection]
chouhoulis has joined #ruby-lang
sharpmachine has quit [Ping timeout: 240 seconds]
dingus_khan has quit [Ping timeout: 252 seconds]
bin7me has joined #ruby-lang
pskosinski has quit [Quit: Til rivido Idisti!]
dmitrykorotkov has joined #ruby-lang
dmitrykorotkov is now known as Guest82622
Guest82622 has quit [Max SendQ exceeded]
codename539 has joined #ruby-lang
codename539 has quit [Max SendQ exceeded]
codename539 has joined #ruby-lang
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
codename539 has quit [Max SendQ exceeded]
codename539 has joined #ruby-lang
codename539 has quit [Max SendQ exceeded]
iamcalledrob has joined #ruby-lang
iamcalledrob has quit [Ping timeout: 240 seconds]
blizzzards has joined #ruby-lang
blizzzards has left #ruby-lang [#ruby-lang]
siflyn has quit []
sharpmachine has joined #ruby-lang
yfeldblum has joined #ruby-lang
robbyoconnor has quit [Read error: Connection reset by peer]
robbyoconnor has joined #ruby-lang
Miphix has quit [Quit: Leaving]
yfeldblum has quit [Ping timeout: 240 seconds]
fezziwig has quit [Remote host closed the connection]
_ht has quit [Remote host closed the connection]
banister has joined #ruby-lang
banister has quit [Client Quit]
Sunnyan has quit [Ping timeout: 240 seconds]
centrx has quit [Quit: All this computer hacking is making me thirsty. I think I'll order a Tab.]
centrx has joined #ruby-lang
benanne has quit [Quit: kbai]
Miphix has joined #ruby-lang
hahuang65 has joined #ruby-lang
sheperson_ has joined #ruby-lang
sheperson has quit [Ping timeout: 252 seconds]
sheperson_ is now known as sheperson
amorphid has joined #ruby-lang
<amorphid>
Hey there, anyone available for a quick chat about test driven, OO programming in Ruby? Want to bounce a few questions about a couple different approaches
Sunnyan has joined #ruby-lang
<pipework>
amorphid: Your best bet is to just ask your question in full here and hope someone answers rather than wait to see if someone wants to help.
<amorphid>
pipework: thanks. just figured my questions might be a bit off topic, but let's try...
dingus_khan has joined #ruby-lang
<amorphid>
Here's the situation. Have 4 years of self taught Ruby experience, and just started applying to jobs at product building startups. They'll ask me whiteboard questions like "how would you build TicTacToe", or "solve this puzzle".
<amorphid>
But the put me on the spot, and I'm not used to thinking about programming that way.
<amorphid>
So just wanted to ask how people in an interview normally frame their response for a question like that, so I can get used to thinking about it in an OO manner
<amorphid>
normally I start w/ tests, or some simple procedural code, but I'm taking too long, and interviewer gets frustrated (and I don't get the job)
dingus_khan has quit [Ping timeout: 264 seconds]
<amorphid>
So my question is... How would you think about writing TicTacToe, especially in an interview? They pont isn't to solve it, I just wanna demonstrate can think about it.
Sunnyan has quit [Ping timeout: 245 seconds]
Sunnyan has joined #ruby-lang
bubodlack is now known as bubodlack|away
<pipework>
amorphid: I'd probably assume a multidimensional array and work towards filling that out and checking the 'grid' starting from the top middle to the left center, then the center center, etc.
toastynerd has quit [Remote host closed the connection]
<pipework>
amorphid: If the interviewer doesn't like tests, walk out the door.
<pipework>
In fact, run.
<amorphid>
that's probably not bad advice
<amorphid>
maybe I'm already on the right track. I told one interview I didn't like his question, he asked me to propose an alternative, and we did that. Got a second round. maybe I'm trying to optimize crappy interviews, which is a failing strategy
toastynerd has joined #ruby-lang
<pipework>
amorphid: It's really a tough thing, because most companies suck really bad at interviewing.
<amorphid>
ok, then I'm just learning to play the game. I'l just push through it.
<pipework>
So you either leave because they can't interview or you stay and hope they're better at what they do because they suck at interviewing. It's hard to choose.
bubodlack|away is now known as bubodlack
<pipework>
I've walked out of a few interviews myself because if they couldn't be bothered to make a good interview, I become disheartened and don't want to work with them.
<pipework>
Better safe than sorry, for them and myself.
danijoo has quit [Read error: Connection reset by peer]
<pipework>
amorphid: When presented with whiteboard questions, I generally talk about how to best solve the problem algorithmically. I hate whiteboarding code and openly let the interviewer know that I would rather conclude the interview than be subjected to that.
danijoo has joined #ruby-lang
<pipework>
Sometimes they switch and other times they're flabbergasted and we end the interview.
<amorphid>
OK, thanks. I'll try standing up for myself a bit.
iamcalledrob has joined #ruby-lang
sheperson has quit [Quit: sheperson]
iamcalledrob has quit [Ping timeout: 258 seconds]
franzip has joined #ruby-lang
Sunnyan has quit [Ping timeout: 240 seconds]
yfeldblum has joined #ruby-lang
flori has quit [Remote host closed the connection]
flori has joined #ruby-lang
<certainty>
amorphid: for tictactoe it's relatively easy to generate all possible states along with their successor states. You can evaluate each state as you build it if it's winning,losing or draw. Once you have that game tree it's simply a matter of searching it for the current state and following down that path. That's a common way to implement it i guess. I vaguely recall that from AIMA.
<certainty>
an improvement would be to apply minmax
<pipework>
certainty: neat.
toastynerd has quit [Remote host closed the connection]
pskosinski has joined #ruby-lang
michaeldeol_ has joined #ruby-lang
relix has joined #ruby-lang
michaeldeol_ has left #ruby-lang [#ruby-lang]
<certainty>
pipework: yeah minimax is a simple yet neat idea. It works well for these kinds of games that have a limited search space
<certainty>
also though not strictly needed on could do well without a two dimensional array. You can simply use a one-dimensional array and simply label the cells from 1 to 9. Alternatively you can encode a gamestate in a single byte. Setting the bits that correspond to an occupied field to one and the rest to zero
<pipework>
certainty: I learned about minmax_by the other day, haven't used it or minmax yet.
Rylee has quit [Excess Flood]
starbucks has joined #ruby-lang
<pipework>
certainty: I've done the single array, but I rather enjoy the math that you use to find neighbors in a multidimensional array.