tiffany352 / rink-rs Goto Github PK
View Code? Open in Web Editor NEWUnit conversion tool and library written in rust
Home Page: https://rinkcalc.app/about
License: GNU General Public License v3.0
Unit conversion tool and library written in rust
Home Page: https://rinkcalc.app/about
License: GNU General Public License v3.0
Hi,
I noticed that the IRC implementation is no longer maintained.
I'm already maintaining a newer IRC implementation in my own fork, albeit with some pretty breaking changes to the output formatting, but I wouldn't mind maintaining a branch where I could submit the changes upstream without the personalized formatting (although I do disagree with the use of NOTICE
over PRIVMSG
due to how many clients consider NOTICE
s to be "highlights/notifications")
I do have a question, though โ I've also recently done a matrix client implementation that I'm willing to maintain for the duration that I'm using Matrix (pardon me for the code quality, it's heavily copied and rushed ๐) and I was wondering if at this point you might prefer out-of-tree implementations you could refer to?
When someone opens the web interface of Rink they see this:
The input field on that page feels more like a small site-search box that you would use for looking up documentation or similar information than a natural main point of attention and interaction.
For example, compare that to the search boxes on GitHub, crates.io and a whole slew of other websites, where the search box is secondary to what is the main focus of the page you are on.
And then look at sites like SymPy Gamma and Wolfram|Alpha, where the input box is meant to be the main focus of the page you are on.
In my opinion, the user experience of the Rink web interface would improve a lot if it drew inspiration from these two (which in turn basically follow the model of Google and other search engines).
Have a big input field with an "=" button next to it that becomes the main focus of the user when they open the web interface.
After removing rink 0.4.0, I installed rink 0.4.1 with "cargo install rink", and now I get thousands of lines of error messages when I run rink. :/ This happens under Ubuntu natively, and it happens under Windows on Bash for Windows with that version of Ubuntu too. I've attached an output.txt file containing all of the output.
"definition.units" has been updated in latest gnu units (v2.16 of the file, but found inside v2.14 of the source code)
This is just a heads up that kcov is not being run in CI
I used your repo as a template when adding code coverage to my own tests and ended up with mkroman/webalert@77ce8b4 as I had several issues with your old approach - the biggest one being that when my crate is a lib, it doesn't seem to just dump the tests in target/debug/<test>
, but instead dumped it as executables in target/debug/deps/โฆ
along with the built crate bins.
This created a new problem - I couldn't distinguish between tests and the CLI bin, and kcov
would run and show code coverage for the failure path of my CLI despite it being untested.
That's when I found cargo-kcov which parses the output of cargo test
to distinguish tests from crate bins and then runs them. But unfortunately it seems a lot slower to run than it should be.
If the following is input, an infinite loop occurs:
log10(-1)
The expected result is 1.36437635 i
. If complex numbers won't be supported for a while, could we at least get an error here?
The new version doesn't have currency values yet, since they need to be loaded externally.
E.g.:
> (100.0860%) ** 365
approx. 1.368568 (dimensionless)
> 100.0860% ** 365
1.00086e-728 (dimensionless)
I expect the subject line to work. Is there any reason it can't?
Output of RUST_BACKTRACE=1 cargo test --release --doc
: https://ptpb.pw/b9hk
FWIW, also tested with #22 applied.
Edit: Arch Linux, Rust 1.19.0, Cargo 0.20.0
It should be possible to run a Rink query using an API like
curl --get -d 'q=kWh/year -> W' https://rinkcalc.app/api/v1/query
(i.e.)
https://rinkcalc.app/api/v1/query?q=...
This might be helpful for people setting up custom bots for running Rink queries or whatever.
Add a new command define {name} {expr}
. Probably also undef {name}
and list-defs
as well. They'll need to be mentioned in the manual.
Units should be saved to the config directory and be stored in json format (DefEntry's Serialize/Deserialize impl).
Editing the file directly should let you use additional functionality like defining new substances, categories, base units, prefixes.
> 1.68e8
168000000 (dimensionless)
> 1.68eโ8
Expected term, got <Malformed number literal: No digits after exponent>
I tried to do this today, expecting something with densities:
> 3.7 billion l * water -> ton
Conformance error: 7256921/200000, approx. 36.28460 giganewton (force) != 45359237/50000, approx. 907.1847 kilogram (mass)
Suggestions: divide left side by acceleration, multiply right side by acceleration
Then I tried to see what various substance names map to, and it's kind of a mess...
> water
Definition: water = gram force / cm^3 = 9806.65 pascal / meter (kg / m^2 s^2)
> mercury
Definition: mercury = 200.59 g / mol = 0.20059 kilogram / mole (molar_mass; kg / mol)
> milk
Definition: milk = 242 g / uscup = approx. 1022.874 kilogram / meter^3 (density; kg / m^3)
> oil
Definition: oil = 7.5 oz / uscup = approx. 898.6982 kilogram / meter^3 (density; kg / m^3)
> gasoline
Definition: gasoline_HHV = 125000 btu / usgallon = approx. 34.83953 gigapascal (pressure; kg / m s^2)
> air
Definition: air = 78.08 % nitrogen 2 + 20.95 % oxygen 2 + 9340 ppm argon + 400 ppm (carbon + oxygen 2) + 18.18 ppm neon + 5.24 ppm helium + 1.7 ppm (carbon + 4 hydrogen) + 1.14 ppm krypton + 0.55 ppm hydrogen 2 = approx. 0.02896790 kilogram / mole (molar_mass; kg / mol)
The wiki lists a few examples for usage of the digits
modifier:
> 2^128 -> digits
340282366920938463463374607431768211456 (dimensionless)
> 1/7 -> digits 50
1/7, approx. 0.1428571428571428571428571428571428571428571428571428 (dimensionless)
> googol -> digits
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (dimensionless)
However, all of them fail with "No such unit digits" when used on the current master.
When trying to calculate the following:
(ln(11000)-ln(9600))/log(1+0,038)
The application crashes with floating point exception
This is also seen on the website.
rustc 1.13.0 (2c6933acc 2016-11-07) on x86_64.
I also tested with rustc 1.15.0-nightly (c80c31a50 2016-12-02)
rink is straight from HEAD.
---โ----
-----------------------------------------------------------------------------------------------------------------------[regs]
RAX: 0x0000000000000000 RBX: 0x0000000000000008 RBP: 0x00007FFFFFFEECA8 RSP: 0x00007FFFFFFEE9B8 o d I t s Z a P c
RDI: 0x0000000000000002 RSI: 0x00007FFFFFFEE940 RDX: 0x0000000000000000 RCX: 0x00007FFFF6DE1F5F RIP: 0x00007FFFF6DE1F5F
R8 : 0x0000000000000000 R9 : 0x00007FFFFFFEE940 R10: 0x0000000000000008 R11: 0x0000000000000246 R12: 0x00007FFFFFFFB258
R13: 0x0000000000000000 R14: 0x00007FFFFFFEF201 R15: 0x0000000000000000
CS: 0033 DS: 0000 ES: 0000 FS: 0000 GS: 0000 SS: 002B
-----------------------------------------------------------------------------------------------------------------------[code]
=> 0x7ffff6de1f5f <raise+207>: add rsp,0x88
0x7ffff6de1f66 <raise+214>: mov eax,r8d
0x7ffff6de1f69 <raise+217>: pop rbx
0x7ffff6de1f6a <raise+218>: ret
0x7ffff6de1f6b <raise+219>: nop DWORD PTR [rax+rax*1+0x0]
0x7ffff6de1f70 <raise+224>: mov rdx,QWORD PTR [rip+0x207011] # 0x7ffff6fe8f88
0x7ffff6de1f77 <raise+231>: neg eax
0x7ffff6de1f79 <raise+233>: mov DWORD PTR fs:[rdx],eax
-----------------------------------------------------------------------------------------------------------------------------
0x00007ffff6de1f5f in raise () from /usr/lib/libpthread.so.0
Backtrace
#1 0x00007ffff7b578ae in __gmp_invalid_operation () from /usr/lib/libgmp.so.10
#2 0x00007ffff7b72345 in __gmpq_set_d () from /usr/lib/libgmp.so.10
#3 0x000055555572c683 in rink::number::to_string::haec1297263603064 ()
#4 0x0000555555730da4 in rink::number::Number::numeric_value::h4850098f4b2093d6 ()
#5 0x0000555555733076 in rink::number::Number::to_parts::he3c1abf6d0004735 ()
#6 0x00005555557242e7 in rink::eval::_$LT$impl$u20$rink..context..Context$GT$::eval_outer::h60a4e918c72522ff ()
#7 0x000055555576ba02 in rink::one_line::h2e9b2f6ff43e8ecc ()
#8 0x00005555556c5376 in rink::main_interactive::hb160f18d7d736a5b ()
#9 0x00005555556cb819 in rink::main::h948107a286eaccdf ()
#10 0x0000555555800257 in __rust_maybe_catch_panic ()
#11 0x00005555557f6f12 in std::rt::lang_start::h538f8960e7644c80 ()
#12 0x00007ffff683c291 in __libc_start_main () from /usr/lib/libc.so.6
#13 0x00005555556afb6a in _start ()
For some time now, the version of rink on crates.io has been failing to build on many of my machines due to a problem with OpenSSL. However, I just noticed that master builds fine on my machines (possibly due to 0db3f4d).
It would be much appreciated if a new version would be pushed to crates.io, so that I can delete the debian stable docker container I currently use for rink ;).
I've just discovered this repository and wanted to try it, but I'm not able to build the project. I've tried "cargo install rink", cloning the repo and using "cargo build" and adding it as a dependency to one of my own projects. For every method, there's the following error
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-m64" "-fPIC" "-o" "/home/user/rink-rs/target/debug/build/openssl-5464f8f6e728c35a/out/src/c_helpers.o" "-c" "src/c_helpers.c"
cargo:warning=src/c_helpers.c:1:25: fatal error: openssl/ssl.h: No such file or directory
cargo:warning=compilation terminated.
ExitStatus(ExitStatus(256))
I've tried using rustc 1.14.0 as well as 1.16.0-nightly on Ubuntu 16.04.
Do you have any hints for me?
rink(1) is proving to be a neat utility, but I only perform quick inlined CLI usage, so echo "..." | rink
feels too long, and an alias/function (adding ^D) feels like a poor hack.
Would it make sense, say, to add -i "..."
as a way to directly invoke the utility instead of piping it out?
rink-web looks like this on my phone:
There's no input box. (There's some input because I coped the URL from my desktop.) The hamburger button does nothing. BTW, putting the input box into the header on mobile devices might be a bad idea; e.g. the default Android browser will put the URL box over that part of the page.
... like Debian.
I'm not sure what's up with the openssl mess in Rust. Can you poke the dependencies somehow, maybe?
> ^C
> ^C
> exit()
No such unit exit, did you mean spectral_exitance_frequency?
> ^C
> ^C
> ^C
> ^C
>
Expected term, got eof
> help
For information on how to use Rink, see the manual: https://github.com/tiffany352/rink-rs/wiki/Rink-Manual
> .exit
Expected term, got <Malformed number literal: No digits after decimal point>
> :q
Expected term, got `:`
> quit
error: the lock file needs to be updated but --locked was passed to prevent this
Perhaps it's just me, but I found the with explicit multiplication and negative numbers to seriously trip up my calculations. The following example should illustrate the problem.
The following calculations work as expected, yielding the correct sum or product with implicit multiplication:
> 3/4 -1
-0.25 (dimensionless)
> 3/4 ( -1)
-0.75 (dimensionless)
However when a users tries to use explicit multiplication to avoid wrapping the negative in parentheses:
> 3/4 * -1
-0.25 (dimensionless)
This is very unintuitive and for me and probably for others. I would consider it a serious bug to silently eat an explicit operator for multiplication and instead perform a sum. What's more this is not the behavior of frink on which rink seems to be based.
E.g.:
You have: 0x1b1e48
You want:
Definition: 1777224
and probably the other way too (no idea how to do it in GNU units)
I want to be reasonably confident that the endpoint won't fall over once it starts seeing frequent use.
It should be easy to continue changing your query after you've run it the first time, currently you have to refocus the textbox every time.
Hi,
There is some odd behavior between bits and bytes, (i.e. GB, Gb, GiB) all being treated as the same unit and converted to bit, where the 3 units are distinctively different units.
Example:
"5 bytes" becomes "40 bit"
"800GB" becomes "6.4 terrabit"
Also as a side note "TB" is recognized as a terrabyte/bit, however "Tb" comes up as a tablespoon. Maybe tablespoon can be changed to "tb" so that "TB" can be consistently used, similarly to gigabytes in the following different units (TB, Tb, TiB).
It would be nice to lazily update currency info in the background.
New base unit: cycle.
New unit: cps -> cycles_per_second -> 1 cycle / s.
There's been a few fixes.
> air density
air: Average molecular weight of air. density = 1 kilogram / meter^3
> gold density
gold: density = 1 kilogram / meter^3
> silver density
silver: density = 1 kilogram / meter^3
To reproduce:
> 300g/(58 g/mol)
150/29, approx. 5.172413 mole (amount)
> 300g/(58 g/mol)*(22.4 l/mol)
46875/203, approx. 230.9113 mole^2 / meter^3
Package managers like Scoop require a pre-built binary in order to distribute an application, and so it's important to start shipping official binaries for the CLI with each release.
Doing it in CI is important because the pre-built binaries should be available for all platforms.
Rink stores cached currency data in the config dir which is not the right place for it.
history.txt
should probably stay in the config dir but I'm not sure.
I find it rather common that I write some complicated expression, quit rink, and then want to run a slightly modified form of it the next time. I would hugely appreciate a persistent history.
Is it time to update crates?
I install this on every single one of my computers, and I tremendously enjoy this tool. The version on Crates is 7 months old, but it seems commits have been happening in the interim.
Inputting the following string will cause a divide by zero error in gmp:
5.2*10^15*300^(3/2)
The expected output is something to the tune of 2.7019993*10^19
num
crate, as it provides complexes of ratios of bigints)This dependency makes it impossible to build rink on windows for me, and also makes it impossible to do things like compile to wasm for an offline-cached version of rink-web. There's a few native-rust alternatives these days to look into.
The web app doesn't seem to handling it's decades correctly.
For instance 2 pi radius of earth / c
returns 133 seconds instead of 133 milliseconds, despite both the radius of earth and speed of light being correct. This does work in the CLI.
https://en.wikipedia.org/wiki/Repeating_decimal#Extension_to_other_bases
Wikipedia is terrible with math stuff though. I actually found out about these rules from this video, which explains way better:
https://youtu.be/qID2B4MK7Y0?t=673
I think the important rule is this:
If the current remainder is not a multiple of the base, and divides cleanly into base^N - 1
(for base 10, this would be 9, then 99, then 999, and so on), then the remainder represents the N recurring digits.
Fraction | Divides into | Result |
---|---|---|
1/3 | 9 / 3 = 3 | 0.3 recurring |
1/7 | 999 999 / 7 = 142 857 | 0.142857 recurring |
1/9 | 99 / 9 = 11 | 0.11 recurring |
1/11 | 99 / 11 = 09 | 0.09 recurring |
Fraction | Divides into | Result |
---|---|---|
1 / 3 (0b1 / 0b11) | 0b11 / 0b11 = 0b01 | 0b0.01 recurring |
1 / 6 (0b1 / 0b110) | ? | 0b0.001, 01 recurring |
If system has OpenSSL v1.0+, dependancy openssl v0.9.24
fails to install. Searching around reveals that openssl v0.10+
fixes this incompatibility.
If I add openssl = "^0.10"
to rink Cargo.toml
, it installs without issues.
Didn't create a pull request as I'm not familiar with rust and not sure if this is a valid solution.
Right now rink takes all command line argument(s) as a file to load, and it doesn't deal very well if the file isn't there, perhaps because you innocently tried to use -h
to see if there was any command line usage help:
$ rink -h
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', src/libcore/result.rs:906:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
It would be nice if rink supported -h / --help, and also perhaps --version, especially if one or the other reported the URL of the repository (so I could remember to check it every so often for new versions).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.