npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leetcode-dump

v0.4.13

Published

Dump your LeetCode solutions, and generate a static website to show them.

Downloads

125

Readme

LeetCode Dump

Features

  • Dump your LeetCode solutions in multiple languages.
    • Including code, note, runtime speed, memory usage, timestamp ...
  • Generate a static website to show your solutions.
    • Index page, code highlight, search bar ...
    • See screenshots for more details.
  • Easy to use.
    • Through npx, GitHub Actions, or Docker.
  • Customizable.
    • You can use "template" -T to design what the website should look like.

Install

You need Node.js 16+.

npm i -g leetcode-dump

Usage

Dump Solutions

❯ leetcode-dump --help
Usage: leetcode-dump [options] [command]

Options:
  -V, --version              output the version number
  -s, --session <session>    Your LeetCode Session (default: "process.env.LEETCODE_SESSION")
  -o, --output <path>        Output Dir (default: "./leetcode")
  -c, --clean                Clear Output Dir Before Start (default: false)
  -l, --limit <rate>         Rate Limit <req>/<sec> (default: "20/10")
  -t, --timezone <timezone>  Your Timezone (default: "Asia/Taipei")
  -p, --pure                 Pure Mode, No Additional Informations to Add (default: false)
  -T, --template <path>      Template File for markdown index page
  -r, --retry <times>        Times to Retry When Fail (default: "3")
  -v, --verbose [bool]       Verbose Mode (default: true)
  -h, --help                 display help for command

Commands:
  build [options]            Build static site from dumped solutions
  transform [options]        Transform dumped solutions to a Vuepress source

Example:

leetcode-dump -s "eyJ0eXAiOiJKV1...AJFGlVhZ7f5QL8"

Build Static Site

This will use Vuepress to build a static site from solutions dumped by leetcode-dump.

❯ leetcode-dump build --help
Usage: leetcode-dump build [options]

Build static site from dumped solutions

Options:
  -s, --source <path>   Source Dir (default: "./leetcode")
  -o, --output <path>   Output Dir (default: "./site")
  -T, --template <path>  Template File for every document page
  -c, --config <path>   Vuepress Config Path
  -v, --verbose [bool]  Verbose Mode (default: true)
  -h, --help            display help for command

Example:

leetcode-dump build

Generate Vuepress Content Source

This will generate a Vuepress content source from solutions dumped by leetcode-dump.

It is similar to leetcode-dump build, but you can do more things to customize the content source, then use Vuepress to build static site by yourself.

❯ leetcode-dump transform --help
Usage: leetcode-dump transform [options]

Transform dumped solutions to a Vuepress source

Options:
  -s, --source <path>   Source Dir (default: "./leetcode")
  -o, --output <path>   Output Dir (default: "./site-source")
  -T, --template <path>  Template File for every document page
  -v, --verbose [bool]  Verbose Mode (default: true)
  -h, --help            display help for command

Example:

leetcode-dump transform

Note

If you install leetcode-dump globally, you can use lcd, the alias of leetcode-dump, as a command line tool.

GitHub Action

There is a Template, you can simply use it and setup in a minute.

Example Repository

Docker Usage

The docker image is available on Docker Hub.

You can simply run it by using docker run:

# See Help
docker run --rm jacoblincool/leetcode-dump --help
# --rm: remove container after exit
# Dump Solutions and Notes
docker run --rm -v $(pwd)/leetcode:/usr/workspace/leetcode jacoblincool/leetcode-dump -s "YOUR_LEETCODE_SESSION"
# --rm: remove container after exit
# -v: mount volume, {current directory}/leetcode (host) <-> /usr/workspace/leetcode (container)
# Build Static Site
docker run --rm -v $(pwd)/leetcode:/usr/workspace/leetcode -v $(pwd)/site:/usr/workspace/site jacoblincool/leetcode-dump build
# --rm: remove container after exit
# -v: mount volumes:
#           {current directory}/leetcode (host) <-> /usr/workspace/leetcode (container)
#           {current directory}/site (host) <-> /usr/workspace/site (container)

You can simply change the mounted host volume to any location you want.

If you want to change the mounted container volume, you should also pass related options to leetcode-dump:

# Custom Mounted Volumes

docker run --rm -v $(pwd)/solutions:/lc/sol jacoblincool/leetcode-dump -s "YOUR_LEETCODE_SESSION" -o /lc/sol
# mount $(pwd)/solutions (host) <-> /lc/sol (container), use option "-o" to specify output dir (in container)

docker run --rm -v $(pwd):/lc jacoblincool/leetcode-dump build -s /lc/solutions -o /lc/site
# mount $(pwd) (host) <-> /lc (container), including "solutions" dir in previous step
# use option "-s" to specify source dir (in container) and "-o" to specify output dir (in container)

You can add -t to docker run to enable more beautiful log.

Screenshots

screenshot-home

screenshot-problem

screenshot-solution

screenshot-code