
Hey! Today I share with you 5 simple packages, I used to be on mute all the time, but now I want to share more of the stuff I do, so in case there are bored people that want to learn/contribute (like this guy here ), they can find something to work on π
This is using the Monocypher library. It provides low-level and high-level APIs for working with secret things, passwords, csrf, tokens, random bytes.
import e2ee/password
let pwd = generatePassword("masterpassword", generateSalt().toHex(), length = 16)
echo "Generated password: ", pwd
Here, an example where Alice and Bob share top secret stuff
This is a simple password strength estimator, that works by checking the password against based on multiple factors: length, character variety, repetition, leet substitution, and optionally, a list of common passwords (you must provide the list yourself, example here).
import blackpaper
let res: PasswordStrengthResult = passwordStrength("P@ssw0rd123")
echo "Score: ", res.score
echo "Strength: ", res.strength # Weak
echo "Reason: ", res.reason # TooPredictable
This is a large database of mime types, useful for retrieving the mime info of a file based on file extension, or content type. Basically, you will need this if you want to implement a static file server or anything that needs to work with files and their mime types
import mimedb
assert getMimeType("html") == some("text/html")
let info2 = getMimeInfo("application/zip")
assert info2.isCompressible == false
assert info2.getExtensions() = some(@["zip"])
assert isExtension("m4a")
This is a wrapper around the standalone Impeller Engine (used by Flutter) via the C API. Currently the high-level API is still in early stages, but the low-level bindings are already available.
I see many CLI frameworks out there. Let me share my own! This one has types, is using macros for the syntax/command definition, can automatically align the help/usage text, has support for labels, auto-links the command to the callback and soon enough, will support pluggable commands!
Pluggable commands will be shared libraries that can be loaded at runtime, so you can have a core CLI app and then load commands per project basis. Imagine a database CLI where you can run migrations, seed data, run queries per project
import pkg/kapsis
#
# Define your command handlers here
#
proc helloCommand(v: Values) =
echo v.get("pkgname").getStr
proc greetCommand(v: Values) =
if v.has("greeting"):
echo v.get("greeting").getStr
echo v.get("name").getStr
proc colorsOrangeCommand(v: Values) =
echo "The one that is orangely out of its head"
proc colorsBlueCommand(v: Values) =
echo "Now everyone loves the new blue / Cause itβs the truest"
proc colorsWhateverColorCommand(v: Values) =
echo "Whatever color command"
#
# Init Kapsis with the defined commands
#
initKapsis do:
commands do:
-- "Crazy stuff"
hello name.string, int(age), ?bool(verbose):
## Describe your command here
-- "Another command"
greet name.string, ?string(greeting):
## Greeting someone with an optional greeting message
-- "Colors by Ken Nordine"
colors:
## Colors are cool, let's have some fun with them
blue bool(enable):
## Blue was the bluest blue can be blue
orange bool(enable):
## The silly old color who lives next to red Yup! Doc comments are used as command description. Crazy!
A plain preview of the generated app (description, author, license and version are collected from the .nimble file):
Your type of CLI framework
(c) George Lemon | MIT License
Build Version: 0.3.0
Crazy stuff
hello <name:string> <age:int> <?verbose:bool> Describe your command here
Another command
greet <name:string> <?greeting:string> Greeting someone with an optional greeting message
Colors by Ken Nordine
colors.blue <enable:bool> Blue was the bluest blue can be blue
colors.orange <enable:bool> The silly old color who lives next to red
colors.all Get all the colors!
--sure:bool
Instead of creating a new thread for each package, I decided to share them all in one place, this is my Another Day Another Package thread, where I will share all the small packages I create. If you have any ideas, suggestions or want to contribute fork these repos like a hungry beast!
I'm always open to new ideas! My open source work is a therapy for me, let's make the Nim's ecosystem a better place together! π€