GithubHelp home page GithubHelp logo

probablykasper / cpc Goto Github PK

View Code? Open in Web Editor NEW
114.0 5.0 14.0 344 KB

Text calculator with support for units and conversion

Home Page: https://crates.io/crates/cpc

License: MIT License

Rust 100.00%
conversion math calculator units units-converter converter cli library package

cpc's Introduction

Hi, I'm a developer from Norway

⭐️ 📦 Repo 📚 Description
114 cpc Text calculator with support for units and conversion
39 ferrum Music library app for Mac, Linux and Windows
284 date-picker-svelte Date and time picker for Svelte
98 kadium App for staying ontop of YouTube channels' uploads
68 mr-tagger Music file tagging app for Mac, Linux and Windows
79 time-machine-inspector Time Machine backup size inspector app
64 remind-me-again Toggleable cron reminders app for Mac, Linux and Windows
5 vidl CLI for downloading video/audio
3 taskler Simple text editor for your New Tab page
6 thumbnail-grabber Chrome extension for grabbing thumbnails/covers
3 starchart GitHub star history graph
3 embler Turn binaries into applications
4 notifier Android app for scheduling notifications
13 readme-template-action Integrate GitHub API data in your README.md
17 redlux AAC decoder for MPEG-4 and AAC files, with rodio support
1 2dcam After Effects 2d camera
1 to CLI audio, video and image file converter
1 serve Simple static file/directory HTTP server

cpc's People

Contributors

djmattyg007 avatar ethwu avatar finnrg avatar gcomte avatar joseluis avatar jqnatividad avatar probablykasper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cpc's Issues

Synonyms for operators

Is it possible to support queries like this?

❯ ./cpc '500 divided by 4'
Lexing error: Invalid string: divided

Support non-US spelling of words

These examples should work, but don't:

❯ ./cpc '24 kilometres per hour in metres per second'
Lexing error: Invalid string: kilometres

❯ ./cpc '24 kilometers per hour in metres per second'
Lexing error: Invalid string: metres

I'm guessing there are probably others that need fixing up; I didn't perform a comprehensive test of all supported units.

Dividing by a unit over time

I haven't been able to find a way to make this kind of query work:

❯ ./cpc '500 megabytes / 3 megabytes per second'
Parsing error: Expected end of input, found LexerKeyword(Per) at 5

❯ ./cpc '500 megabytes / 3 megabytes/second'
Eval error: Unit has no child[0]

Thanks for creating this project by the way, it looks amazing :) Queries like this are one thing I still tend to use Google for, so I see it as a way to continue de-googling my life.

Inputs need to be quoted

It doesn't appear to be stated anywhere in the readme, but as far as I can tell the full input query needs to be quoted and passed as a single argument on the shell. This was quite frustrating until I worked it out.

I think the readme should be updated to state this. I also think the examples section of the readme should be updated to include the expected results. This will assist users in testing the program.

Output formatting improvements

Currently the output doesn't produce nice human-readable descriptions, and doesn't differentiate between singular and plural values.

❯ target/release/cpc '123 kph'
123 KilometersPerHour

❯ target/release/cpc '1 kph'
1 KilometersPerHour

It would be good if the output of the above was 123 kilometres per hour and 1 kilometre per hour.

Quarter unit treated as month

I believe there's a typo in lexer.rs where (a) quarter is misspelled as quater (and quaters) and (b) the unit assigned is Unit::Month instead of Unit::Quarter.

Trig functions result in floating point error

Description: using "pi" with trig functions results in close but wrong floating point results

Steps to reproduce: cpc 'sin(pi)' or cpc 'sin(pi/2)'

Expected result: 0 and 1 respectively

Actual result: 5.012535993076719585277299108368256E-35 and 1.000000000000000000000000000000001

Add CI to run the tests

It would be good to set up something like Github actions to run the tests, so that they're automatically validated when someone submits a PR.

Improvement: Allow to not use quotes when invoking from the command line

I find this package really helpful to operate from the CLI, however it would be really handy to just type cpc 2 + 2 instead of cpc '2 + 2'.

I created a bash script to do cpc "$*" this work just fine, but not for multiplication and I don't necessarily want to write a wrapper around this issue, especially if it could be provided out of the box.

Merely food for thought.

cargo-audit finds rustc-serialize vulnerability

Hi @probablykasper , running cargo audit returns:

Crate: rustc-serialize
Version: 0.3.24
Title: Stack overflow in rustc_serialize when parsing deeply nested JSON
Date: 2022-01-01
ID: RUSTSEC-2022-0004
URL: https://rustsec.org/advisories/RUSTSEC-2022-0004
Solution: No fixed upgrade is available!
Dependency tree:
rustc-serialize 0.3.24
└── decimal 2.1.0
└── cpc 1.8.0

error: 1 vulnerability found!

Any chance an alternative library for decimal can be used?

Handle scientific notations correctly

Currently CPC couldn't handle scientific notations such as "2e10" and "1e-3". It will calculate it as 2 * e * 10, and 1 * e * (-3). Can we fix that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.