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

@whojudge/alice

v1.0.1

Published

An lrun-based informatics judger.

Downloads

4

Readme

alice

An lrun-based Informatics Judger in TypeScript.

Dependency

  • Node.js with ES2017 Support (Better if > v12)
  • npm
  • Linux
  • lrun (can run w/o libseccomp)

Configure

import { init } from '@whojudge/alice'
init({
    cachePath: './cache/', // Cache path, Where codes and executables are temporarily stored (with trailing slash)
    infilePath: './uploads/infile', // Testcase Infile Path (Handle file uploading by ourself - alice does not do that)
    outfilePath: './uploads/outfile', // Testcase Outfile Path
    language: { // Language info
        cpp: {
            compiler: 'g++ -Wall -Wextra -std=c++98 {infile} -o {outfile}'.split(' '), // Compiler must be an array
            runner: '{outfile}'.split(' '), // Runner muse be an array
            extension: '.cpp', // Extension (with dot)
            mirror: [],
        },
        cpp11: {
            compiler: 'g++ -Wall -Wextra -std=c++11 {infile} -o {outfile}'.split(' '),
            runner: '{outfile}'.split(' '),
            extension: '.cpp',
            mirror: [],
        },
        python3: {
            compiler: null, // Compiler can be null if no compiler
            runner: 'python3 {infile}'.split(' '),
            extension: '.py',
            mirror: ['/usr/bin/python3'], // Extra executables / dependencies for runner
        },
        ...
    },
    mirror: ['/lib/', '/lib64/', '/usr/lib/', ...], // General extra executables / dependencies
    lrun: {
        uid: 1001, // The lrun user's uid
        gid: 1001, // The lrun user's gid
        compilerTime: 20 * 1000, // Max time for compilers (ms)
        compilerMemory: 256 * 1024 * 1024, // Max memory for compilers (Bytes)
    },
    concurrent: 4, // How many compile & run tasks can be run concurrently
})

Run

  • Run with sudo; or alice won't be able to switch uid/gid.
  • chown the cache path to the lrun user.
  • Copy testlib.h to ${cachePath}/spj/source.

Default SpecialJudge

Use this code as a default SpecialJudge:

#include "testlib.h"
using namespace std;

int main(int argc, char *argv[]) {
    setName("token-by-token comparing, ignoring trailing space and endl");
    registerTestlibCmd(argc, argv);

    while (!ans.seekEof() && !ouf.seekEof()) {
        string ja = ans.readToken();
        string pa = ouf.readToken();
        if (ja != pa) quitf(_wa, "wrong answer");
    }

    bool ansEnded = ans.seekEof(),
         oufEnded = ouf.seekEof();

    if (ansEnded && oufEnded)
        quitf(_ok, "accepted");
    else if (ansEnded)
        quitf(_fail, "answer too short");
    else if (oufEnded)
        quitf(_fail, "answer too long");
    
    return 0;
}