Be Excellent To Each Other

And, you know, party on. Dude.

All times are UTC [ DST ]




Reply to topic  [ 46 posts ] 
Author Message
 Post subject: Interview Quiz
PostPosted: Mon Mar 01, 2010 16:15 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
Hello!
I am interviewing new code monkeys. The test we currently give code monkeys to fill in is OLD and DULL. Here is one of the current questions:
Code:
What is the output of the following code?
<?
function r($p) {
   if ($p==1) {
      return 1;
   } else {
      return $p*r($p-1);
   }
}
echo r(5);
?>


Here is another:
Code:
There are no errors when the following code is executed but is does not function as expected.  What is missing?

   $user = array(   1 => array('name' => 'john',  'email' => '[email protected]'),
         2 => array('name' => 'barry', 'email' => '[email protected]'),
         3 => array('name' => 'bob',   'email' => '[email protected]'));

   //LIST EMAILS
   while (list($id, $user_array) = each($user)) {
      print $user_array['email']."<br>";
   }
   
   
   //LIST NAMES
   while (list($id, $user_array) = each($user)) {
      print $user_array['name']."<br>";
   }


I need various questions, because I want everyone to get some right and some wrong. I've written the easy ones, but writing harder ones is more difficult because something I find hard might be easy to someone else, and vice-versa.

So, if any of you can thing of a hard question about PHP (specifically OO-type stuff), MySQL, Javascript or CSS that can be answered without having to write an essay, I would be interested in seeing them.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Mon Mar 01, 2010 17:41 
Awesome
User avatar
Yes

Joined: 6th Apr, 2008
Posts: 12334
For CSS get them to tell you the width of a box in IE with padding and borders applied or similar?

_________________
Always proof read carefully in case you any words out


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Mon Mar 01, 2010 18:02 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
http://fizzbuzz.rubyforge.org/ - except in PHP, obv.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Mon Mar 01, 2010 18:06 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
What does this code output (the number of people I know who don't understand the ternary operator is staggering):

Code:
$foo = 1;
$bar = 2;
echo ($foo == 2) ? $bar : $foo;


Why doesn't the following code print the message over two lines, as you would expect? (strings in single quotes don't evaluate special characters like \r\n)
Code:
header('Content-Type: text/plain');
echo 'Hello\r\n';
echo 'World!';


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Mon Mar 01, 2010 18:08 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
I already have a question about the ternary operator (they have to write one). I will yoink the second one.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 11:15 
User avatar
Comfortably Dumb

Joined: 30th Mar, 2008
Posts: 12034
Location: Sunny Stoke
I'm still a learner at all this PHP stuff but I understood Grim...'s question on the array pointer thing and I've seen the ternary operator used a bit (I must admit, I still write stuff out the long way as I find it easier to follow).

However, what's the best way to learn more on this stuff? Are you two purely self-taught or are there some decent books/courses out there? I only get to dabble in this stuff from time to time in this job, but it'd be nice to be doing things properly rather than cobbling bits of code together till it works. :)

_________________
Consolemad | Under Logic
Curse, the day is long
Realise you don't belong


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 11:28 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
devilman wrote:
cobbling bits of code together till it works. :)

That's how I learnt ;)

Pick something way out of your comfort zone (I wrote a forum), and make it. It'll take ages and it'll be shit, but when you make the next one it'll be better.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:16 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
Yup, agree with Grim. I'm entirely self taught. PHP makes it ridiculously easy to write terrible and insecure code, but once you read up on best practices you start to get better at it. Been doing it for 9 years now. Jesus.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:20 
User avatar
Comfortably Dumb

Joined: 30th Mar, 2008
Posts: 12034
Location: Sunny Stoke
GazChap wrote:
Yup, agree with Grim. I'm entirely self taught. PHP makes it ridiculously easy to write terrible and insecure code, but once you read up on best practices you start to get better at it. Been doing it for 9 years now. Jesus.


The security thing is something I'm always trying to address, especially as some of the stuff I do is related to HR type stuff so data protection and all that. Saying that, I had a poke around a competitor's system recently and found a big security/privacy flaw within five minutes so at at least it's not just me who is amateurish at this. ;)

_________________
Consolemad | Under Logic
Curse, the day is long
Realise you don't belong


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:26 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
I've started to point-blank refuse to work with PHP code written by other agencies because it seems that for every one that actually knows what they're doing, there's another 1,000 that don't.

I've seen all sorts of stupid shit. Storing credit card numbers in plain text in a mySQL database, storing passwords in plain text, and then this (which isn't a security or privacy issue, but is just retarded) written by my predecessor here before he was expunged:

Code:
$comma = ",";
$text = "Hello" . $comma . "\r\nThis is a confirmation e-mail to confirm that you" . $comma . " " . $name . "" . $comma . " have requested information from our website.";

(text paraphrased)


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:28 
User avatar
baron of techno

Joined: 30th Mar, 2008
Posts: 24136
Location: fife
It looks like a retarded language if it forces you to do things like that :S


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:29 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
Bwuh?
What was he doing?

kalmar wrote:
It looks like a retarded language if it forces you to do things like that :S

It doesn't.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:30 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
GazChap wrote:
Code:
$comma = ",";
$text = "Hello" . $comma . "\r\nThis is a confirmation e-mail to confirm that you" . $comma . " " . $name . "" . $comma . " have requested information from our website.";

(text paraphrased)


:S

That's, erm, special.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:31 
User avatar
Comfortably Dumb

Joined: 30th Mar, 2008
Posts: 12034
Location: Sunny Stoke
kalmar wrote:
It looks like a retarded language if it forces you to do things like that :S


It's not the language that's retarded in this case. :)

_________________
Consolemad | Under Logic
Curse, the day is long
Realise you don't belong


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:31 
User avatar
Unpossible!

Joined: 27th Jun, 2008
Posts: 38652
Possible :boots: here

I'm no coder, but couldn't he just put the comma inside the quotes?


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:32 
User avatar
baron of techno

Joined: 30th Mar, 2008
Posts: 24136
Location: fife
You'd think so wouldn't you? Does it not allow that?


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:32 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
Yeah, that's what's retarded about it.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:34 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
GazChap wrote:
Yeah, that's what's retarded about it.


With levels of weirdness that great, I'm surprised he didn't set up variables for every single character.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:36 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
What's especially weird about it is that he didn't create a variable for \r\n. I could almost understand creating a variable for \r\n because languages like Visual Basic have vbCrLf variables, but for a comma? Madness.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 12:38 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
GazChap wrote:
What's especially weird about it is that he didn't create a variable for \r\n. I could almost understand creating a variable for \r\n because languages like Visual Basic have vbCrLf variables, but for a comma? Madness.

Yeah, I thought that. Nutbar.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:40 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
devilman wrote:
The security thing is something I'm always trying to address, especially as some of the stuff I do is related to HR type stuff so data protection and all that. Saying that, I had a poke around a competitor's system recently and found a big security/privacy flaw within five minutes so at at least it's not just me who is amateurish at this. ;)


And in another twist of fate, a guy I'm dealing with now has set up a subfolder on his domain to contain fairly sensitive information. There's no security on it, but no matter, because he's going to give the folder an obscure name and turn off spider-crawling. Sorted!


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:42 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
I made that mistake once a few years ago, never again.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:43 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
GazChap wrote:
I made that mistake once a few years ago, never again.


Do elaborate, chap!


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:44 
User avatar

Joined: 30th Mar, 2008
Posts: 32624
To be fair, should the English language ever adopt a different character to replace the comma, his code is robust againt the change.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:46 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
Doctor Glyndwr wrote:
To be fair, should the English language ever adopt a different character to replace the comma, his code is robust againt the change.


Let's replace it with a SarcMark.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:51 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
The client wanted enquiries from their contact form sent via e-mail and a HTML version to be created in an area for them to access. I didn't do it how I should have done it, and had a HTML template populated by entries from a database, I created flat HTML files and stored them in a directory on the server. A web-accessible directory.

Didn't think about that though, as I'd programmed a back-end interface that was password protected that would pull the HTML files through for them. So in my mind, it was secure.

Search engine found the directory, which didn't have indexing disabled, indexed all the enquiries and lo-and-behold loads of people's personal details were now on Google.

Whoops.

Fortunately we got it all removed pretty damn quickly and I held my hands up to being the cause of the problem, which I think impressed both the client and the boss as I didn't try and bullshit my way out of it. Yeah, not making that mistake again.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:52 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
GazChap wrote:
Search engine found the directory, which didn't have indexing disabled, indexed all the enquiries and lo-and-behold loads of people's personal details were now on Google.

Yeek.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:53 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
Grim... wrote:
GazChap wrote:
Search engine found the directory, which didn't have indexing disabled, indexed all the enquiries and lo-and-behold loads of people's personal details were now on Google.

Yeek.


Eep.

How are you getting on with your questions, Grim...?


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 14:58 
User avatar
Comfortably Dumb

Joined: 30th Mar, 2008
Posts: 12034
Location: Sunny Stoke
GazChap wrote:
Search engine found the directory, which didn't have indexing disabled, indexed all the enquiries and lo-and-behold loads of people's personal details were now on Google.


Bugger. Thankfully, the only thing I've done like that so far was to expose an unfinished version of the company's website to search engine spiders so that as well as the live site being listed, all the half-done experimental layout and content showed up too.

