Skip to content

Instantly share code, notes, and snippets.

@fredjean
Forked from ahoward/quiz-1.md
Created September 26, 2012 15:52
Show Gist options
  • Save fredjean/3788826 to your computer and use it in GitHub Desktop.
Save fredjean/3788826 to your computer and use it in GitHub Desktop.
quiz-1.md
So you think you wanna be a web developer...

Fork this, update your copy with answers.

They don't need to be precise - pseudo-code is fine in most cases.

Some questions don't have correct answers.


Submit your answers to ara@dojo4.com


  FROM: you@yeraaddy.com

  SUBJECT: [dojo4-quiz] quiz-1

  BODY:

    https://gist.github.com/to-your-submission






==========================================================

  1. is this broken in html5? if so why? ==========================================================
  <div id='teh_javascripts' />

The spec does not allow "self-closing" tags. In HTML5, this means ends up meaning <div id='teh_javascripts'>

leading to an unclosed tag.

The reality though is that the browsers' rendering engines are designed to assume that the developers don't know what they are doing and will try to render it anyway.

========================================================== 2. write an http GET request for the url

  'http://domain.com:4242/foo/bar/baz.html'

GET /foo/bar/baz.html HTTP/1.1
Host: domain.com

========================================================== 3. in any language you choose, write this to run in parallel

  numbers = 20, 1

  results = []

  numbers.each do |number|
    results.push( parallelize{ number * 2 } )
  end


  sum = reduce( results )

teh answerz...

========================================================== 4. in any language you choose, write this to run in parallel on multiple cores

  numbers = 20, 1

  results = []

  numbers.each do |number|
    results.push( parallelize{ number * 2 } )
  end


  sum = reduce( results )

teh answerz...

========================================================== 5. is this broken in html5?, why?

  <label for='user.email'>
  <input name='user.email'>

teh answerz...

========================================================== 6. what is value of 'status'

  if @not_modified
    render :status => status
  end

In this context, it is probably undefined ;) However, the HTTP spec would expect the status to be 304 NOT MODIFIED. This tells the browser to use the cached copy.

========================================================== 7. is this javascript broken? if so, why?

  var submit = document.getElementById("submit");

  submit.click();

teh answerz...

========================================================== 8. which is better? why?

<!-- A -->

  <table>
    <tr>
      <td class='key' style='width:33%'>
        {{ dynamic_content_for(:key) }}
      </td>
      <td class='val'>
        {{ dynamic_content_for(:val) }}
      </td>
    </tr>
  </table>

<!-- B -->

  <div class='fluid grid'>
    <div class='row'>
      <span class='key width33'>
        {{ dynamic_content_for(:key) }}
      </span>
      <span class='val'>
        {{ dynamic_content_for(:val) }}
      </span>
    </div>
  </div>

The table cells will expand horizontally until it can't anymore. Afterwards, the td's content would wrap. The span would either expand as far as it can or would push some content down. Keeping the size of the spans in sync is much harder.

It is perfectly fine to use table for tabular data.

========================================================== 9. which is better? why?

# A

  if var == 42
    "..."
  end

# B

  if 42 == var
    "..."
  end

teh answerz...

========================================================== 10. describe steps to debug this problem

  @response =
    http_request(url, :method => method, :params => params, :headers => headers)

  if @response.ok?
    ship_it!
  else
    debugger!
  end

teh answerz...

========================================================== 11. which is better? why?

# A

  if foo.bar.baz
    '...'
  end

# B

  if foo
    if foo.bar
      if foo.bar.baz
        '...'
      end
    end
  end

teh answerz...

========================================================== 12. is this javascript broken? if so, why?

  ajax(url)({

    'method'  : 'POST',

    'params'  : params,

    'headers' : headers

  });

teh answerz...

========================================================== 13. what color is this?

  '#FFE'

teh answerz...

========================================================== 14. what number is this?

  0b101010

teh answerz...

========================================================== 15. describe an algorithm to detect the 'edges' in these pixels

  0 0 0 0 0 0 
  0 0 1 1 1 0 
  0 1 1 1 1 0 
  0 1 1 1 0 0 
  0 0 0 0 0 0 


teh answerz...

========================================================== 15. what does @X represent?

  $color = [@X, @R, @G, @B].as_hex

 

teh answerz...

========================================================== 16. what are the advantages of static linking?

  export HINT=$LD_RUN_PATH

teh answerz...

========================================================== 17. wtf is this javascript doing?

     var uploader = new qq.FileUploader(options);

     var image_ids = [];

     uploader._uploadFileList = function(){
       image_ids = [];
       var args = Array.prototype.slice.call(arguments);
       var result = qq.FileUploaderBasic.prototype._uploadFileList.apply(uploader, args);
       return(result);
     };

teh answerz...

========================================================== 18. what does this code do?

  jQuery('.help').find('a').attr('tabindex', '-1');

teh answerz...

========================================================== 19. how would you solve this problem?

  ~ > run_api_tests_locally


    "FAIL: you must access teh API from a box on EC2 with IP 1.2.3.4!"


teh answerz...

========================================================== 20. which is better? why?

// A

  User.prototype.first_name = function(){
    return this.name.split(/\s+/)[0];
  };

// B

  User.prototype.first_name = function(){
    return User.first_name_for(this.name);
  };

  User.first_name_for = function(name){
    return name.split(/\s+/)[0];
  };

teh answerz...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment