[HN Gopher] Show HN: I made a web-based notepad with a built in ...
___________________________________________________________________
 
Show HN: I made a web-based notepad with a built in unit calculator
 
Hi HN  It also supports percentages, dates and variables.  I've
been working on this alone for a few years now, so would love to
get some feedback.
 
Author : tonyonodi
Score  : 425 points
Date   : 2022-08-17 09:01 UTC (13 hours ago)
 
web link (numpad.io)
w3m dump (numpad.io)
 
| harpiaharpyja wrote:
| Very cool! Any plans to support vector/matrix operations? I
| occasionally do some work with 2D/3D graphics or physics and
| having some basic linalg would be nice.
| 
| I can see myself using this a lot as a scratch pad to hash out
| ideas while implementing stuff. The ability to define custom
| functions would be very helpful for that.
 
  | tonyonodi wrote:
  | It's something I've thought about but I'm not sure I'm going to
  | implement it for a while as it would be quite a big
  | undertaking. The same is true of complex numbers unfortunately.
 
| botinko wrote:
| 2+2 -> 4 ok 2+2 _2 - > 6 ok 2+2_2-3 -> 0 What?
 
  | suntuba wrote:
  | Yes - there is a precedence problem. Try 2*2-3 (2 times 2 minus
  | 3).
 
| samwillis wrote:
| I like how you are using a Gist for the exchange rates (https://g
| ist.github.com/tonyonodi/e154f529180b1f0f475966d333...), do you
| have a GitHub action setup to automatically update that?
 
  | tonyonodi wrote:
  | Impressed you found that. I don't have anything set up to
  | automatically update it currently, but I do have an _intention_
  | to have something set up to automatically update it.
 
    | ewidar wrote:
    | Btw the conversions don't seem to work for me:
    | 
    | > 100 eur to usd $-100.63 > 100 usd to eur Incompatible units
 
      | mkishi wrote:
      | The right operator for unit conversions is "in." "to" is
      | used for ranges, so it's doing 100 euros _goes to_ 1 us
      | dollar and giving you back the answer in dollars.
      | 
      | But it seems the parser is breaking when trying to do the
      | inverse, anyway: "100 usd in eur" seems to do "e*ur" and
      | gives "Values must be converted to units."
 
    | samwillis wrote:
    | Ha, yes, I was being nosy. It was quite easy to spot as it's
    | the only XHR/Fetch request.
    | 
    | I was intrigued what you had used to build it, and if you had
    | built your own solver (which you have), and what editor you
    | used (Code Mirror) so went looking at the code. Interesting
    | to see you left the source maps for production, made it easy
    | for my sleuthing...
    | 
    | I experimented with a similar idea last year, but used
    | ProseMirror/TipTap as the editor to enable rich text editing,
    | and the MathJS (https://mathjs.org) solver. I also combined
    | it with PouchDB and Yjs for offline editing and syncing
    | between devices. Never finished it though, you have kept your
    | nice and simple!
 
      | tonyonodi wrote:
      | Oops, didn't realise I'd left source maps in, thanks for
      | pointing it out!
      | 
      | Your project sounds really interesting, I'm following you
      | on twitter now, so tweet about it if you ever finish it and
      | hopefully I'll see.
      | 
      | Having CRDT-based syncing/collaboration is a direction I'd
      | like to take NumPad in eventually, and if I have time. But
      | I definitely think that ignoring that part completely has
      | allowed me to get it to an MVP state.
 
| tonfreed wrote:
| Very cool idea, would love to see it work with recipes if you
| could manage it. I always have to look it up when I see a cup of
| butter listed in the ingredients of a cake
 
| OJFord wrote:
| This is great, I use `bc` a lot at work (particularly when away
| from desk and my actual calculator) but I'll probably bookmark
| this to use instead.
| 
| One bit of very minor feedback:
| 
| `x^y tonnes` errors 'exponent must be unitless'. The more
| expected (IMO) grouping `(x^y) tonnes` works, so why not have the
| non-error grouping be the implied one, when no parens given?
 
  | tonyonodi wrote:
  | I hadn't thought about that before but I think you're right,
  | I've added it to my roadmap.
  | 
  | Getting operator precedence right has been pretty fraught tbh.
  | For example "1km / 3 hours" is evaluated as "(1km) / (3
  | hours)", but "1 / 3 hours" is evaluated as "(1 / 3) hours",
  | which is odd from a PL perspective, but I think it's more
  | intuitive from a user perspective for this sort of thing.
 
| mixcocam wrote:
| I wonder when Google docs will introduce this type of feature.
 
  | radiojasper wrote:
  | ... and then cancel it 2 years after?
 
| mjaniczek wrote:
| Very nice! Bookmarked.
| 
| I found a small bug: `5 hours 20 minutes` will give you `5 hr 19
| min 60 s`. This only happens with some numbers in the minutes
| slot.
 
| infinityio wrote:
| on a similar note - QALC in vscode offers a similar experience
| for file types of your choosing
 
| flanbiscuit wrote:
| Looks good! I love the idea of the embedded calculator
| 
| I noticed that it doesn't handle remainder/modulo (%) equations:
| 
| "10 % 2" results in: "Left hand side of addition cannot be a
| percentage."
| 
| It does look like decimal.js can handle that:
| https://mikemcl.github.io/decimal.js/#mod
| 
| https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
 
  | ianbicking wrote:
  | You can do "6% of $10" and get "$0.6" (minor note that it would
  | look better as $0.60).
  | 
  | Looks like there's a mod operator, so "2303 mod 10" gives 3.
 
  | mcintyre1994 wrote:
  | It does, but you have to type `10 mod 2`
 
| jjt-yn_t wrote:
 
| tiagod wrote:
| Hey, great tool!
| 
| Just a little bug: I found that if I click a number to copy, then
| click it again, I'll get the original string in my clipboard
| concatenated with " Copied!"
 
  | tonyonodi wrote:
  | Glad you like it! Thank you for the bug report, I'll get it
  | fixed shortly
 
| layer8 wrote:
| This is really neat, but you need to rethink the
| date/time/duration arithmetics. You're equating 12 months with
| 365.25 days, which gives rise to results like "1 month - 31 days"
| giving "-0.0184804928 months". At the same time, "30th January +
| 1 month" gives "28 Feb 2022 at 12:00:00" (why "2022", and why "at
| 12:00:00"? -- this is only a date calculation without reference
| to a year or to a time of day), while "30th January + 30 days"
| gives "1 Mar 2022 at 12:00:00", although "1 month in days" gives
| "30.4375 days".
| 
| In reality, months/years are simply not convertible to days/weeks
| arithmetically, and you can't sensibly add months to certain
| dates, and sometimes also not years (for February 29th). The
| former should give "Incompatible units", and the latter should
| result in something like "Undefined" for incompatible dates.
 
| suntuba wrote:
| Nice app - I like the workspace sharing feature.
| 
| It would be nice if "1 mm / inch" would be returned as a unitless
| number. I know that you can enter "1 mm in inch" but there are
| cases where it would help to have the calculator reduce the units
| for you.
 
  | tesseract wrote:
  | For what it's worth, `1 mm/inch in 1` seems to work as
  | expected.
 
| akino_germany wrote:
| TIL that it is convention in the English language to place the
| euro sign in front of the amount and not after it, like in most
| other European languages.
 
  | skrebbel wrote:
  | TIL: Germans put it after the amount :-)
  | 
  | (I'm European too and I thought it was always in front,
  | everywhere)
 
    | LoveMortuus wrote:
    | Slovenian here, we put it after. It makes more sense, at
    | least to me, since you do say that apple costs five euros,
    | where as the other way around: That apple costs euro five.
    | Which would here mean that it costs 1.05EUR and not 5EUR.
 
  | tonyonodi wrote:
  | Yeah, I'm British and I'll concede that how we write it doesn't
  | make sense. I do intend to localise it/add options in the
  | future.
  | 
  | NumPad currently accepts numbers in the "9,999.9" format, which
  | is the default in the anglosphere, but "9.999,9" is common
  | elsewhere. So that's another thing I'd like to address in the
  | future.
 
| kretaceous wrote:
| There are a few bugs as people have mentioned but the currency
| support is a huge win for me. Thanks for making this!
 
| majkinetor wrote:
| There is a bug with unintendend addition if word starts with the
| variable name                   e2foo 4.7182818285         pi-
| hole 3.1415926536
 
| pwdisswordfish0 wrote:
| The docs say that this is using CodeMirror. The CodeMirror
| license says that you're allowed to use CodeMirror for your
| stuff, but that stuff has to in turn include:
| 
| 1. the copyright notice
| 
| 2. the text itself that explains that you/others have this
| permission/obligation
| 
| Currently, it looks like NumPad isn't doing either.
| 
| From comments here, NumPad is evidently also using decimal.js,
| which has similar terms.
 
  | ianbicking wrote:
  | The About page is also a reasonable place to put credits
  | (whether required or not)
 
  | tonyonodi wrote:
  | Both are MIT licensed, I don't think this is the case.
 
    | samatman wrote:
    | It's true of source code but not artifacts. MIT places no
    | obligation to distribute source, but requires credit and
    | license when someone does so.
 
      | pwdisswordfish0 wrote:
      | > It's true of source code but not artifacts.
      | 
      | That's simply not true. Please don't do stuff like this--to
      | go off and make these kind of proclamations in public. It's
      | negligent at best.
 
        | afro88 wrote:
        | Just when I thought I understood the MIT license, I'm
        | back to confused. Can you link me to where this is
        | clearly outlined? Do you need to attribute somewhere in
        | artifacts or not?
 
      | tonyonodi wrote:
      | Thanks for clearing that up, I'm not distributing the
      | source code so I think I'm good.
 
        | pwdisswordfish0 wrote:
        | Don't look to people who don't know what they're talking
        | about to "clear things up" for you. If you think they
        | have any qualms about leaving you to deal with the
        | blowback after misleading you with uninformed takes (and
        | pointing the finger at you for putting your faith in them
        | to begin with), then you're setting yourself up to be
        | burned.
        | 
        | There's a reason why everyone who has their ducks in a
        | row (in other words, people with competent legal counsel
        | along with something to lose, e.g. Mozilla, Google,
        | Apple, Microsoft, etc) will bake something like
        | about:license into the stuff they work on, even if it's
        | buried in some "open source licenses" entry of an About
        | screen reachable by the last menu item in the system
        | settings. Spoiler alert: _it 's because they have to_--in
        | order to comply with the terms of the license. It's not
        | because they just think it's the nice thing to do. (And
        | definitely not because it's fun and easy to do, because
        | it's not.)
 
| 0xRusty wrote:
| It's very nicely done, but I'm afraid I don't "get it" with
| things like this and written out calculators in general. Why
| would I type out something long like:
| 
| " Alice's food = PS30 Bob's food = PS25 VAT = 20% Alice's food +
| Bob's food + VAT "
| 
| Rather than just punch (30+25)*1.2 straight into a calculator?
 
  | wccrawford wrote:
  | Maybe you want to store all that information for later and also
  | want the calculation, both now and later?
 
    | 0xRusty wrote:
    | So...a spreadsheet?
 
      | samwhiteUK wrote:
      | A spreadsheet won't automatically work out and display
      | units for you
 
  | samatman wrote:
  | I've found that the Calca[+] format hits a nice sweet spot
  | between using an ordinary calculator and running a spreadsheet.
  | 
  | [+]: http://calca.io
  | 
  | It's particularly suited to calculations I'm doing by fetching
  | various numbers from websites, and for the most part it
  | 'composes' by just copypasting a calca into another one.
  | 
  | Basically where the numbers mean something, aren't stable / I
  | don't know them all when I start, but there's no tabular data
  | or significant aggregation going into the question.
 
| adamddev1 wrote:
| I like this! One thing that would be nice is a time zone
| converter. For example:
| 
| 8:00pm 24 Aug Toronto time in Dubai time
| 
| And have the conversion show up.
 
  | tonyonodi wrote:
  | It's on the list ;) https://numpad.io/about/
 
| ghjm wrote:
| Maybe there's already a way to do this, but it seems to me that
| it would be useful to be able to refer to the answer on a
| previous line, like the Ans key on a TI calculator. So:
| 
| 2 + 3 (=4)
| 
| Ans * 2 (=8)
 
  | softawre wrote:
  | x = 2 + 3
  | 
  | x * 2
 
| ajsnigrutin wrote:
| Fun idea, but:
| 
| 10^900=[?] :)
 
  | tonyonodi wrote:
  | I think that's right, isn't it?
 
| euos wrote:
| Looks so cool and clean. Stealing the design for my project
 
| bww wrote:
| This looks pretty cool. I've long been looking for something
| similar to Soulver (https://soulver.app/) that I can use on
| Linux. This seems promising.
| 
| One small criticism: In my opinion, no web-based writing app is
| useful unless the tab key inserts a tab. The default behavior of
| most browsers to move focus to the next field is tremendously
| infuriating in this context. Unfortunately, that's what happens
| here, at least for Firefox.
| 
| (Related: key combinations that normally perform cursor movements
| but which are often used by browser for navigation.)
 
  | mk12 wrote:
  | I've never used Soulver, but there is a free web app
  | https://numbr.dev that seems very similar to it.
 
  | tonyonodi wrote:
  | Yeah, honestly this has been annoying me too, I just haven't
  | got around to fixing it. It's using CodeMirror 6 as the editor,
  | the author said he deliberately made this version not "break"
  | the default tab behaviour, which I think is understandable as a
  | library author, but that makes it my job to fix!
 
    | math-dev wrote:
    | I thought CM had some example code on how to override the tab
    | behaviour. Might be worth checking out as I agree it sucks to
    | not have tab = indent 4 spaces
 
      | chrisweekly wrote:
      | 2 spaces!
      | 
      | (ducks) (but srsly)
 
    | dugmartin wrote:
    | To save you some time, here is what I did to add tabs to CM 6
    | (I think I found it somewhere or I may have cobbled it
    | together to insert two spaces):
    | 
    | First import things you need:                   import {
    | indentMore, indentLess } from "@codemirror/commands"
    | 
    | Then create a command:                   export const
    | insertTab: StateCommand = ({state, dispatch}) => {
    | if (state.selection.ranges.some(r => !r.empty)) return
    | indentMore({state, dispatch})
    | dispatch(state.update(state.replaceSelection("  "),
    | {scrollIntoView: true, userEvent: "input"}))           return
    | true         }
    | 
    | and then add it to the keymap in your extensions array:
    | const extensions: Extension[] = [           ...other
    | extensions here...,           keymap.of([
    | ...closeBracketsKeymap,               ...defaultKeymap,
    | ...searchKeymap,               ...historyKeymap,
    | ...completionKeymap,               {key: "Tab", run:
    | insertTab, shift: indentLess}             ]),         ]
    | 
    | and then pass the extensions array into where you setup your
    | editor view, eg:                   const view = new
    | EditorView({           state: EditorState.create({
    | doc: textarea.value,             extensions           }),
    | parent: editor         })
 
  | madrox wrote:
  | While I tend to agree, this can break accessibility. The
  | official WAI-ARIA authoring practices recommend Control+M.
  | https://www.w3.org/WAI/ARIA/apg/
  | 
  | There should likely be an explicit override of accessibility so
  | the visitor knows what they're getting into.
 
  | usrme wrote:
  | Might not be as comprehensive as Soulver, but here's something
  | I've been using in a browser to fiddle with:
  | https://cruncher.io/.
 
    | tonyonodi wrote:
    | Gosh, everyone has made one of these haven't they?
 
      | jen729w wrote:
      | Not everyone! About five people from a population of six
      | billion. And you're one of them.
      | 
      | Yours looks great. Well done on the release.
      | 
      | Line 100 might have an error though? It isn't recognising
      | `30th Sept`, does it not like the final `t`?
 
      | makach wrote:
      | I have as well :-) but I lose for not having released. This
      | version is pretty cool though, will probably not gonna use
      | it because same reason I didn't evolve my version. Don't
      | need it, and when I need it I don't need for it to be
      | dynamic.
 
    | Groxx wrote:
    | > Cruncher can also automatically plot changes as you adjust
    | a variable
    | 
    | Well that's pretty neat. I've seen it in fancier setups, but
    | not something Soulver-like. It seems a lot more usable here,
    | since practically any equation can show it.
 
  | sabellito wrote:
  | I've made this one and use it daily:
  | 
  | https://github.com/filipesabella/calcpad
  | 
  | It's electron though, if that's important to you.
 
    | anthropodie wrote:
    | Hey this is pretty cool. Instead of Electron app I would
    | prefer it as a browser tab. Wish it could be self hosted.
 
      | sabellito wrote:
      | Thanks!
      | 
      | You can use the web version, it's all offline and saved in
      | localStorage. Works well in mobile too and can be
      | "installed" as an app from there.
      | 
      | https://filipesabella.com/CalcPad
 
        | grimgrin wrote:
        | I wanted to see how this would run in redbean[1], and it
        | runs fantastically!
        | 
        | If you wanna see this in a little executable that you can
        | pass around to your friends, check out this repo I threw
        | up: https://github.com/shmup/redbean-calcpad
        | 
        | This is now essentially an offline CalcPad that still
        | leverages LocalStorage, since the UI is your browser.
        | I've configured this specific build to automatically
        | launch your default browser when you run it.
        | 
        | 1. https://justine.lol/redbean2/
 
  | sigmaprimus wrote:
  | Good Feedback! I would think a checkbox that enables tab
  | function would be best, how would you feel about a FF Plugin
  | that achieves this? My only concern would be that FF has
  | reserved that particular key and it would require special
  | permissions to map it to your needs.
 
    | addandsubtract wrote:
    | I think it should just be a toggle on the page: "Hijack
    | keyboard shortcuts? Y/N". Figma, Miro, Google and co do it
    | without asking. It's something we've come to expect with web
    | apps, so a toggle would be a fair middle ground.
 
  | cpow3104 wrote:
  | I came here to deposit this exact same comment with one
  | addition. Great project but seems to be lacking base support.
  | As an engineer I need hex at least.
 
  | justinlloyd wrote:
  | SoulVer on macOS as you know. OpalCalc on Windows. Speedcrunch
  | on all three platforms, though I will categorically state that
  | whilst Speedcrunch is very good, it is no Soulver/OpalCalc.
 
