Coder Social home page Coder Social logo

stripe-ctf-level3's Introduction

Solution

Friends don't let friends use scala.

  • Set up a basic sinatra server to implement the API
  • Shell out to grep to do actual searching. Single node, no index. O_o

Level 3

API

Instant Code Search defines the following HTTP endpoints. All of them return JSON.

  • /healthcheck: Returns '{"success": "true"}' if all the nodes are up and ready to receive requests.

  • /index?path=PATH: Takes a path on the filesystem and indexes it.

  • /isIndexed: Returns '{"success": "true"}' if all the nodes have indexed paths, and are ready to receive queries.

  • /?q=QUERY Returns any file and line number in the indexed path. The response is of this form:

    { "success": true, "results": [ "path/to/file1:5", "path/to/another/file:33", ... ] }

All of these endpoints have been implemented, but we could use your expertise in making the query endpoint a lot faster.

Usage

To start a specific server, run bin/start-server. This looks to see if your jar is assembled; if it is, it runs the jar, and if not, uses sbt[1].

To start all of your nodes, run bin/start-servers. This will start a master search node, and three search nodes. The master node is the only node that we communicate with.

The master node runs on port 9090 (and the search nodes on 9091, 9092, and 9093). Once the servers are up, you can point your browser at http://localhost:9090 to communicate with (and query) the master node.

As always, to submit your code, first commit, and then run git push.

You can test your code locally via test/harness[2]. You can use the harness to download the test cases we run your code against.

Note that the input is generated randomly on a seed; we'll always run against the same dictionary (the harness will download that dictionary for you if you don't have it).

Constraints

We're limiting the amount of memory that each of your nodes gets to 500mb.

When running your solution, we'll give you up to 4 minutes to index, after which, ready or not, we'll start sending queries your way!

(We'll be polling /isIndexed in the meanwhile, and if at any point, you're ready to start accepting queries, we'll start sending them.)

Scoring

The scoring in this level is based on a single metric: the average request latency over 50 requests. Your score is a function of the ratio of your average response time to the default solution.

To beat the level, you will have to perform 4 times as fast as the default solution in this repository.

Good luck!

[1] Scala Build Tool: http://www.scala-sbt.org/

stripe-ctf-level3's People

Contributors

danielfone avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.