Блог пользователя Vladosiya

Автор Vladosiya, история, 16 месяцев назад, По-русски

Привет, Codeforces! Довольно часто делал анонсы раундов, так что какое-то время назад сделал скрипт, который выдаёт весь список тестеров по цветам. Вы, конечно, можете его немного переписать, чтобы порядок был какой вам угодно.

Скрипт использует Codeforces API, так что первым делом вам нужно зайти в настройки аккаунта и сгенерировать ключи API и поместить открытый в файл "key", а секретный в файл "secret" в одной папке со скриптом (или просто присвоить их соответствующим переменным в скрипте). Теперь нужно просто заполнить массив contestids id мешапов, которые вы использовали для тестирования и запустить скрипт. По окончании своей работы скрипт создаст файлы "ru.txt" и "en.txt" с благодарностями на соответствующих языках.

Надеюсь он поможет вам быстро изменять список тестеров. Всем удачи и успешных раундов!

Скрипт
  • Проголосовать: нравится
  • +79
  • Проголосовать: не нравится

»
13 месяцев назад, # |
  Проголосовать: нравится +16 Проголосовать: не нравится

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 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

    • »
      »
      »
      13 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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