| spectaclepiece wrote:
| This is an excellent tool, would be good to have some simple
| rounding functionality. Perhaps a generic visible decimal points
| settings or a round() method of some sort.
 
| reaktivo wrote:
| One thing that I haven't found supported in other calculators is
| returning the min or max between two values
 
| supernes wrote:
| "Right hand side of subtraction cannot be a date or time." :(
 
| Severian wrote:
| Can you add bit and byte values, as well as units per unit of
| time please?
| 
| Base 10 (GB for example) and base 2 (GiB) would be very handy.
| Full words as an alias as well, so GB -> gigabyte, and GiB ->
| gibibyte.
| 
| That way you can do something like:
| 
| 1GB / 40MB/s in minutes
| 
| 1GB to Gib
| 
| 1GB to bits
| 
| 50 bits to bytes
 
  | tonyonodi wrote:
  | Yes I can, I'm busy with launch stuff today but I'll get that
  | done soon
 
| xixixao wrote:
| I also made one of these, still working on it now with a focus on
| including support for accuracy/measurement errors.
| 
| This is impressively close to what I have in my desired spec (but
| already more future proof). Congratz!
| 
| https://github.com/xixixao/recomputer
| 
| https://xixixao.github.io/recomputer/
 
  | tonyonodi wrote:
  | Nice work! I like that you're using rational numbers, I thought
  | about going that route but decided to compromise by using
  | Decmial.js in the end. Also really like the "Same Use Case"
  | section in your readme. It's a good summary of the reasons I
  | made this app :)
 
| majkinetor wrote:
| On srelated note, I use Markdown Excel:
| 
| * https://github.com/cescript/MarkdownFormula
| 
| Its totally awesome, although it needs some more work.
 
| xaduha wrote:
| I'm surprised no one mentioned https://insect.sh yet.
 
| badcppdev wrote:
| Mini feedback: The difference between a defined variable and an
| undefined variable could be clearer. And should an expression
| with an undefined variable still give a value?
| 
| So if you had: Alice's food + Bob's foood = PS30 then I think
| there should be more to highlight the typo.
| 
| P.S. This is an awesome thing
 
  | badcppdev wrote:
  | Ooh a super useful function (in my experience) is the monthly
  | mortgage repayment calculator.
  | 
  | MonthlyRepayment(principle, annual_interest, term_in_years)
 
| owl110 wrote:
| Looks very interesting. I think there is some ambiguity with
| respect to currency symbols, $ converts to USD and PS to GBP.
| However, depending on user location those symbols can be used to
| mean very different currencies.
 
  | tonyonodi wrote:
  | Is there anywhere else that uses "PS"? I didn't feel great
  | about having $ default to USD but it is probably what most
  | users want. I'll probably make it location-aware and/or allow
  | the user to decide which it defaults to in the future.
 
    | owl110 wrote:
    | I believe pound sign is used in a few other places as well
    | (see https://en.wikipedia.org/wiki/Pound_sign). Enforcing the
    | use of ISO 4217 codes
    | (https://en.wikipedia.org/wiki/ISO_4217) may be a solution to
    | avoid this type of ambiguities.
 
| doerig wrote:
| Very nice! Reminds me a lot of numi (https://numi.app). Similar,
| but MacOS only (and paid).
 
  | athenot wrote:
  | Big fan of numi, somehow I like it better as a smaller window
  | tucked on the corner of my screen than a full browser page.
 
| staz wrote:
| I find it pretty cool.
| 
| Some feedback: I tried to convert m/s in km/h and it wouldn't
| works, finally found how to do it, you need to specify `hour` in
| full letters
| 
| I assumed it was something like an etherpad that you could edit
| collaboratively but apparently not
 
  | tonyonodi wrote:
  | "kph" is also supported, will add support for "km/h"
 
    | joshspankit wrote:
    | And `mpg`/`l/100k` please!
 
      | tonyonodi wrote:
      | I've avoided adding mpg because the UK and US disagree on
      | what a gallon is and mpUKg/mpUSg is not very nice to look
      | at. You can write "miles per gallon" or "miles per US
      | gallon" because per is the same as the "/" operator, and
      | you can _sort of_ do  "L/100km" but you can't convert to
      | it.
      | 
      | I'll have to think some more about this one.
 
        | joshspankit wrote:
        | I think I see where you're going. I'd be comfortable with
        | "litres per hundred kilometres" if that's possible and
        | especially if there was a "did you mean" suggestion
        | prompt
 
| JacobSeated wrote:
| I would love to have a plain text "notepad" for iOS, because the
| built in app is horrendous and converts links to clickable
| hyperlinks. Etc. Hate that piss shit.
 
| anthropodie wrote:
| Can I self host this?
 
  | jdoss wrote:
  | I second this question. I would love to selfhost this too. I
  | hope the creator considers opensourcing their work.
 
| mkrishnan wrote:
| Love it. Thank you! Thank you! Thank you!.
 
| defrost wrote:
| Nice - I'll give it props for:
| 
| > 1 metre + 8 chain = 161.9344 m
| 
| > 1 tonne + 1 short ton = 1.90718474 t
| 
| > 1 tonne + 1 long ton = 2.0160469 t
| 
| and give it a pass for not supporting pre 1963 UK | US historic
| weights and measures .. that's getting into a pretty specific use
| case where Standards nerds like to have a clear display of what
| conversion factors are in play and what provenance those factors
| have.
| 
| Time Zone support (on your About ToDo) will be interesting,
| historic computations with daytime savings support will be a
| quagmnire :-)
| 
| The SHARE DOC URLs seem a bit long - something like "base64 full
| text of doc as an URL" I guess.
| 
| Will this hit a URL length limit if widespread use becomes a
| thing?
| 
| jq play : https://jqplay.org/s/f1r-BZ5xYd2
| 
| regex101 : https://regex101.com/r/OqojJl/1
| 
| do server side storage and doc hash .. which has issues of its
| own.
 
  | tonyonodi wrote:
  | You're right, I'm using lz-string to compress the text before
  | shoving it in the URL. This is definitely a necessary evil for
  | the time being so I don't need a back end component to the app.
  | But eventually I do want prettier URLs and collaborative
  | editing if I can make that work without it bankrupting me or
  | driving me insane.
 
    | joshspankit wrote:
 
    | simonz05 wrote:
    | Be aware URL field in browsers have a maximum number of
    | characters they accept.
 
    | dunham wrote:
    | For what it's worth, the typescript playground takes the
    | exact same approach as you, placing a compressed (lz-string)
    | copy of the text after the #code/ in a sharing url.
 
  | tonyonodi wrote:
  | Well, I love this comment. And yes, time zone support terrifies
  | me an order of magnitude more than anything else on the list.
 
    | defrost wrote:
    | On the gnarly scale dealing with with pre-WGS84 paper maps
    | from about the globe is arguably worse ..
    | 
    | there are so many reference ellipsoids and datums used in
    | different parts of the world at different times .. and then
    | there are the many variations on curved surface to flat map
    | projections to deal with.
    | 
    | But yes - Time and date is an iceberg domain :-)
 
  | XorNot wrote:
  | Didn't tell me how much 8 gills[1] would be in liters (about 1)
  | 
  | [1] https://en.wikipedia.org/wiki/Gill_(unit)
 
    | tonyonodi wrote:
    | I am truly sorry
 
    | hcrisp wrote:
    | I was disappointed it couldn't convert "1 furlong / 1
    | fortnight in mph", but this was successful:
    | 
    | > 14 furlongs / 2 weeks in mph [0.0052083333 mph]
 
      | tonyonodi wrote:
      | That's a very enjoyable calculation!
 
| T3RMINATED wrote:
 
| dubcanada wrote:
| Small bug report
| 
| 23 USD to CAD = -28.875332087 CAD
| 
| $23 USD to CAD = -30.174259569 CAD
| 
| It does not appear to like the USD/CAD stuff
 
| amelius wrote:
| For the next step, maybe you can build an editor/autocomplete
| with a search-engine in it (you can use an existing search
| engine).
 
| GauntletWizard wrote:
| I would really appreciate if there were units for si prefixes,
| common orders of magnitude, and compute, i.e. "G", "M", "billion"
| "million", "megabytes" and "gigabytes"
 
| jackphilson wrote:
| how expensive was that domain name lol
 
  | tonyonodi wrote:
  | I'm just paying the standard fee for a .io, it's a far less
  | polluted namespace than .com :)
 
| alexcosan wrote:
| Nice work on getting this out. I think it looks pretty neat and
| simple to use.
| 
| I've had some issues when using it though: - on mobile, moving
| the cursor in a calculation doesn't work very well; - More
| important, multiplying "200 * 10%" results in "2000%", I believe
| the result should be "20";
| https://www.wolframalpha.com/input?i=200+*+10%25
 
  | joshspankit wrote:
  | I also had issues navigating on mobile (iPad). There seem to be
  | hover states that get in the way (example: I tapped on a line
  | to move to that line and it had a small popup to say something
  | was copied)
 
  | np_tedious wrote:
  | Those are equal values right? This is just formatting
  | preference.
  | 
  | I agree formatting should probably go with the first factor,
  | but I wouldn't say current behavior is incorrect
 
| spiffytech wrote:
| Very cool!
| 
| This reminds me of the open source NoteCalc:
| https://bbodi.github.io/notecalc3/
| 
| It was discussed on HN, you might look there for inspiration:
| https://news.ycombinator.com/item?id=25495393
 
  | bbodi wrote:
  | I am the author of NoteCalc, and it warms my heart that my
  | project is mentioned here :)
  | 
  | As a sidenote I would like to mention that NoteCalc is still in
  | active (but slow) development, though I do it privately, and
  | the next big release will be definitely this year.
 
    | mad2021 wrote:
    | Just discovered NoteCalc, really cool. Thanks!
 
  | tonyonodi wrote:
  | I hadn't seen that before, it's very impressive!
 
| zwog wrote:
| When I type `4W*3hours` the result is `12 mWh`. Same with
| `12Wh/3hours = 4kW`
 
  | tonyonodi wrote:
  | Oh, thank you for the bug report. I'm not sure why that's
  | happening, but will look into it shortly.
 
| dskloet wrote:
| On my Android phone I can't see the last letter of some lines and
| I'm unable to zoom out.
 
  | tonyonodi wrote:
  | I'm sorry about that, I don't have an Android device to test
  | on. But I'll fix that when I get hold of one.
 
    | dskloet wrote:
    | I also notice when typing a number it gets entered twice. So
    | I'll type a 3 and get 33.
 
| sandgiant wrote:
| This is great! Love Soulver too, but having it in the browser is
| fantastic. Well done!
 
  | tonyonodi wrote:
  | I'm a big fan of Soulver too! It's the OG in this app category
  | and I still use it for calculations NumPad can't do (yet!).
 
| stephc_int13 wrote:
| I really like it, except the fact that it is not an app but
| something on the web.
| 
| I wish it could be something lightweight and launched as a native
| app.
 
| bkazez wrote:
| Very cool! Some ideas:
| 
| 1. Doesn't seem to support area conversions (tried 400 square
| meters, 400 m^2, and abbreviations in between).
| 
| 2. If I only give a time, it would be more useful if it gave a
| time-only result rather than defaulting to the current date -
| unless it rolls over to a different date. (E.g. in Soulver,
| "2:30pm + 20hr" gives "Tomorrow at 10:30".)
| 
| 3. It would be nice to support multiple abbreviations for minutes
| (mn/min are both used in various countries).
 
  | tonyonodi wrote:
  | Thanks for the feedback
  | 
  | 1. "square" before a unit I probably will implement that in the
  | future. I'm not sure why "400 m^2" isn't working for you, I've
  | just tried it and it works as expected for me?
  | 
  | 2. It's a little bit clunky, but I decided to always specify
  | the time and date being shown because there's so much potential
  | for ambiguity. I might revisit this if I can think of a better
  | way of doing it that's still unambiguous (the Soulver way isn't
  | bad tbh)
  | 
  | 3. "min" is supported, I've never come across "mn", do you know
  | where it's used?
 
  | zweifuss wrote:
  | 400 inch^2 -> 400 inches2 10 km^2 -> 10 km2
  | 
  | ... works for me.
 
    | bkazez wrote:
    | Ohhh, I missed that "->" was the operator. I was typing "to"
    | as in Google searches.
    | 
    | Re dateless times, yes, I think the Soulver way is
    | unambiguous but still human-friendly.
 
| huhtenberg wrote:
| Math is not terribly precise I'm afraid :)                 >
| 1111111111111111111111111111111*9       >
| 10,000,000,000,000,000,000,000,000,000,000
 
  | joshspankit wrote:
  | That doesn't _seem_ like a floating point inaccuracy. What's
  | going on there?
 
    | tonyonodi wrote:
    | NumPad uses Decimal.js to represent numbers
    | 
    | https://mikemcl.github.io/decimal.js/
 
| bflesch wrote:
| Found an error:                   20mm * 30mm * 7mm in m^3 ->
| incompatible units
 
| seper8 wrote:
| Love it! This kind of stuff should be added to notepad on Windows
| (in an opt-in manner)!
 
  | imagine99 wrote:
  | IIRC, calc.exe (Windows Calculator) has some (limited) unit
  | conversions built in. Better than nothing in an offline
  | environment...
 
| menthena wrote:
| how do you do
| 
| great work, bookmarked.
| 
| "Share doc" is not clear imo. Why not "Save & Share"?
 
| dabedee wrote:
| Looks awesome! Well done! It would be great to have a similar UI
| for LaTeX or maybe even a REPL. Cheers!
 
  | argulane wrote:
  | https://www.overleaf.com/ comes quite close
 
| ivolimmen wrote:
| This looks really useful for a quick calculation. Thanks for the
| bookmark!
 
| lazylion2 wrote:
| "Share Doc" doesn't work if you edit a shared doc
 
| vhanda wrote:
| This is awesome.
| 
| Minor bug report -
| 
| * 5 feet 8 inches to centimeters -> -171.72 cm
| 
| * 5 feet 8 inches to meters -> -0.7272 m
| 
| * 5 feet 8 inches to cms -> doesn't work
| 
| The conversion seems wrong in the case of cms, and I'm not sure
| why it's always negative.
 
  | Spare_account wrote:
  | After reading the sibling comments to mine, I've worked out
  | what it is doing.
  | 
  | > _* 5 feet 8 inches to centimeters - > -171.72 cm_
  | 
  | As @defrost said, the 'to' operator instructs NumPad to
  | calculate the distance from the unit before 'to' and the unit
  | after 'to'.
  | 
  | To the nearest mm, 5 feet 8 inches = 172.72cm
  | 
  | It appears that NumPad is defaulting to a value of '1' where no
  | value is specified, so it is calcuating the distance BACK from
  | '5 feet 8 inches' TO '1 centimeters'.
  | 
  | It correctly responds with -171.72, which is 1cm less than
  | 172.72.
  | 
  | > _* 5 feet 8 inches to meters - > -0.7272 m _
  | 
  | Same as above, except the calucation is the distance back from
  | '5 feet 8 inches' TO '1 metres'.*
  | 
  | If you use the operator 'in', NumPad calculates the answer
  | correctly:
  | 
  | 5 feet 8 inches in metres -> 1.7272 m
 
  | defrost wrote:
  | "to" is a subtraction operation, not a convert to cue.
  | 
  | As in (distance from) 30 to 50 (is 20 == 50 - 30 )
 
  | radiojasper wrote:
  | "cms" is nothing, try "cm". Also you're 100% correct that this
  | shouldn't be a negative number. Screenie [0]
  | 
  | [0] https://jasper.monster/sharex/firefox_eXIffwiyBq.png
  | 
  | //EDIT
  | 
  | Ah yeah, replace "to" with "in" and you're good! [1]
  | 
  | [1] https://jasper.monster/sharex/firefox_rVKx2w1TUI.png
 
| seligman99 wrote:
| Along the same lines, I made a command line calculator that does
| basic unit conversions, and has a few other tricks up it's sleeve
| 
| https://github.com/seligman/human_calc
| 
| I find it surprisingly useful. It's probably one of those things
| that has an audience of one, but I find it useful.
 
  | tonyonodi wrote:
  | This is really cool, you're a braver person than I for tackling
  | the English representation of numbers stuff!
 
| swah wrote:
| Congrats! I'd say it makes no sense to post here before doing
| hex,bin,dec conversion and bitwise operations ;)
 
| AbraKdabra wrote:
| I tried converting USD to ARS and it didn't work, I guess you
| should make a list of how units are named so I can use the
| correct one.
 
| shash wrote:
| Interesting! Thank you...
| 
| I was trying to divide an area by a smaller area to get the
| number of widgets, and it insists on making that into a
| percentage. Is there a way to make it report a raw number instead
| of percentages when the two quantities are the same unit?
 
  | tonyonodi wrote:
  | What's the exact calculation you're doing?
 
| shreyshnaccount wrote:
| THIS IS AMAZING. the next step is adding variables and
| assignments and conditionals, and you have something very
| powerful that can be used by just about anybody to do really
| interesting things. provided you have a way to integrate with
| other services that a lot of people use
 
  | janjones wrote:
  | Variables and assignments are already supported.
 
    | shreyshnaccount wrote:
    | should rephrase, meant to say (variables, assignments) AND
    | conditionals
 
  | tonyonodi wrote:
  | Thanks! Turning the current language into a Turing complete one
  | would be a huge step up in complexity and I'm not sure it will
  | ever make sense to implement. But I have thought about adding
  | the ability for users to define their own functions in JS and
  | might get around to that one day.
 
    | shreyshnaccount wrote:
    | I see. despite my not totally unjustified hate of Javascript,
    | Im looking forward to it.
 
| dailyplanet wrote:
| The feet to meters conversion, or vice versa, doesn't work.
 
| kiemrong08 wrote:
| love it, i bookmarked
 
| xerxesaa wrote:
| Super cool. I wish this was open source so I could see how you
| did some things, but I understand you've decided to keep it
| closed. Just to satisfy my curiosity, would you mind sharing how
| you did parsing at a high level? Did you use some publicly
| available parser/lexer or did you just implement pattern matching
| yourself with something like regex or other token splitting
| measures?
 
  | ralphb wrote:
  | I've found that a super simple way to parse basic expressions
  | is a recursive descent parser. It is very simple to implement.
  | No need to to break into tokenizer/parser, no need to generate
  | an AST, just evaluate the expression while parsing.
 
    | lsferreira42 wrote:
    | Do you have an example of a simple parser like that?
 
  | tonyonodi wrote:
  | I'm very glad you asked. I wrote my own parser combinator
  | library in TypeScript partly based on eulalie[0], so it doesn't
  | have a separate lexer and parser and doesn't rely heavily on
  | regexes (though it does use them to do things like match a
  | single alphanumeric character). I plan on open sourcing this
  | library one day once I can tidy up the API because I think it
  | would be useful to other people.
  | 
  | But to give you an idea of what that all looks like this is the
  | code for the parser that parses the "as a % of" operator:
  | append(         string("as"),         oneOrMore(space),
  | optional(append(string("a"), oneOrMore(space))),
  | percentSymbol,         oneOrMore(space),         string("of")
  | )
  | 
  | [0] https://github.com/bodil/eulalie
 
    | joe8756438 wrote:
    | Thanks for sharing, I had the same question!
    | 
    | I wasn't familiar with Eulalie, that's a really interesting
    | approach. I built functionality [0] similar to numpad into a
    | larger record-keeping system, Tap [1]. Precedence rules
    | kindof scramble my brain so I ended up implementing
    | s-expression syntax for Tap formulas.
    | 
    | I ended up writing the parser myself, called sowhat, but used
    | a library for tokenization, moo.js [2]. You can see a demo of
    | just the sowhat editor here [3].
    | 
    | 0. https://www.tatatap.com/formulas 1.
    | https://www.tatatap.com 2. https://github.com/no-context/moo
    | 3. https://tatatap-com.github.io/sowhat-editor/
 
| ttoinou wrote:
| Nice. Could this be done with a VS Code extension ?
 
  | tonyonodi wrote:
  | I've never made a VS Code extension, but I think it would be
  | possible; no plans to do so currently though.
 
  | nudpiedo wrote:
  | there are several inline repl extensions, for many many
  | programming languages. One of the first ones to do it was
  | clojure, imitating the lighttable IDE. I believe you will find
  | similar ones for other languages
 
| hidelooktropic wrote:
| This is a great demonstration of a feature I feel is greatly
| missing from modern note taking applications like Notion.
 
| elcritch wrote:
| Looks nice! Making the result blocks non-text is handy. Any plans
| to open source this or sell a desktop version? I've long been a
| fan of http://calca.io but it doesn't run on Linux. There's some
| other versions out there but they tend to be flaky.
 
  | tonyonodi wrote:
  | Glad you like it! I've got a desktop version in the works, and
  | if the web version gets enough interest I'll finish it off.
 
    | Aeolun wrote:
    | Finish it off sounds like you are going to kill it ;)
 
| ohadpr wrote:
| Fantastic, thank you for implementing one of my future side
| projects. I was planning to build a web-based version of Soulver
| with sharing/collaboration. I hope this can fill that spot for
| me.
 
| sjinta wrote:
| This is awesome! Some feature requests: it would be great though
| if you could have multiple sessions/tabs in stead of 1. Also a
| clear button would be nice.
 
  | mrcartmeneses wrote:
  | Can't you just select all then hit backspace? Asking for a
  | friend...
 
    | sjinta wrote:
    | When using it to make simple calculations while on a phone I
    | think it would be easier than the long click select all
    | delete combo, but perhaps this is not really the aim of the
    | tool.
 
