a guest Oct 19th, 2019 147 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. **PLEASE NOTE: We'd prefer you send your answers to rather than post them publicly in another Gist or in comments on this Gist ;-)**
  3. ### 1. Voting
  5. Each voter can vote in zero or more referenda. Each referendum has one or more questions, and each question is a yes/no vote. Write the simplest normalized schema to describe this in generic SQL statements or as an entity-relationship diagram. Point out where the indexes would be if you want to quickly know the results of a given referendum question, but you never expect to query a single voter's voting record.
  7. ### 2. Availability on AWS
  9. Your client plans to host their web application on AWS. When would you advise (a) deployment in a single availability zone, (b) deployment in multiple availability zones in a single region (c) deployment in multiple regions? What operational difficulty or complexity, if any, is added as you go from (a) to (b) to (c)?
  11. ### 3. Lies, damn lies, and git
  13. You're working on a cool branch of the foobar project, and your branch contains two commits A and B. The git lineage is:
  14. ```
  15. X -- Y -- Z <-- master
  16.            \
  17.             A -- B <-- your-cool-branch
  18. ```
  19. You want to contribute the code back to the master foobar repo, but you realize there is a really dumb typo in one of your source code comments in commit A. You'd still like to submit the pull request as two commits A' and B', where A' is the fixed version of A, and B' is the same exact diff as B. How do you rewrite git history to make this happen? Is B' the same hash as B? Why or why not?
  21. ### 4. Ruby metaprogramming
  23. What's `Module.included`? What is a common (meta-)programming construct in which it is used? Give an example and explain exactly what's going on.
  25. ### 5. Someone did something dumb
  27. New code was released to multi-tier production environment and now the site is SO slow. But it worked great on the single-server staging environment, which has only half the CPU and half the RAM of the production servers!
  29. Here's the code that's behaving poorly:
  31.     class Post < ActiveRecord::Base
  32.       def comments
  33.         comment_ids = Comment.where("post_id = ?", { |c| }
  34. { |comment_id| Comment.find_by_id(comment_id) }
  35.       end
  36.     end
  38. What's wrong? And why did it work well (enough) on the staging server?
  40. Obviously the person who wrote this isn't a Rails programmer. How would a Rails programmer have written the code?
  42. ### 6. Unix tools
  44. In one Unix command, find all of the files in `/usr/local` whose contents contain the word "aardvark" (case-insensitive), and list them all in order from most-recently created to least-recently created.
  46. ### 7. CSS
  48. Usage of the "!important" CSS declaration is often frowned upon by front-end developers. What does the "!important" CSS declaration do? Why do front-end developers suggest using it with caution? What are some cases in which it makes sense to use it?
  50. ### 8. JavaScript
  52. Take a look at the following:
  54. ```
  55. function *foo(x) {
  56.   while (x < 4) {
  57.     x += yield x;
  58.   }
  59.   return x;
  60. }
  61. var bar = foo(3);
  62. console.log( );
  63. console.log( );
  64. console.log( );
  65. ```
  66. What is the output of this code snippet, and why does it behave in the way it does?
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand