Jump to content

Recommended Posts

calculate-anything-af.jpg

 

Calculate Anything is a workflow for Alfred 4, that uses natural language and is able to calculate multiple things like currency, time, vat, px, em, rem, percentage, and more.

 

Why?
 

There are several conversion workflows out there but I wanted a workflow that worked naturally. For example, you can open Alfred, type `100 + 9` and get a result. No need for keywords or hotkeys -- it just works. With Calculate Anything you can do the same, simply type `100 + 16%`, `100 euros to usd`, `100km to cm` or `100 years to hours` and many more.

 

Features


- Natural language - type 100 euros to dollars, 100 euros in usd, 100€ to $, 100eur usd, 100 euros a dolares -- it does not matter, the same result will be displayed It includes support for English, Spanish and Swedish
- Currency - Up to 168 currencies

- Cryptocurrency - Support for up to 5,000 cryptocurrencies
- Units - 100 kilometers to meters or 100 km to m or simply 100km m

- Data Storage - 100 gigabytes in megabytes, 2 gb to mb, 400MiB to kib, 2tb gb, etc.
- Percentages - 100 + 16%, 100 - 16%, 40 as a % of 50, 20 is what % of 50, etc.

PX,Em,Rem,Pt - 12px or 12px to em or 12px pt
- Time - time +15 years, time now plus 6 hours or convert a timestamp
- VAT - value added tax calculations, we all need this
- Translations You can create your own translations to display results in your language
- Keywords Extend the natural language in the queries so you can type 100 dolares a pesos and the code will see 100usd to mxn

 

Important

You will always find the latest version, changelog and updated documentation on Github as is difficult to use the forum to keep track of updates and support. 

 

Requirements for Mac OS Monterey Users and up

Starting from Mac OS Monterey Apple removed PHP so you have to install it manually, that can easily be done with Homebrew, just open your terminal and paste the commands below:

 

1.- Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 

2.- Install PHP

brew install php

 

That's it, you need to have the latest version of Alfred and will automatically find the PHP version that you install.

 

Mac OS Big Sur users and below do not need to do anything, your Mac OS already includes PHP.

 

Download


Download directly from Github releases page, make sure to download the latest release. Download here

 

Configuration


You can configure the workflow using the new Alfred 5 Workflow Configuration window.

 

Currency

 

You can use natural language or a few characters -- that's all! For example:

 

  • 100 us dollars in mexican pesos
  • 100 canadian dollars in argentinian peso
  • 100 euros to dollars
  • 100 euros in dollars
  • 100 euros as dollars
  • 100 euros a dolares (you can also write it in your own language)
  • 100 usd to mxn
  • 100 usd mxn
  • 100usd yen
  • 100€ to $
  • 100 ¥ in €
  • 100¥ €
  • 100eur (if no target the currency will be converted to the base currencies that you configured)

 

You can set a base currencies so if you type for example 120 euros it will be automatically converted to the currencies that you configured.

All these examples just work. You can add spaces between the value and the currency or not.

 

currency-v3.gif

 

Currency Modifiers
 

When a result is displayed you can use action modifiers to copy the value in different formats:

 

  • Return - Press Return to copy the value with format, for example 2,376.54
  • Command + Return - Press Command + Return to copy the value without formatting, for example 2376.54
  • Option + Return - Press Option + Return to copy the value of a single unit, for example 23.76

 

Currency API Key (Not required)

 

By default the workflow will use exchangeratehost api to make the conversion. exchangeratehost only support 32 currencies; if you need support for additional currencies supported by Calculate Anything, you need to get a FREE API Key from https://fixer.io -- it takes less than a minute. Then simply add the API Key in the workflow configuration window.

 

Currency Symbols

 

You can also use currency symbols in your query for example 100¥ to € will be converted to 100JPY to EUR, here is a list of available symbols.

 

Please go to the repo description on Github for a full list of supported symbols it's really difficult to write them here in the forum. View Currency Symbols

 

Cryptocurrency