Turns out that some idiot had left a link to this beta version of the site in his post asking for advice a while back. When it came up in a meeting, an external SEO type guy checked to see what links were pointing at the beta, I cringed when I saw the Beex url. Projected on the screen.

_________________
Consolemad | Under Logic
Curse, the day is long
Realise you don't belong


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:07 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
Malabar Front wrote:
Grim... wrote:
GazChap wrote:
Search engine found the directory, which didn't have indexing disabled, indexed all the enquiries and lo-and-behold loads of people's personal details were now on Google.

Yeek.


Eep.

How are you getting on with your questions, Grim...?

Oh, I did them.

Hang on, I'll upload the document.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:08 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
Grim... wrote:
GazChap wrote:
Search engine found the directory, which didn't have indexing disabled, indexed all the enquiries and lo-and-behold loads of people's personal details were now on Google.

Yeek.

That's about the size of it. As I said, PHP makes it hiliariously easy to write code that's terribly insecure, but even the most secure code in the world won't help if the person writing it is a numpty.

I'm not a numpty any more.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:10 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
Attachment:
Test.pdf


You do not have the required permissions to view the files attached to this post.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:20 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
Some good shit there, mind if I crib some of those if I ever need to do any interviews here?

Also, question 1.5.2 - no way have you left enough room for that answer ;)


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:24 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
GazChap wrote:
Some good shit there, mind if I crib some of those if I ever need to do any interviews here?
Knock yourself out.

GazChap wrote:
Also, question 1.5.2 - no way have you left enough room for that answer ;)
10^100, innit?

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:31 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
Quote:
10^100, innit?

You just know someone (probably me) would be smarmy enough to try and fit all of the zeroes in that space.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:39 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
Oh, and on 1.3.4 - is that a "trick" question to see if people think of the simple answer before they think of a complex one?


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:41 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
GazChap wrote:
Oh, and on 1.3.4 - is that a "trick" question to see if people think of the simple answer before they think of a complex one?

I'd be happy either way. A lot of questions are like that. I'm just as interested in how people did things than if they got things right.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:47 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
I really, really don't know PHP. I can get the gist of a fair bit of that, but rarely enough to answer with any conviction. It's the very simple language-specific things holding me back.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 15:48 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
What happened to question 6 after 1.1.5?


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 16:05 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
GazChap wrote:
What happened to question 6 after 1.1.5?

It's missing. Only one interviewee noticed (or noticed and had the balls to mention it, which is what I wanted).

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 16:06 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
What have people answered about the Facebook question? And did anyone draw a good pig?


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 16:29 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
They all said "No", which is interesting.
It doesn't matter if the pig is good.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 16:33 
User avatar
Part physicist, part WARLORD

Joined: 2nd Apr, 2008
Posts: 13421
Location: Chester, UK
Grim... wrote:
They all said "No", which is interesting.
It doesn't matter if the pig is good.


What were you looking for in the Facebook question?

I'm reasonably sure I'd have answered along the lines of ‘Yes. I believe in judging employees by the quality of their work, not what they're doing at every second during work hours. That said, if it gets in the way of their work, it should certainly not be allowed. Keep your employees happy, and they generally perform better.’ But I could cave into giving you the answer I think you'd want which, for most large companies, is a firm ‘NO!’

Hmm.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 16:34 
User avatar

Joined: 30th Mar, 2008
Posts: 14367
Location: Shropshire, UK
Given that I've recently started doing Facebook apps here at work, I would answer "Yes" to that question ;)


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 16:44 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69713
Location: Your Mum
Malabar Front wrote:
‘Yes. I believe in judging employees by the quality of their work, not what they're doing at every second during work hours. That said, if it gets in the way of their work, it should certainly not be allowed. Keep your employees happy, and they generally perform better.’

That would be my opinion on the matter.
Again, there's no 'wrong' answer though, really.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: Interview Quiz
PostPosted: Wed Mar 03, 2010 18:01 
User avatar
Heavy Metal Tough Guy

Joined: 31st Mar, 2008
Posts: 6607
Have you seen this thingy Grim...? It's supposed to be a sort of automated version of some of what you're trying to do. I've given the demo a go, but we haven't actually used the main app yet.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 46 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Columbo, The Greys and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search within this thread:
You are using the 'Ted' forum. Bill doesn't really exist any more. Bogus!
Want to help out with the hosting / advertising costs? That's very nice of you.
Are you on a mobile phone? Try http://beex.co.uk/m/
RIP, Owen. RIP, MrC. RIP, Dimmers.

Powered by a very Grim... version of phpBB © 2000, 2002, 2005, 2007 phpBB Group.