Vladosiya's blog

By Vladosiya, history, 16 months ago, translation, In English

Hello, Codeforces! I made announces of rounds quite often, so some time ago I made a script that gives out the entire list of testers divided by colors. Of course, you can rewrite it a little, so that the order is whatever you want.

Script uses Codeforces API, so first of all you need to go to your account settings and generate API keys and put the open one in the "key" file, and the secret one in the "secret" file in the same folder with the script (or just assign them to the corresponding variables in the script). Now you just need to fill in the array contestids with ids of mashups that you used for testing and run the script. At the end of its work, the script will create file "en.txt " with thanks to all the testers.

I hope it will help you to quickly change the list of testers. Good luck to all and successful rounds!

Script
  • Vote: I like it
  • +79
  • Vote: I do not like it

»
13 months ago, # |
  Vote: I like it +16 Vote: I do not like it

It's really funny, when everybody (including me in past) implements codeforces scripts in python, puts it in some folder and then forgets this folder, forgets that it exists and how to use it. And of course implements api requests in each script from scratch
9 month ago I implemented typescript SDK. It's really easier to implement any script with SDK and strict types: just look into your script, but rewritten with SDK

Which advantages does it have?

  • autocomplete completes every API call, options and return values for you: no need in documentation
  • strict type checks
  • auth out of the box
  • codeforces changed color's ranges? Just update SDK
  • codeforces changed API? Just update SDK
  • codeforces changed color? Just update SDK and string dicts
  • you forgot how your script is named? npx codeforces --help
  • you forgot how to use you script? npx codeforces <script> --help
  • you want to pass some CLI options? Out of the box
  • no need to manually sleep between consecutive API calls
  • virtualenv out of the box (how many times my your python script without virtualenv was broken after system update?)

Disadvantages:

  • strict type checks
    • yes, type checks can be very annoying. I'd say that advantage/disadvantage of it is 95/5 on difficult projects and can be even less than 50/50 on easy ones. In this case I'd say 100/0 as you only need to manually cast input strings to ContestId
  • need to install nodejs
    • it's big when you compare with 0. But we compare it with python, lol
  • node_modules's size
    • Yes, it's true, but mainly for frontend and when you install everything you see. In this project the biggest folder is typescript: 65Mb. All other libraries take about 10Mb (all!) and are needed mainly for dev. You can implement everything on raw js and then node_modules will be about 5Mb
node_modules

Links:

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Oh, we're advertising SDKs? Might I add my Polygon SDK for Go?

    • »
      »
      »
      13 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanx for the question, I understood that I forgot to explicitly state my point:
      As long as ad of SDK (any SDK, yes), I strongly advice to make any scripts as mainainable as possible: it's not codeforces problem, it has different goals and usages. And do not forget that you are not on contest!

      • you don't need to rush implementing from scratch, you can use any library, tool and language you want
      • make it as reusable as possible: if you are implementing API request make it as function call with params, you are definetely going to use it later
      • make it as clear as possible: you don't need to hurry and make some dirty hacks and unusable code like you used to do during contest, just think couple of minutes and come up with more clear code
      • make it usable as easy as possible: it's reeeeealy bad when before running some script you need to modify it (like in this example). Only month later you'll forget what you need to modify and you'll spend at least couple of minutes reading some old script. Or you won't be able to include/pipe this script. Even without completely rewritting this example replacing contestids = ['ids of gyms you used for testing'] with contestids = sys.argv[1:] and adding if len(sys.argv) == 1: print('Usage: ...') will drastically improve this script
      • write usage, comments and readme whenever possible