Calculate Anything can convert between 5,000 cryptocurrencies and 168 currencies. Again, you can use natural language or simply pass the currency symbol.

 

  • 2 bitcoin to dollars
  • 0.1 bitcoin in dollars
  • 5 bitcoins in ethereum
  • 1 ethereum to ¥
  • 10 ethereum in mxn
  • 1eth btc
  • 1btc (If no target the currency will be converted to the base currency that you configured)

 

crypto-v3.gif

 

Cryptocurrency Modifiers

When a result is displayed you can use action modifiers to copy the value in different formats:

 

  • Return - Press Return to copy the value with format, for example 2,376.54
  • Command + Return - Press Command + Return to copy the value without formatting, for example 2376.54
  • Option + Return - Press Option + Return to copy the value of a single unit, for example 23.76

 

Cryptocurrency API Key

You need to get a FREE API Key from https://coinmarketcap.com/api/pricing/ it takes less than a minute. Then simply add the API Key in the workflow configuration window.

 

Units

 

You can write your query using natural language or just a few characters. Either way works!

 

  • 100 kilometers to meters
  • 100 km in meters
  • 100 km m
  • 100km m
  • 100 miles as meters
  • 100miles in meters
  • 100 miles to m
  • 100 ounces to kilograms
  • 100oz to kg
  • 100oz = kg
  • 100oz kg
  • 10 years to months
  • 10years to seconds
  • 1 year to sec
  • 1hr s
  • 10 días a horas (use your own language)

 

If you don't remember the unit abbreviation just simply type the name for example instead of "oz" you can type "ounce" or "ounces" or even use words in your own language for exaple "onza" or "onzas" in spanish.

 

units-v3.gif

 

Please go to the repo description on Github for a full list of units it's really difficult to write them here in the forum. View Units

 

Units Modifiers

When a result is displayed you can use action modifiers to copy the value in different formats:

 

  • Return - Press Return to copy the value with format, for example 2,376.54
  • Command + Return - Press Command + Return to copy the value without formatting, for example 2376.54
  • Option + Return - Press Option + Return to copy the value of a single unit, for example 23.76

 

 

Data Storage

You can write your query using natural language or just a few characters. Either way works!

 

  • 100 gigabytes in megabytes
  • 100 gigas in megas
  • 100 Mebibytes in Kibibytes
  • 100 gb to mb
  • 100gb to kb
  • 100gb mb
  • 400MiB in kib
  • 2tb gb
  • 1b kb

 

datastorage-v3.gif

Please note, this workflow follows the IEC Standard (International Electrotechnical Commission) as it had been adopted by the IEEE, EU, and NIST. That means that if you type `1MB in KB` you will get `1000 KB` but if you type `1MiB in KiB` you will get `1024 KB`, you can read more about it here https://en.wikipedia.org/wiki/Byte#Multiple-byte_units

 

Do you prefer 1 MB = 1024 KB? No problem, you can configure it in the Workflow configuration window.

 

Data Storage Modifiers

When a result is displayed you can use action modifiers to copy the value in different formats:

 

  • Return - Press Return to copy the value with format, for example 2,376.54
  • Command + Return - Press Command + Return to copy the value without formatting, for example 2376.54

 

Percentages

 

You can easily calculate percentages for example:

 

  • 15% of 50 = 7.50  //7.5 equals to 15% of 50
  • 120 + 30% = 156  //120 plus the 30% of 120
  • 120 plus 30% = 156  //120 plus the 30% of 120
  • 120 - 30% = 84  //120 minus the 30% of 120
  • 120 minus 30% = 84  //120 minus the 30% of 120
  • 30 % 40 = 75%  // 30 is 75% of 40.

 

Translations and natural language can also be used

  • 120 más 30% = 156

 

percentages-v3.gif

PX, EM, REM, PT

Open Alfred, type `12px` and you'll see the value converted to em, rem and pt. It's that simple. Check the examples below.

 

  • 12px
  • 12px to em
  • 2 rem
  • 2rem
  • 2rem to pt
  • 12px in em base 17px (use a custom px base or configure it in the workflow)

 

 

Time

 

Given its less frequently used, time conversions require the use of the keyword time

 

Gives you the current time

  • time

 

Converts the timestamp to a regular date

  • time 1577836800

 

Gives you the time from now plus anything you want

  • time +15 days
  • time now plus 3 days

 

Number of days until specified date

  • time days until 31 december

 

The start date of current year

  • time start of year

 

The start date of specified year

  • time start of 2021

 

The end date of current year

  • time end of year

 

The end date of specified year

  • time end of 2021

 

It also works in your language

  • time inicio de 2020
  • time fin de 2020
  • time dias hasta 31 diciembre

 

Get information about date

  • time 31 December, 2021 18:00:00
  • time 31/12/2021 18:00:00
  • time 12/31/2021 18:00:00

 

Calculate the difference between two dates

  • time 25 December, 2021 - 31 December, 2021
  • time 31-11-2019 - 21-11-2019
  • time 11/31/2019 - 11/21/2019

 

time-v3.gif

 

VAT (value added tax)

 

With this you can calculate the VAT for a given amount. Like time, VAT is also triggered with a keyword. By default, the keyword is "vat" but you can change the keyword in the workflow.

 

Given the following query

vat of 400 (with a 16% VAT configured, a percentage you can configure)

 

Calculate Anything will provide the following conversions:

 

  • VAT of 400 = 64 (the VAT amount)
  • 400 plus VAT = 464 (the Amount plus VAT)
  • 400 minus VAT = 344.82 (the Amount minus VAT, useful if you have a final amount and want to know the VAT applied)

 

 

Cache

 

The workflow stores some data about currency in the workflow data folder. You can delete the cache by opening Alfred and typing `_caclear`.

Edited by biati
Updated for Alfred 5 as the configuration has changed
Link to comment

This looks fantastic, and hijacking the numbers is a clever hack (though not sure how I feel about that, I might replace those with a single Script Filter with a proper keyword).


I’ve found some bugs.


You’re not creating alfred_workflow_data. You need to, as Alfred doesn’t do it for you. Without it, users will get an error.

 

I was expecting natural language processing to understand in, as in 100km in m or 100usd in eur.


On the currency converter:

  • Two decimal places isn’t enough precision for correct calculations. 1JPY = 0.00EUR isn’t too useful, even if approximately true (it’s 0.0083), but the real issue is that same rounding is used for the random calculations, which means the Workflow claims 10000000jpy is 0.00eur, which is 83060eur off the mark.
  • calculate set currency changes the flag icon and does the correct calculations, but it doesn’t change the currency symbol (it always shows as $).
  • Setting the currency to eur and searching for any value in eur (e.g. 100eur)  causes an error: Symbols 'EUR' are invalid for date 2019-11-13. I tried other currencies and couldn’t reproduce the bug.


Good work otherwise, I’m interested in using the fixed Workflow.


How often does it fetch currency data?

Link to comment
2 hours ago, vitor said:

This looks fantastic, and hijacking the numbers is a clever hack (though not sure how I feel about that, I might replace those with a single Script Filter with a proper keyword).


I’ve found some bugs.


You’re not creating alfred_workflow_data. You need to, as Alfred doesn’t do it for you. Without it, users will get an error.

 

I was expecting natural language processing to understand in, as in 100km in m or 100usd in eur.


On the currency converter:

  • Two decimal places isn’t enough precision for correct calculations. 1JPY = 0.00EUR isn’t too useful, even if approximately true (it’s 0.0083), but the real issue is that same rounding is used for the random calculations, which means the Workflow claims 10000000jpy is 0.00eur, which is 83060eur off the mark.
  • calculate set currency changes the flag icon and does the correct calculations, but it doesn’t change the currency symbol (it always shows as $).
  • Setting the currency to eur and searching for any value in eur (e.g. 100eur)  causes an error: Symbols 'EUR' are invalid for date 2019-11-13. I tried other currencies and couldn’t reproduce the bug.

 


Good work otherwise, I’m interested in using the fixed Workflow.


How often does it fetch currency data?

 

Hi vitor, thank you for your input.

 

I'm searching information about alfred_workflow_data but not sure exactly what you mean, are you referring to the folder stored in ~/Library/Application Support/Alfred/Workflow Data/com.alfred.calculateanything ? if so I've added some validation to make sure it exists and if not then it's created. If this is not what you mean please let me know.

 

1.- I've adde "in" to the stop words list so now 100km in m works as expected as any other query like 100 usd in eur.

2.- You are right about the decimals, I'm working on that.

3.- Already fixed the calculate set currency symbol

4.- mmm making some tests on this.

 

Once fetched, the currency is cached for 6 hours and the data is from fixer.io, this is the first time I work with currencies so not sure if 6 hours is a correct amount of time. The data will be fetched again only if a currency conversion is triggered.

Link to comment

Adding a Script Filter for each digit is a brilliant idea. So simple, so good. I am totally going to steal that 😛

 

Don't zip the exported .alfredworkflow file before uploading it to GitHub releases. .alfredworkflow files are zip files, just with a different extension. So there's no benefit in zipping them again.

 

3 hours ago, biati said:

Once fetched, the currency is cached for 6 hours and the data is from fixer.io

 

The exchange rates aren't from fixer.io: its API absolutely requires an API key. The rates are actually coming from exchangeratesapi.io, which doesn't require an API key. But it's also basically this list of 32 currencies converted to JSON, and the rates are only updated every 24 hours.

 

So unfortunately, most of the listed currencies aren't actually supported :(

 

image.thumb.png.6ed8ccd5072b001d9e6846de0834611a.png

 

Link to comment
8 hours ago, deanishe said:

The exchange rates aren't from fixer.io: its API absolutely requires an API key. The rates are actually coming from exchangeratesapi.io, which doesn't require an API key. But it's also basically this list of 32 currencies converted to JSON, and the rates are only updated every 24 hours.

 

@biati Thank you for the fast fixes.

 

I don’t need more than the currencies already available or an update window shorter than 24h, but if you want to support everything you envisioned, my recommendation is to add an optional field for a fixer.io API. If the user adds the API key (i.e. they need that kind of information), you use it; if not (i.e. more modest needs), you use what’s already in place.

 

By the way, I forgot to say so on the first post, but welcome to the forums.

Link to comment

Hi @deanishe I'm glad you liked the idea of using each digit as a script filter 😊 I won't zip the exported files anymore.

 

@vitor @deanishe

 

About the currencies, sorry for the confusion, I've added support for fixer.io also the previous functionality still exists so there's no need to create an API Key for fixer but in case you want to use fixer you can configure the API key with calculate set fixerapi yourapihere 

 

Also I've incremented the cache from 6 hours to 24 hours.

 

Not sure if I can edit my original post to update the information but you can find the updated readme on Github

Link to comment

You're bloody fast with the updates!

 

1 hour ago, biati said:

Also I've incremented the cache from 6 hours to 24 hours.

 

I'd leave that at 6, tbh, or even 1 or 2 if a fixer.io API key is set. If the workflow pulls the exchange rates just before the site updates them, users may end up using rates that are up to 48 hours old. Your worse case scenario is basically (update interval * 2) - 1 second, so you should try to minimise that.

Link to comment
1 hour ago, deanishe said:

You're bloody fast with the updates!

 

 

I'd leave that at 6, tbh, or even 1 or 2 if a fixer.io API key is set. If the workflow pulls the exchange rates just before the site updates them, users may end up using rates that are up to 48 hours old. Your worse case scenario is basically (update interval * 2) - 1 second, so you should try to minimise that.

 

Hi @deanishe You are right, 24 hours is a lot, I've followed your recommendation and changed the update interval to 2 hours for fixer.io and 12 hours for exchangerates api. The updated workflow can be downloaded from Github 

 

Thank you for giving a try to this workflow.

Link to comment
7 minutes ago, Thomas Dunne said:

Really interesting and useful.

 

But I've noticed some cooking and everyday small life US-American units aren't supported:

 

