« first day (718 days earlier)      last day (4227 days later) » 

9:04 PM
Here's an interesting question:
 
How would you describe a rock-paper-scissors relationship between 3 items?
2
Say you have Hand::ROCK, Hand::PAPER and Hand::SCISSORS, how would you describe it so compareHands($hand1, $hand2) would give the expected result?
(Without ifs or switches, that's easy)
 
are ternary operators cheating?
 
you could assign a number to each: 1,2,3 and then check if numa=numb+1 return numa else return numb
no that doesn't work
 
that's using an if statement anyway
okay well lets see
Rock beats scissors
Scissors beats paper
Paper beats rock
 
9:17 PM
May ask this as a proper question on Stack Overflow
Seems interesting
 
i actually know one way its doable
i think multiple
seems harder than it is though
 
hold on
i'll make a codepad to determine if im right
also that might be better on codegolf.se
 
I'm trying to mock against a class that calls curl directly. I have the following, but calling the mock method always returns null. Can someone point me to what I'm doing wrong?

$mockApi = $this->getMockBuilder('ContactologyAPI')
				->disableOriginalConstructor()
				->setMethods(array('Contact_Add_Email'))
				->getMock();
$mockApi->expects($this->at(0))
		->method('Contact_Add_Email')
		->with($this->equalTo($email))
		->will($this->returnValue($expectedData));
 
@MadaraUchiha viperpad.com/X0fDyL
2
there's your solution
one way anyway
 
9:23 PM
Interesting
 
is this a question you ran into somewhere and didn't know how to solve
or were you just curious how people would solve it?
 
Kinda both
Right now we use an IF based strucutre
And I want to improve it badly
In theory, it's a rock paper scissors,
 
you solve rock paper scissors in production code? :P
 
In reality is looks more like this:
@Lusitanian Ever played Pokemon?
 
a loong loong time ago
 
9:30 PM
It's closer to the relationship between the different elements there
Than it is to rock paper scissors
 
@Lusitanian Why are you doing intval()?
 
You can imagine the kind of if structure I have going on there
 
@PeeHaa to rturn the number of the hand who won
@MadaraUchiha viperpad.com/b5pXlO
there's another way --- oop style
 
I'm leaving for the night, but any assistance to my mocking question would be greatly appreciated
 
0
A: How can one describe a rock-paper-scissors relationship between 3 items?

LusitanianFrom PHP chat OOP-style <?php interface Hand { function beats(Hand $hand); } class Rock implements Hand { public function beats(Hand $hand) { return $hand instanceOf Scissors; } } class Paper implements Hand { public function beats(Hand $hand) { retur...

anyway
that's a good question
 
9:35 PM
@Lusitanian instanceOf ... :(
 
@Lusitanian I actually like your procedural style better (as it clearly defines what beats what, and then finishes the comparison with one line).
The definition should be fat, and the comparison itself, thin.
At least that's my perspective
(The code should be OOP though, still tagged it as OOP :D)
 
@Lusitanian i need to understand your codes(i'm kind a newbie) in this question
 
@NikiC BUT IT ENABLES CODE COMPLETION IN PHPSTORM
yeah i know that one kinda sucked
 
my point is why do you put beat metod in hand, i think it should be serperated from hand because in the future maybe you want to add some new features like this
and everytime you do this won't you need to modify your code?
 
nah, the hand should be able to determine who it can beat
my implementation sucked though
 
9:40 PM
@draconis A Hand will always beat another hand
 
@MadaraUchiha Additionally one could argue that the OO code is less extensible. E.g. if you want to use an extension of the game (with more hands) you would need to modify the classes themselves. That's why I think that the beats method does not belong to the hands and should rather be a separate concern
 
yes but let's think game will be improved and it will be like this :
 
@Lusitanian I was referring to the case ;) The Of.
 
@NikiC A different object perhaps?
Referee class?
 
@NikiC lol --- but it still sucks regardless of how it is cased
 
9:41 PM
@Lusitanian But the case is the annoying part :P
 
hahaha ok fine
 
is a coding style nazi
 
and you're german
 
My hand is already twitching and want to click the "edit" button
 
http://4.bp.blogspot.com/_wCzCY93mKq0/TFJHFjZd2jI/AAAAAAAABVI/7cAz1surslY/s1600/Advanced+Rock+Paper+Scissors.jpg
this is dummy example but let's think game evolved to this, you will need to modify beat method all the time right?
 
9:42 PM
@NikiC so lol do it
 
@Lusitanian Hehe, bad joke removed in time ^^
 
so i think who beats who should be handled by another class, but as i said im newbie
correct me if i'm wrong.
 
@draconis Nah, sounds pretty accurate to me.
Defining who wins should only be done once.
 
@NikiC that wasn't a joke -- and i'm still scared ):
 
@draconis Also, Air does not beat Fire.
 
9:45 PM
air fuels fire
 
@MadaraUchiha yes, that was my point, current codes of @Lusitanian seems a bit tightly coupled to me
 
it is, i didn't like that at all
 
I'll leave the question to cook for the night
 
air beats em all btw(see: aang)
 
I'm off to bed folks
Cya tomorrow.
 
9:46 PM
Bye.
 
niht
 
@draconis Aang isn't fair, Aang has all 4 + weird YinYang bending!
Pit Aang against me (Google for Madara Uchiha), and we'll see who wins.
 
:)
 
@NikiC i'm just waiting for "code in your question has been edited"
 
@Lusitanian Okay, it's fixed now :D
ahhh no there is still one wrong whitespace
 
9:49 PM
nice summary
 
omfg, and it uses tabs!
 
Did I hear someone is using tabs?
 
no i did not use tabs.
 
Release the hounds
 
woot
I use the tab key
 
9:51 PM
 
@Lusitanian I have proof! stackoverflow.com/revisions/…
 
omg
where'd the
nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo‌​ooooooooo
andddddddddddddd that's another one for the (removed)
 
@Lusitanian You have a lot of these :D
 
No no, it's too late, I saw it!
(hello all)
 
permanent retention scares me @NikiC
hey @DaveRandom
this message will still exist 10 years from now
 
9:54 PM
Everyone has seen it. Now we know @Lusitanian for real :P
 
hahahahaha
it's okay, your name is nikita and you are therefore a girl
and you therefore don't actually exist
 
@Lusitanian It does indeed:
 
What, girls don't exist?
 
On the internet.
@NikiC lol
 
3 mins ago, by Lusitanian
accidentally using tabs in code is like sleeping with a guy by mistake and realizing it the next morning --- but that's not from personal experience
 
9:57 PM
@NikiC why are you forging messages with my nickname attached?
 
^- that's the right one
 
not cool >:C
 
I'm not forging. I'm just cheating the system :P
 
lolol
i still think every apple (and android) fanboy should watch this
 
9:59 PM
@NikiC ______________what_________________ is that
 
@NikiC I can't work out how you did that, I thought I knew but he no worky :-(
 
@DaveRandom magic
also, stop posting videos
you're breaking my firefox nightly build
 
@NikiC Get a proper browser then. If only there was some kind of useful kit for using the web, a web-kit, if you will...
 
a "web-kit"? tell me more
 
the only good part of webkit is the WTF framework
 
@Lusitanian Well I envisage that you could make all sort of shiny, make it out of some kind of shiny metal, like maybe chrome?
 
@DaveRandom or perhaps element #24?
hm
 
I consider the metal Chromium to be better than Chrome.
 
anyone here ever ran into a toolkit for creating a simple DSL in php?
 
preg :P
 
10:08 PM
-______________________-
meh, i'll just have to write a lexer
 
you only need a lexer?
if you need a lexer I might have something for you :)
 
quite possibly
i need to write a spec first
but i'm basically going to create an exceptionally simple language for reporting in an application i've written
 
I was going to make a crack about Lex Luther then but I couldn't even type it out it was that bad. Maybe my time on the naughty step last night has done me some good.
 
this is where i need compsci knowledge though --- a lexer will handle regular grammars and a parser will handle CFG, right?
 
hum, I wanted to put my lexer stuff on github, but forgot about it :/
 
10:12 PM
The problem is I don't want this DSL to end up on TDWTF someday for being so f'ed up in both implementation and usage that it's pathetic......................which is the direction I'm probably currently heading in.
@NikiC I was going to put my NLP stuff on github, it looks like this: viperpad.com/X4t6wg
 
NLP?
 
natural language processing
as you can see, it's a very powerful algorithm
 
@DaveRandom The cv links should be expanded to also include /review links
 
11:02 PM
hi, i'm trying to get my head around something. i have a page that's a cost calculator that's generated by php with a javascript on it
i need to add a promo code field to it
what is the best way to check if the promo code matches a string without it being open to everyone?
 
@UnoMeinAme Check it with PHP, and limit the number of tries.
 
is there a way to check it without reloading the page?
and more importantly without forcing the user to press submit
 
I'm going to bed, see you later!
 
@UnoMeinAme AJAX.
 
i think you've just pointed me to the right direction. thanks. nighty night :)
 

« first day (718 days earlier)      last day (4227 days later) »