Coder Social home page Coder Social logo

fastolympiccodinghook's Introduction

FastOlympicCodingHook

Problem test-case parser for sublime text from various online judges. Depends on Competitive Companion and FastOlympicCoding.

Setup

  • Make sure you have python3, FastOlympicCoding and Competitive Companion installed.
  • Add 12345 in the list of ports of competitive-companion browser extension.
  • Clone the repository inside your Sublime Text Packages folder and rename the cloned folder to FastOlympicCodingHook. You can do a quick google search to locate that folder for your particular OS or you can click the "Browse Packages" option in Sublime Text (if you find it) and the folder will open itself.
  • Configure the relative directory and file suffix for test cases files in the FastOlympicCoding settings (FastOlympicCoding.sublime-settings). After making changes to this file, remember to restart Sublime Text to ensure that this plugin fetches the latest configuration.. You can also keep the default values ("tests_relative_dir": "") while ensuring that "tests_file_suffix" is not empty to prevent overwriting your code file.

Usage

  1. Navigate to the file that you'll solve the problem in. Then right click anywhere in the file. You should find an option named Listen to Competitive Companion. Click on it.
  2. In the browser, navigate to the problem page and click on the competitive-companion extension's green plus icon.

The problem's test cases and correct answers will now be parsed and stored in tests_relative_dir within the parent directory of your code file, using the filename tests_file_suffix appended to your code file name. You might not immediately see the change in test cases inside sublime text. But if you run your code using FastOlympicCoding plugin (ctrl+B), then it'll you show those updated test cases and run your code against them.

To see a walkthrough of the setup process, you can watch this video:

Setup walkthrough

fastolympiccodinghook's People

Contributors

drswad avatar gabrielxduo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fastolympiccodinghook's Issues

Test cases not parsing

I am unable to view the result of the test cases when they are being parsed from codeforces. The system just builds and waits for me to enter an input. I have kept the port as 12345.
Also you mentioned the output will come in __filename.cpp but I can't find that anywhere.
I will be really grateful if you will help me.
Screenshot 2021-06-03 130254

Not woring

Hello , This is not working on my machine. What can I do?
I cloned from git hub rep. There is a option in my sublime text "listen competitive companion" and I set my port as 12345 as you mentioned.

What can I do ??

hook no longer works!!

companion is not able to parse the test cases after the latest update of sublime text

Change path of contest folder

The problems files are always stored in some other path. It should be stored in a folder that I want.
How to change the destination folder?

The latest build no longer works in Sublime 4

Package control upgraded to 4.0 in sublime, and meanwhile the latest build of FastOlympicCodingHook no longer parsed the test cases. Had to revert to the older version and immediately worked again. Please help revert to the old build (without the change for the latest one contributed by the other person), so it won't auto upgraded to the "bad version" again.

By the way, here is the working version that I revered to and proved to be working:

import sublime
import sublime_plugin
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import _thread
import threading
import platform

def MakeHandlerClassFromFilename(filename):
class HandleRequests(BaseHTTPRequestHandler):
def do_POST(self):
try:
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
tests = json.loads(body.decode('utf8'))
tests = tests["tests"]
ntests = []
for test in tests:
ntest = {
"test": test["input"],
"correct_answers": [test["output"].strip()]
}
ntests.append(ntest)
nfilename = filename + ":tests"
if platform.system() == "Windows":
nfilename = filename + "__tests"
print(nfilename)
with open(nfilename, "w") as f:
f.write(json.dumps(ntests))
except Exception as e:
print("Error handling POST - " + str(e))
threading.Thread(target=self.server.shutdown, daemon=True).start()
return HandleRequests

class CompetitiveCompanionServer:
def startServer(filename):
host = 'localhost'
port = 12345
HandlerClass = MakeHandlerClassFromFilename(filename)
httpd = HTTPServer((host, port), HandlerClass)
httpd.serve_forever()
print("Server has been shutdown")

class FastOlympicCodingHookCommand(sublime_plugin.TextCommand):
def run(self, edit):
try:
_thread.start_new_thread(CompetitiveCompanionServer.startServer,
(self.view.file_name(),))
except Exception as e:
print("Error: unable to start thread - " + str(e))

Data Not Being Parsed

Hey hi ... I have been using this tool at windows machine for quite a while now and it is the exact thing I was looking for but I have ran of a problem now .
I have switched to ubuntu and using the same things as I did for my previous machine .. This thing is not parsing the data in my cppFastOlympicCoding plugin ..
I would be available to give any further information u would require for the same and would really request u to look into my query becz this is one thing without which I cant really code my way into cp ...
Regards

issue with checking answers to test cases

Hi DrSwad , Is there a feature to automatically check the correct answers for the respective test cases?
And Can we parse a contest using sublime and competitive programming hook and fast olympic coding?

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.