For example, teaspoons, tablespoons, cups... and fractions: 1/8 inch, 1/16 tablespoon

 

It'd be nice to have those.

 

Hi @Thomas Dunne you are right, as a non us citizen I forgot to add those units, I'll be updating the workflow with this and if I find some other useful units I'll add them.

Link to comment
15 hours ago, Thomas Dunne said:

everyday small life US-American units (…) teaspoons, tablespoons, cups

 

Culinary units are used outside of the USA, and have precise metric measurements.

 

@biati How are you handling auto-updates? Does the Workflow support them? If not, I can help you set it up with OneUpdater (disclaimer: I’m the author).


I found some references to Packal inside the Workflow. Did you upload this to Packal, download it again, and made updates on that version? Either way, using Packal is no longer recommended, as the website is abandoned and buggy. The official place to share Workflows is the forums.

Link to comment
On 11/15/2019 at 11:16 AM, vitor said:

 

Culinary units are used outside of the USA, and have precise metric measurements.

 

@biati How are you handling auto-updates? Does the Workflow support them? If not, I can help you set it up with OneUpdater (disclaimer: I’m the author).


I found some references to Packal inside the Workflow. Did you upload this to Packal, download it again, and made updates on that version? Either way, using Packal is no longer recommended, as the website is abandoned and buggy. The official place to share Workflows is the forums.

 

Hi @vitor I've added OneUpdater, did some tests and it seems to work without problems, it's now available in version 1.0.5 with some changes and bug fixes and a new way to configure the workflow. Thank you for OneUpdater it is really simple to use.

 

Link to comment
9 hours ago, NathanMcKnight said:

Great workflow! I just started playing around with it, and noticed a small bug. When subtracting percentages, it seems to have trouble subtracting round number percentages.

 

For example:

100 - 3% = 70

100 - 30% = 70

100 - 300% = 70

 

Keep up the good work! I can't wait to see how far along you get!

-N

 

Hi @NathanMcKnight thank you for trying the workflow, the error you mention has been fixed in version 1.0.5 please download the latest version from Github  also automatic updates have been added so this is the last time you have to manually download an update. Thank you for your nice words.

Link to comment
On 11/17/2019 at 1:24 AM, biati said:

 

Hi @NathanMcKnight thank you for trying the workflow, the error you mention has been fixed in version 1.0.5 please download the latest version from Github  also automatic updates have been added so this is the last time you have to manually download an update. Thank you for your nice words.

 

Thanks for your prompt response! The new version looks good.

 

I found a couple of other things in the way it calculates area, volume, and small scale calculations that you might be interested in taking a look at...

 

Cheers,

Nathan

 

 

Screen Shot 2019-11-20 at 11.05AM EST 1.png

 

Screen Shot 2019-11-20 at 11.05AM EST.png

 

Screen Shot 2019-11-20 at 11.03AM EST 1.png

 

Screen Shot 2019-11-20 at 11.03AM EST.png

 

Screen Shot 2019-11-20 at 11.02AM EST.png

 

Screen Shot 2019-11-20 at 11.01AM EST 2.png

 

Screen Shot 2019-11-20 at 11.01AM EST 1.png

 

Screen Shot 2019-11-20 at 11.01AM EST.png

Edited by NathanMcKnight
Link to comment

This workflow is awesome!  However, I'm not able to use decimals in currency conversion, neither with point (.) nor with comma (,). Does it only support integers, or have I missed a setting somewhere? it works with unit conversions.

Also, a feature request: Calculation of workdays that exclude weekends, e.g. today + X workdays.

Would be perfect for quickly calculating delivery dates. 

Link to comment
On 11/20/2019 at 11:06 AM, Peter U said:

This workflow is awesome!  However, I'm not able to use decimals in currency conversion, neither with point (.) nor with comma (,). Does it only support integers, or have I missed a setting somewhere? it works with unit conversions.

Also, a feature request: Calculation of workdays that exclude weekends, e.g. today + X workdays.

Would be perfect for quickly calculating delivery dates. 

 

