PJdan's blog

By PJdan, history, 3 years ago, In English

Without Leetcode Premium, it's annoying to have to see those locked problems.

Here is a user script used to hide locked problems in Leetcode.

  1. Install Tampermonkey
  2. Create a new script:
// ==UserScript==
// @name         Hide locked Leetcode problems
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Hides locked Leetcode problems
// @author       PJDan
// @match        https://leetcode.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=leetcode.com
// @grant        none
// ==/UserScript==

$(document).ready(function() {
    setTimeout(hide, 3000);

    function hide() {
        document.querySelector('.reactable-th-frequency').remove();
        document.querySelectorAll('.frequency-locked').forEach(e => e.remove());
        var lockItems = $(".fa-lock");
        lockItems.closest('tr').hide();
    }
});

Make sure the script is enabled

Full text and comments »

  • Vote: I like it
  • +15
  • Vote: I do not like it

By PJdan, 3 years ago, In English

I use competitive companion and the Competitive Programming Helper to import problems directly to VSCode. The problem is that submitting is slow via the cph-submit plugin. Plus, Firefox has to be opened for that plugin to work.

Here is the solution:

  • Install cf-tool
  • Add this snippet to keybindings.json in VSCode:

{
 "key": "alt+f",
 "command": "workbench.action.terminal.sendSequence",
 "args": { "text": "cf submit -f ${fileBasename} ${fileBasenameNoExtension}\u000D"}
}

\u000D is Unicode for new line.

Of course, you can adjust the alt+f keyboard combination to your liking.

N.B: I've set CPH to create short ID for the generated files.


For Sublime Text users, make sure that the cf-tool is installed of course, and then follow these steps:

  • Install Terminus
  • Install SendCode
  • In the SendCode settings, set the target terminal to Terminus
  • In the key bindings of SendCode paste this code:

{
 "keys": ["super+enter"], "command": "send_code",
 "args": {"cmd": "cf submit -f $file_name $file_base_name\u000D"},
 "context": [
  { "key": "selector", "operator": "equal", "operand": "source" }
 ]
}

Of course, you can adjust the super+enter keyboard combination to your liking, just make sure that it's unique.

  • Open a Terminus pane (you could set a shortcut for this in the Terminus key bindings)
  • Use the shortcut super+enter

N.B: You have to make sure that the name of the file is the same as the Codeforces ID of the problem.

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it