Skip to main content

Goldman Sachs DevOps

2 years ago
marcus platform
customuer consumer banking
retail, like chase

100 engineers
from strip, uber, twitter

aquire

devops, automation
24/7 consumer facing
manage building deployment
relase management
client issue
unix/linux, python, terraform, consol, redhat, appdynamics.
web api

codepad technical
prefer code in pytho
-----------------------------
marcus of CCBD

1. load to american people
marcus loan no fee
charge on interest payback

2. savings account for consumer

dec 2017 combined the two

aquired creditmoney this sunday.

credit line poc

perks of startup
cto talk

300 people in marcus
already lend out 3 billion dollars.

nyc, tx, london, bangalore

sfo 5-10 people

devops:
- core devops
- production engineer (sre)
- process release management. work with vendor

on call once every 3 months
only tx and nyc atm.


# Problem Name is &&& ApacheLog &&& PLEASE DO NOT REMOVE THIS LINE.

"""
Instructions to candidate.
 1) Run this code in the REPL to observe its behaviour. The
    execution entry point is specified at the bottom.
 2) Consider adding some additional tests in do_tests_pass().
 3) Implement find_top_ip_address() correctly.
 4) If time permits, try to improve your implementation.
"""


def find_top_ip_address(lines):
    """ Given an Apache log file, return IP address(es) which accesses the site most often.

        Our log is in this format (Common Log Format). One entry per line and it starts with an IP address which accessed the site,
        followed by a whitespace.

        10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] "GET /a.gif HTTP/1.0" 200 234

        Log file entries are passed as a list.
    """

    # todo: implement logic
    # return "10.0.0.1"
    # s = "10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234"
    # print s.split()[0]
    countd = {}
    for line in lines:
        ip = line.split()[0]
        if ip not in countd:
            countd[ip] = 1
        else:
            countd[ip] += 1
    maxcount = 0
    maxips = []
    for ip, cnt in countd.items():
        if cnt > maxcount:
            maxcount = cnt
           
    for ip, cnt in countd.items():
        if cnt == maxcount:
            maxips.append(ip)
    # print maxips
    return maxips

def do_tests_pass():
    """Returns True if the test passes. Otherwise returns False."""

    # todo: implement more tests
    lines = ["10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234",
             "10.0.0.1 - frank [10/Dec/2000:12:34:57 -0500] \"GET /b.gif HTTP/1.0\" 200 234",
             "10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234",
             "10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234",
             "10.0.0.3 - abc   [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234"]
           
    result = find_top_ip_address(lines)
    if "10.0.0.1" in result and "10.0.0.2" in result:
        print("test passed")
        return True
    else:
        print("test failed")
        return False
       

if __name__ == "__main__":
    do_tests_pass()
   

# Problem Name is &&& Second Smallest &&& PLEASE DO NOT REMOVE THIS LINE.

"""
 Instructions to candidate.
  1) Run this code in the REPL to observe its behaviour. The
     execution entry point is main().
  2) Consider adding some additional tests in doTestsPass().
  3) Implement secondSmallest() correctly.
  4) If time permits, some possible follow-ups.
"""

# use heapq?

def secondSmallest(x):
        """ Returns second smallest element in the array x. Returns nothing if array has less than 2 elements. """
        # todo: implement here
        if len(x) < 2:
            return
        # x = [2,4,3,5]
        x.sort()    
        return x[1]
   
import heapq
def secondSmallest(x):
        """ Returns second smallest element in the array x. Returns nothing if array has less than 2 elements. """
        # todo: implement here
        if len(x) < 2:
            return
        return heapq.nsmallest(2, x)
   
def doTestsPass():
        """ Returns 1 if all tests pass. Otherwise returns 0. """     
        testArrays    = [ [0], [0,1] ]
        testAnswers   = [ None, 1, ]

        for i in range( len( testArrays ) ):
            if not ( secondSmallest( testArrays[i] ) == testAnswers[i] ):
                return False
       
        return True

if __name__ == "__main__":
        if( doTestsPass() ):
            print( "All tests pass" )
        else:
            print( "Not all tests pass" )
   

Comments

Popular posts from this blog

CKA Simulator Kubernetes 1.22

  https://killer.sh Pre Setup Once you've gained access to your terminal it might be wise to spend ~1 minute to setup your environment. You could set these: alias k = kubectl                         # will already be pre-configured export do = "--dry-run=client -o yaml"     # k get pod x $do export now = "--force --grace-period 0"   # k delete pod x $now Vim To make vim use 2 spaces for a tab edit ~/.vimrc to contain: set tabstop=2 set expandtab set shiftwidth=2 More setup suggestions are in the tips section .     Question 1 | Contexts Task weight: 1%   You have access to multiple clusters from your main terminal through kubectl contexts. Write all those context names into /opt/course/1/contexts . Next write a command to display the current context into /opt/course/1/context_default_kubectl.sh , the command should use kubectl . Finally write a second command doing the same thing into ...

OWASP Top 10 Threats and Mitigations Exam - Single Select

Last updated 4 Aug 11 Course Title: OWASP Top 10 Threats and Mitigation Exam Questions - Single Select 1) Which of the following consequences is most likely to occur due to an injection attack? Spoofing Cross-site request forgery Denial of service   Correct Insecure direct object references 2) Your application is created using a language that does not support a clear distinction between code and data. Which vulnerability is most likely to occur in your application? Injection   Correct Insecure direct object references Failure to restrict URL access Insufficient transport layer protection 3) Which of the following scenarios is most likely to cause an injection attack? Unvalidated input is embedded in an instruction stream.   Correct Unvalidated input can be distinguished from valid instructions. A Web application does not validate a client’s access to a resource. A Web action performs an operation on behalf of the user without checkin...