Hi, I'm glad you like this workflow, about decimals and commas in currency I've fixed the error, I'll publish the update tomorrow.

 

About the workdays calculations I like that idea, it has been implemented, please check for updates tomorrow just open Alfred and type calculate and select check for updates.

 

Link to comment
On 11/20/2019 at 10:09 AM, NathanMcKnight said:

 

Thanks for your prompt response! The new version looks good.

 

I found a couple of other things in the way it calculates area, volume, and small scale calculations that you might be interested in taking a look at...

 

Cheers,

Nathan

 

 

Hi @NathanMcKnight I've updated the workflow to fix the problems you mention, please note there are some conversions that are not yet supported for example:

 

1 m3 to m
1 ft2 to in
144 in to ft2

 

The rest should be working fine, I'll be adding more units as soon as I have some free time. 

 

To install the update just open Alfred and type calculate and select check for updates.

Link to comment
On 11/21/2019 at 9:48 PM, biati said:

 

Hi, I'm glad you like this workflow, about decimals and commas in currency I've fixed the error, I'll publish the update tomorrow.

 

About the workdays calculations I like that idea, it has been implemented, please check for updates tomorrow just open Alfred and type calculate and select check for updates.

 

Oh, that's just fantastic, thank you so much! Especially the workdays feature will speed things up enormously for me.

 

Would you be interested in a translation to Swedish?

 

Edited by Peter U
Link to comment
1 hour ago, xilopaint said:

I'm struggling to configure my currency and date formats. Is there a list anywhere that could help me with that?

 

The workflow includes a list of currencies, just Open Alfred and type calculate select "list available units and currencies" then you can type your country name to get the currency code (press enter to copy the currency code) or if you prefer here is a list online https://www.iban.com/currency-codes

 

For dates, you can find here the available options to format the date the way you want. If you do not understand what you have to do in that page then go to this other page you can visually create the date in the format you want. In the section "Build your own" you can  for example select how you want to display the day (24 or Sun or Sunday, etc) do the same with the rest of options and at the top you'll see the generated code for example: date('F l Y'); the part you need is inside the quotes so just copy F l Y if you need more help just let me know.

Link to comment
5 hours ago, biati said:

 

The workflow includes a list of currencies, just Open Alfred and type calculate select "list available units and currencies" then you can type your country name to get the currency code (press enter to copy the currency code) or if you prefer here is a list online https://www.iban.com/currency-codes

 

For dates, you can find here the available options to format the date the way you want. If you do not understand what you have to do in that page then go to this other page you can visually create the date in the format you want. In the section "Build your own" you can  for example select how you want to display the day (24 or Sun or Sunday, etc) do the same with the rest of options and at the top you'll see the generated code for example: date('F l Y'); the part you need is inside the quotes so just copy F l Y if you need more help just let me know.

 

I know my currency code but if I enter it via `Set base currency` and `Set currency locale` I don't get my currency properly formatted.

 

5 hours ago, biati said:

For dates, you can find here the available options to format the date the way you want. If you do not understand what you have to do in that page then go to this other page you can visually create the date in the format you want. In the section "Build your own" you can  for example select how you want to display the day (24 or Sun or Sunday, etc) do the same with the rest of options and at the top you'll see the generated code for example: date('F l Y'); the part you need is inside the quotes so just copy F l Y if you need more help just let me know.

 

It seems your workflow is not accepting capital letters, so "Y" is being converted to "y" which gives different results for a date format.

Link to comment
15 hours ago, xilopaint said:

 

I know my currency code but if I enter it via `Set base currency` and `Set currency locale` I don't get my currency properly formatted.

 

 

It seems your workflow is not accepting capital letters, so "Y" is being converted to "y" which gives different results for a date format.

 

I've published a fix for the configuration error, the settings are now saved keeping upper and lowercase.

 

For the other thing you mention please first try the update otherwise you need to be more specific, what's your currency, your locale, give me an example of the output you are expecting, etc. something that helps me to make some tests otherwise there's nothing I can do.

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...