Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------ Web Architecture and Design Knowledge
- What happens after you enter "ssh _host name_" into the command line?
- It's your first day on the job as an Ops guy.
- What monitoring do you begin to put in place on the site in the first week?
- ...Month? Quarter? What do you track?
- You have a lot of production servers and a giant data set that will be updated consistently over time.
- The data set is updated 4 times per day. How do you get all your production servers up to date consistently, automated?
- ...First job doesn't finish before the second. What do you do?
- ------ Systems and Architecture
- You're running a static site on one server. Latency is high and some connections don't go through. What do you do?
- (Apache parallelization of worker tasks, redundancy in the static assets on different hard disks to parallelize content access)
- 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?
- 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?
- -------------------------------
- This is just a simple shared plaintext pad, with no execution capabilities.
- When you know what language you'd like to use for your interview,
- simply choose it from the dropdown in the top bar.
- You can also change the default language your pads are created with
- in your account settings: https://coderpad.io/profile
- Enjoy your interview!
- """
- 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.
- """
- for x in range(1, 100):
- if x % 4 == 0 and x % 6 == 0:
- print "LinkedIn"
- continue
- elif x % 4 == 0:
- print "Linked"
- continue
- elif x % 6 == 0:
- print "In"
- continue
- print x
- """
- Below, see a sample of /var/log/messages.
- ---------- begin sample log extract ----------
- Jan 20 03:25:08 fakehost logrotate: ALERT exited abnormally with [1]
- Jan 20 03:25:09 fakehost run-parts(/etc/cron.daily)[20447]: finished logrotate
- Jan 20 03:26:21 fakehost anacron[28969]: Job 'cron.daily' terminated
- Jan 20 03:26:22 fakehost anacron[28969]: Normal exit (1 job run)
- Jan 20 03:30:01 fakehost CROND[31462]: (root) CMD (/usr/lib64/sa/sa1 1 1)
- Jan 20 03:30:01 fakehost CROND[31461]: (root) CMD (/var/system/bin/sys-cmd -F > /dev/null 2>&1)
- Jan 20 05:03:03 fakehost ntpd[3705]: synchronized to time.faux.biz, stratum 2
- Jan 20 05:20:01 fakehost rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="20438" x-info="http://www.rsyslog.com"] start
- 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]
- 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"
- Jan 20 05:22:08 fakehost cs3[31163]: Q: ".../sbin/sv restart": ok: run: /export/service/cool-service: (pid 32323) 0s
- Jan 20 05:22:08 fakehost cs3[31163]: I: Last 1 quoted lines were generated by "/sbin/sv restart /export/service/cool-service"
- 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.
- Jan 20 05:22:37 fakehost ACCT_ADD: WARNING: Manifest /var/syscmds/inputs/config-general/doit.txt has been processed already, bailing
- ---------- end sample log extract ----------
- Write a script which parses /var/log/messages and generates a CSV with two columns: minute, number_of_messages in sorted time order.
- ---------- begin sample output ----------
- minute, number_of_messages
- Jan 20 03:25,2
- Jan 20 03:26,2
- Jan 20 03:30,2
- Jan 20 05:03,1
- Jan 20 05:20,1
- Jan 20 05:22,6
- ---------- end sample output ------------
- Extract the program name from the field between the hostname and the log message and output those values in columns.
- Sample Output (when run against the lines containing "Jan 20 05:2" in the log above):
- ---------- begin sample output ----------
- minute,total_count,rsyslogd,cs3,ACCT_ADD
- Jan 20 05:20,1,1,0,0
- Jan 20 05:22,6,0,5,1
- ---------- end sample output ------------
- """
- #lines = f.readlines()
- #for line in f:
- # string.split(<char>)
- f = open("/var/log/messages")
- o = open("output.csv")
- dict = {}
- set = set()
- for line in f:
- proc = line.split(" ")[4]
- index1 = len(proc)
- index2 = len(proc)
- if "(" in proc:
- index1 = proc.indexof("(")
- if "[" in proc:
- index2 = proc.indexof("[")
- proc = proc.substring(0, min(index1, index2))
- set.add(proc)
- for line in f:
- #Jan 20 03:25:08 fakehost logrotate: ALERT exited abnormally with [1]
- arr = line.split(" ")
- key = arr[0]+arr[1]+arr[2].substring(0, len(arr[2])-3)
- proc = arr[4]
- index1 = len(proc)
- index2 = len(proc)
- if "(" in proc:
- index1 = proc.indexof("(")
- if "[" in proc:
- index2 = proc.indexof("[")
- proc = proc.substring(0, min(index1, index2))
- if key not in dict:
- dict[key] = (1, )
- else:
- dict[key] += 1
- f.close()
- o.write("minute, number_of_messages" + ','.join(list(set)))
- for key, value in dict.iteritems():
- o.write(key + "," + str(value))
- o.close()
- """
- 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:
- 'name' refers to a String that contains the employee's first and last name
- 'title' refers to a String that contains the employee's job title
- 'reports' refers to an Array of Strings containing the IDs of the employee's direct reports
- Write a function that will take an employee ID and print out the entire hierarchy of employees under that employee.
- 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.
- -----------Begin Sample Output--------------
- Flynn Mackie - Senior VP of Engineering
- Wesley Thomas - VP of Design
- Randall Cosmo xxxxxx - Director of Design
- Brenda Plager - Senior Designer
- Nina Chiswick - VP of Engineering
- Tommy Quinn - Director of Engineering
- Jake Farmer - Frontend Manager
- Liam Freeman - Junior Code Monkey
- Sheila Dunbar - Backend Manager
- Peter Young - Senior Code Cowboy
- -----------End Sample Output--------------
- 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.
- Don't worry about output formatting/spacing, you can just alter the behavior of your existing function to only print the relevant results.
- """
- #response = request.get(url)
- #response.status_code
- def hierarchy(emp_id, tab_count=0):
- url = "http://www.linkedin.corp/api/employee/" + emp_id
- response = request.get(url)
- if response.status_code >= 400 and response.status_code <= 500:
- print "Error accessing URL"
- list = response.json()
- for employee in list:
- # Print tabs
- for tab in range(tab_count):
- print "\t"
- # if current empid is bad, dont print
- if formatted_properly(emp_id):
- print employee["name"] + " - " + employee["title"]
- for report in employee["reports"]:
- # if report's id is not formatted properly
- hierarchy(report, tab_count+1)
- def formatted_properly(emp_id):
- if len(emp_id) != 9:
- return False
- if str.isalpha(str(emp_id[0])):
- for x in range(8):
- if not str.isdigit(str(emp_id[1+x])):
- return False
- return True
- return False
Advertisement
Add Comment
Please, Sign In to add comment