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

snipgpt

v0.2.0

Published

A plugable CLI to generate short snippets using OpenAI LLM

Downloads

4

Readme

snipgpt npm CI checks

A CLI to generate short snippets using OpenAI LLM (See also: snipgpt.nvim)

Why

I know what I want to do, but the syntax is on the way. :)

Sometimes I just don't remember the syntax when working with a language/lib/coreutils and I just need a snippet to remember how it works. Using Google takes too long and more often than not to useless places. ChatGPT is helpful, but, oh boy, it is verbose. Copilot is a bit inconvenient, it works only on an IDE, and is expensive compared to openai.

-- Impatient developer

Common usages:

  • SHELL: Looking for a snippet to use curl and send JSON data. Or I need to use some advanced feature of a CLI like sed or awk.
  • BASH: Sometimes I like to create small bash scripts, but I forget every single time how to do simple things like check if a variable is empty or loop through lists, because of the bash's odd syntax.
  • CSS: I know a given selector/property exists, but I forgot the syntax and arguments.
  • BOILERPLATE: Sometimes I just need a quick boilerplate to start experimenting on something or just to getting started. (see examples below)
  • TEST: To start testing a module, I just need a snippet test scenario and I expand from there.
  • ALGORITHMS: I know an algorithm that solves the issue, but I don't remember how to implement it.

Demo

snipgpt demo

Usage

Prerequisite: Make sure you have set OPENAI_API_KEY (obtaining my secret key)

export OPENAI_API_KEY=yourkey

As a repl:

npx snipgpt

Pass the request directly

npx snipgpt loop in COBOL

Pipe a request to it

echo "post json using curl" | npx snipgpt

To generate a boilerplate of any kind

echo "node: a package.json for an express app" | npx snipgpt > package.json

echo "node: an express app running on port 8888" | npx snipgpt > index.js

npm i && npm start # It gets the boilerplate right with an incredible accuracy :)

Generate generic documentations

echo "a readme of a node app, with 'getting started', 'installation' and 'running' sections" | npx snipgpt > README.md

Getting started

Clone this repo and install the dependencies.

git clone [email protected]:cristianoliveira/snipgpt.git
cd snipgpt
npm i

Obtain your OpenAI key following these instructions.

cp .env.example .env
# edit the file with your key
echo "OPENAI_API_KEY=your-key" > .env

All good. Now run it:

npm start

It will open a prompt where you can request for short snippets. It also works for other stuff, for instance, to ask for examples of how to use a given command from the coreutils.

See: ./example.sh

Automated checks

Running unit tests

npm test
# or
npm test -- --watch

LICENSE

The dude abides. AKA MIT.