| benecollyridam wrote:
| 1=2
| 
| 1+1 // = 4
| 
| Really nice project though
| 
| https://numpad.io?#text/IwXgTAUMDUxA
 
  | [deleted]
 
  | tonyonodi wrote:
  | Some people just want to watch the world burn.
  | 
  | No, you're right. I thought I'd prevented it from parsing
  | numbers as variables, but apparently not. It's on my todo list
  | now.
 
| amitheonlyone wrote:
| This is really cool. I usually end up doing some weird math
| during development and I usually use the browser developer tools
| which is a bit cumbersome. This might help me replace it.
 
| runxel wrote:
| Really cool! Only missing a "sum" function.
 
  | tonyonodi wrote:
  | Thanks! I'll be implementing a sum (and mean/median/mode)
  | function soon.
 
| barroomhero wrote:
| This is fantastic. I never realized how much I wanted this. Thank
| you for opening my eyes.
| 
| Now we need to port to Obsidian.md! haha.
 
| brospars wrote:
| There is something wrong with the order of operations. When I
| type 2+2*2-6 i get -6 which should be 0.
 
  | simonz05 wrote:
  | Yep, this should be evaluated as `(- (+ 2 (* 2 2)) 6)`
 
  | unsafecast wrote:
  | It looks like APL order? Right-to-left.
 
  | sneak wrote:
  | I would think this might be the first unit test one would write
  | for a calculator program.
 
  | [deleted]
 
  | bdwjn wrote:
  | Oh there's more:
  | 
  | 9 - 3 ^ 2 = 0
  | 
  | 9 -3 ^ 2 = 18 ???
  | 
  | pi = 3.1415926536
  | 
  | 2 pi = 5.1415926536 ???
  | 
  | sin(3.1415926536 radians) = -0
  | 
  | sin(pi radians) = Incompatible units ???
 
    | wizofaus wrote:
    | Seems to assume + if an arithmetic operator is missing?
 
      | tonyonodi wrote:
      | This is correct, the idea is that you can type things like
      | "6 foot 3 inches" and have it evaluate as an addition. But
      | the example shown above is definitely a problem, I'll try
      | to think of a work around.
 
        | wizofaus wrote:
        | I'd think that rule only makes sense after a symbol
        | representing a unit (including potentially 6'3").
        | Certainly   should logically
        | assume multiplication.
 
| unnouinceput wrote:
| One thing it's missing which is trivial to implement. Have a
| little checkbox adjacent to line numbers, default true, that when
| unchecked would simply not parse the calculations, just leave it
| as simple text.
| 
| This way writing "and here is a little example of 9^9^9" and
| simply copy paste that to next line would allow me to not have it
| evaluate on text, but only on next line. OF course, a little more
| complicated to implement would be next step of actually select
| the text and within the pop-up have "Don't evaluate". This way
| writing a documentation without having always calculation be in
| your way would be very easy.
| 
| Other than that, this looks great ma' dude. Keep it up!
 
| llimllib wrote:
| It would be cool if "6 minutes / 1 mile in min/km" showed `3:44`
| instead of (in addition to?) `3.7268`
| 
| I wrote my own little calculator, much less general than this, to
| answer running time questions like "to run an 18 minute 5k, what
| would my mile pace be"? and it would be neat if that were cleanly
| solvable in a tool like this
 
  | tonyonodi wrote:
  | Yeah, that's a feature I really wanted to get out before my
  | launch deadline but sadly it didn't make the cut. Soon though.
 
| carapace wrote:
| See also Frink: https://frinklang.org/
| 
| > Frink is a practical calculating tool and programming language
| designed to make physical calculations simple, to help ensure
| that answers come out right, and to make a tool that's really
| useful in the real world. It tracks units of measure (feet,
| meters, kilograms, watts, etc.) through all calculations,
| allowing you to mix units of measure transparently, and helps you
| easily verify that your answers make sense. It also contains a
| large data file of physical quantities...
 
| felipelalli wrote:
| It would be nice to be an emacs extension. :)
 
| nudpiedo wrote:
| Why limit it to arithmetic?
| 
| Looks much like the original idea behind lighttable IDE which is
| basically a REPL plugin that allows to evaluate certain lines
| within it. There are several similar projects around.
 
  | tonyonodi wrote:
  | Because Turing completeness scares me!
  | 
  | I was a big fan of Light Table when it first came out and the
  | developers behind it have gone on to do some really interesting
  | things, but I want to keep this project more limited in scope
  | for now.
 
| [deleted]
 
| nonoesp wrote:
| I have a side project slightly similar to the functionality your
| tool offers focused on expense tracking (or other measures) over
| time, adding date parsing to the equation in order to plot
| metrics into a graph and with tags and locations for filtering.
 
  | tonyonodi wrote:
  | Nice! Can you send a link or is it still in development?
 
  | Dries007 wrote:
  | I'm (slowly) working on something that can eat up PSD2 data
  | from banks and parse it into some usable data, but I'm bad at
  | nicely presenting stuff. It would be great to see your tool and
  | get some inspiration, or maybe even use it.
 
| botinko wrote:
| 2+2*2-3 calculated as 0. WAT?
 
| jbaczuk wrote:
| Nice! What is the long term goal with numpad?
 
| Lanrei wrote:
| Inline whitespace summation at the same time as mathematical
| operations seems like a problem. I don't think that there's a
| standard order of operation for that sort of thing.
 
| ascar wrote:
| Minor bug report: for whatever reason entering a space on my
| Android keyboard enters the next suggestion on your editor.
| That's a feature I explicitly disabled, but is active on your
| website. On top of that if that enters an unrenderable character
| I see a red dot that's undeletable.
 
| MrGilbert wrote:
| Really cool. Minor user pain:
| 
| When starting a new line, and the first character is 'e', it gets
| evaluated to the euler constant. Would be cool if you could find
| a way to prevent that. :)
 
___________________________________________________________________
(page generated 2022-08-17 23:00 UTC)