Koolaidrain

LinkedIn Questions

Dec 16th, 2015
1,437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.74 KB | None | 0 0
  1. ------ Web Architecture and Design Knowledge
  2.  
  3. What happens after you enter "ssh _host name_" into the command line?
  4.  
  5. It's your first day on the job as an Ops guy.
  6. What monitoring do you begin to put in place on the site in the first week?
  7. ...Month? Quarter? What do you track?
  8.  
  9. You have a lot of production servers and a giant data set that will be updated consistently over time.
  10. The data set is updated 4 times per day. How do you get all your production servers up to date consistently, automated?
  11. ...First job doesn't finish before the second. What do you do?
  12.  
  13. ------ Systems and Architecture
  14.  
  15. You're running a static site on one server. Latency is high and some connections don't go through. What do you do?
  16. (Apache parallelization of worker tasks, redundancy in the static assets on different hard disks to parallelize content access)
  17.  
  18. Now you're running a large distributed service that takes content from a bunch of other services in order to return content. One of these services goes down often. Besides fixing their side of things, what can you do to mitigate losses on your side of the content?
  19.  
  20. You have a set of machines with the best hardware available to you. Your service is keeping track of user actions over time, though you're beginning to run out of memory to store this stuff in your database, and your service is getting slower. What do you do?
  21.  
  22. -------------------------------
  23.  
  24. This is just a simple shared plaintext pad, with no execution capabilities.
  25.  
  26. When you know what language you'd like to use for your interview,
  27. simply choose it from the dropdown in the top bar.
  28.  
  29. You can also change the default language your pads are created with
  30. in your account settings: https://coderpad.io/profile
  31.  
  32. Enjoy your interview!
  33.  
  34. """
  35. Write a program which prints out all numbers between 1 and 100. When the program would print out a number exactly divisible by 4, print "Linked" instead. When it would print out a number exactly divisible by 6, print "In" instead. When it would print out a number exactly divisible by both 4 and 6, print "LinkedIn" instead.
  36. """
  37.  
  38. for x in range(1, 100):
  39. if x % 4 == 0 and x % 6 == 0:
  40. print "LinkedIn"
  41. continue
  42. elif x % 4 == 0:
  43. print "Linked"
  44. continue
  45. elif x % 6 == 0:
  46. print "In"
  47. continue
  48. print x
  49.  
  50. """
  51. Below, see a sample of /var/log/messages.
  52. ---------- begin sample log extract ----------
  53. Jan 20 03:25:08 fakehost logrotate: ALERT exited abnormally with [1]
  54. Jan 20 03:25:09 fakehost run-parts(/etc/cron.daily)[20447]: finished logrotate
  55. Jan 20 03:26:21 fakehost anacron[28969]: Job 'cron.daily' terminated
  56. Jan 20 03:26:22 fakehost anacron[28969]: Normal exit (1 job run)
  57. Jan 20 03:30:01 fakehost CROND[31462]: (root) CMD (/usr/lib64/sa/sa1 1 1)
  58. Jan 20 03:30:01 fakehost CROND[31461]: (root) CMD (/var/system/bin/sys-cmd -F > /dev/null 2>&1)
  59. Jan 20 05:03:03 fakehost ntpd[3705]: synchronized to time.faux.biz, stratum 2
  60. Jan 20 05:20:01 fakehost rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="20438" x-info="http://www.rsyslog.com"] start
  61. Jan 20 05:22:04 fakehost cs3[31163]: Q: ".../bin/rsync -LD ": symlink has no referent: "/var/syscmds/fakehost/runit_scripts/etc/runit/service/superImportantService/run"#012Q: ".../bin/rsync -LD ": rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
  62. Jan 20 05:22:04 fakehost cs3[31163]: I: Last 2 quoted lines were generated by "/usr/local/bin/rsync -LD --recursive --delete --password-file=/var/syscmds/modules/rsync_password /var/syscmds/fakehost syscmds@fakehost::syscmds_rsync"
  63. Jan 20 05:22:08 fakehost cs3[31163]: Q: ".../sbin/sv restart": ok: run: /export/service/cool-service: (pid 32323) 0s
  64. Jan 20 05:22:08 fakehost cs3[31163]: I: Last 1 quoted lines were generated by "/sbin/sv restart /export/service/cool-service"
  65. Jan 20 05:22:09 fakehost cs3[31163]: R: cs3: The cool service on fakehost does not appear to be communicating with the cool service leader. Automating a restart of the cool service in attempt to resolve the communication problem.
  66. Jan 20 05:22:37 fakehost ACCT_ADD: WARNING: Manifest /var/syscmds/inputs/config-general/doit.txt has been processed already, bailing
  67. ---------- end sample log extract ----------
  68.  
  69. Write a script which parses /var/log/messages and generates a CSV with two columns: minute, number_of_messages in sorted time order.
  70.  
  71. ---------- begin sample output ----------
  72. minute, number_of_messages
  73. Jan 20 03:25,2
  74. Jan 20 03:26,2
  75. Jan 20 03:30,2
  76. Jan 20 05:03,1
  77. Jan 20 05:20,1
  78. Jan 20 05:22,6
  79. ---------- end sample output ------------
  80.  
  81. Extract the program name from the field between the hostname and the log message and output those values in columns.
  82. Sample Output (when run against the lines containing "Jan 20 05:2" in the log above):
  83. ---------- begin sample output ----------
  84. minute,total_count,rsyslogd,cs3,ACCT_ADD
  85. Jan 20 05:20,1,1,0,0
  86. Jan 20 05:22,6,0,5,1
  87. ---------- end sample output ------------
  88.  
  89. """
  90. #lines = f.readlines()
  91. #for line in f:
  92. # string.split(<char>)
  93.  
  94. f = open("/var/log/messages")
  95.  
  96. o = open("output.csv")
  97.  
  98. dict = {}
  99.  
  100. set = set()
  101.  
  102. for line in f:
  103. proc = line.split(" ")[4]
  104.  
  105. index1 = len(proc)
  106. index2 = len(proc)
  107. if "(" in proc:
  108. index1 = proc.indexof("(")
  109. if "[" in proc:
  110. index2 = proc.indexof("[")
  111.  
  112. proc = proc.substring(0, min(index1, index2))
  113. set.add(proc)
  114.  
  115.  
  116.  
  117. for line in f:
  118. #Jan 20 03:25:08 fakehost logrotate: ALERT exited abnormally with [1]
  119. arr = line.split(" ")
  120. key = arr[0]+arr[1]+arr[2].substring(0, len(arr[2])-3)
  121.  
  122. proc = arr[4]
  123. index1 = len(proc)
  124. index2 = len(proc)
  125. if "(" in proc:
  126. index1 = proc.indexof("(")
  127. if "[" in proc:
  128. index2 = proc.indexof("[")
  129.  
  130. proc = proc.substring(0, min(index1, index2))
  131.  
  132. if key not in dict:
  133. dict[key] = (1, )
  134. else:
  135. dict[key] += 1
  136.  
  137. f.close()
  138.  
  139. o.write("minute, number_of_messages" + ','.join(list(set)))
  140.  
  141. for key, value in dict.iteritems():
  142. o.write(key + "," + str(value))
  143.  
  144. o.close()
  145.  
  146. """
  147. Assume there is a REST API available at "http://www.linkedin.corp/api" for accessing employee information The employee information endpoint is "/employee/<id>" Each employee record you retrieve will be a JSON object with the following keys:
  148. 'name' refers to a String that contains the employee's first and last name
  149. 'title' refers to a String that contains the employee's job title
  150. 'reports' refers to an Array of Strings containing the IDs of the employee's direct reports
  151. Write a function that will take an employee ID and print out the entire hierarchy of employees under that employee.
  152. For example, suppose that Flynn Mackie's employee id is 'A123456789' and his only direct reports are Wesley Thomas and Nina Chiswick. If you provide 'A123456789' as input to your function, you will see the sample output below.
  153.  
  154. -----------Begin Sample Output--------------
  155. Flynn Mackie - Senior VP of Engineering
  156. Wesley Thomas - VP of Design
  157. Randall Cosmo xxxxxx - Director of Design
  158. Brenda Plager - Senior Designer
  159. Nina Chiswick - VP of Engineering
  160. Tommy Quinn - Director of Engineering
  161. Jake Farmer - Frontend Manager
  162. Liam Freeman - Junior Code Monkey
  163. Sheila Dunbar - Backend Manager
  164. Peter Young - Senior Code Cowboy
  165. -----------End Sample Output--------------
  166.  
  167. Employee IDs should consist of an alphabetical character, followed by 8 digits (e.g. A37208391, p00273611, etc.) Print out the employees whose employee_id does not conform with the standard.
  168. Don't worry about output formatting/spacing, you can just alter the behavior of your existing function to only print the relevant results.
  169. """
  170. #response = request.get(url)
  171. #response.status_code
  172. def hierarchy(emp_id, tab_count=0):
  173. url = "http://www.linkedin.corp/api/employee/" + emp_id
  174. response = request.get(url)
  175.  
  176.  
  177. if response.status_code >= 400 and response.status_code <= 500:
  178. print "Error accessing URL"
  179.  
  180. list = response.json()
  181.  
  182. for employee in list:
  183. # Print tabs
  184. for tab in range(tab_count):
  185. print "\t"
  186.  
  187. # if current empid is bad, dont print
  188. if formatted_properly(emp_id):
  189. print employee["name"] + " - " + employee["title"]
  190.  
  191. for report in employee["reports"]:
  192. # if report's id is not formatted properly
  193. hierarchy(report, tab_count+1)
  194.  
  195.  
  196. def formatted_properly(emp_id):
  197. if len(emp_id) != 9:
  198. return False
  199. if str.isalpha(str(emp_id[0])):
  200. for x in range(8):
  201. if not str.isdigit(str(emp_id[1+x])):
  202. return False
  203. return True
  204. return False
Advertisement
Add Comment
Please, Sign In to add comment