wolph Posted December 7, 2014 Share Posted December 7, 2014 (edited) Alfred unit converter is a really fast smart calculator for Alfred with support for unit conversions to make it a bit comparable to the Google Calculator and Wolfram Alpha. If new units and/or other names for units should be added please let me know by creating an issue at:https://github.com/WoLpH/alfred-converter/issues Example queries Downloadable from Packal: http://www.packal.org/workflow/unit-converter 1m in cm # Just a simple conversion 2^30 byte # Using powers before conversion 5' # Converting units with special characters 20" # Like above 5 * cos(pi + 2) # Executing mathematical functions 5 * pi + 2 mm in m # Mathematical constants with unit conversion 1 * cos(pi/2) - sin(pi^2) # More advanced mathematical expressions ln(e^10) # Testing the ln(x) alias of log _e(x) log(e^10) # The normal log method 5+3^2" in mm # Testing math with unit conversion 1 + 2 / 3 * 4) mm^2 in cm^2 # Unbalanced paranthesis with unit conversion ((1 + 2 / 3 * 4) mm^2 in cm^2 # Unbalanced paranthesis the other way inf - inf # Not actually possible, but we backtrack to "inf" The list of units and conversions was downloaded from:http://w3.energistics.org/uom/poscUnits22.xml It returns results within 50 milliseconds making it fast enough to use the results instead of the standard alfred calculator. It supports more too Note: the parser automatically works when you start with a number or a ".". For all other cases (functions for example) it's best to just use "=". For example: "=ln(e^5)" Edited December 19, 2014 by wolph mixterdee and DevMan 2 Link to comment
Florian Posted December 7, 2014 Share Posted December 7, 2014 Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster). I really like the multiple ways to input (0 to 9, =, .) but then it lacks full blown calculator function (ln, tan, e, cos... then don't seem to work, and they can't be the first thing in because they don't start a query). Also the precision is weird 4^.5 outputs 2.0000000000000000000000000000 Link to comment
DevMan Posted December 8, 2014 Share Posted December 8, 2014 Really nice. Thanks for sharing. Link to comment
dfay Posted December 8, 2014 Share Posted December 8, 2014 @Florian you never know when you will need to convert square meters to miles with 19 digits of accuracy. Link to comment
wolph Posted December 8, 2014 Author Share Posted December 8, 2014 (edited) The output can be improved indeed, for me it's a bit more convenient since it just converts it to any alternative measurement instead of just from a single one to another. Not really sure what the best solution for the output should be, right now all calculations are done with a precision of 28 places which is the default for the Decimal library. I could easily increase or decrease it upon demand. Perhaps I'll even make it configurable. I'll see if I can make the output slightly less messy by rounding things like 4^.5 As for functions, there's actually a workaround for mathematical functions, try this for example: "=sin(pi/2)-cos(2pi)" Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster). I really like the multiple ways to input (0 to 9, =, .) but then it lacks full blown calculator function (ln, tan, e, cos... then don't seem to work, and they can't be the first thing in because they don't start a query). Also the precision is weird 4^.5 outputs 2.0000000000000000000000000000 Edited March 14, 2015 by wolph Link to comment
wolph Posted December 8, 2014 Author Share Posted December 8, 2014 @Florian you never know when you will need to convert square meters to miles with 19 digits of accuracy. Yeah... it's nice to have accuracy but sometimes it's a bit much Right now it rounds to 6 decimal places so things like 4^.5 work without a problem but it doesn't lose precision for calculations like: (25/4)^.5 dfay 1 Link to comment
wolph Posted December 8, 2014 Author Share Posted December 8, 2014 Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster). Can't say I saw the units library before I started writing this, that's indeed a lot better. I was previously trying to use the units library from Jason Cheatham which never worked the way I liked. The one thing I don't like about the units library is that it requires an internet connection, otherwise it just fails. By doing everything locally it always (on my system at least) return within 50ms making it fast enough for instant results. Either way, I think I've fixed all issues (although it's not as pretty as the units library). Perhaps I can merge some things with the units library, can't find any license information though. Link to comment
wolph Posted December 18, 2014 Author Share Posted December 18, 2014 Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster). I really like the multiple ways to input (0 to 9, =, .) but then it lacks full blown calculator function (ln, tan, e, cos... then don't seem to work, and they can't be the first thing in because they don't start a query). Also the precision is weird 4^.5 outputs 2.0000000000000000000000000000 If you're willing to try again. I've included some icons in the output to make everything a bit clearer. Perhaps that helps Link to comment
wolph Posted December 18, 2014 Author Share Posted December 18, 2014 Added support for binary, octal and hexadecimal numbers Link to comment
roccitman Posted March 12, 2015 Share Posted March 12, 2015 Loving this workflow! In my daily work I add a lot of prices, sometimes 10+ numbers together. I see that if you leave a space between numbers it will multiply them together (wouldn't let me embed image) http://r.roccit.com/1539j Is it possible to edit the script somewhere to make the default operation in this case be addition? Here's to saving my pinky finger -roccit Link to comment
wolph Posted March 12, 2015 Author Share Posted March 12, 2015 Right now it's just using the mathematical method of calculating (which means that `(5)(6)` will default to multiplying). And as a side-effect, spaces also multiply I guess To change this to addition instead of multiplying you just need to replace the * with a + over here: https://github.com/WoLpH/alfred-converter/blob/master/converter/safe_math.py#L25 Link to comment
roccitman Posted March 13, 2015 Share Posted March 13, 2015 Thanks for the reply. Not sure I want to sacrifice that default behavior, but now I play with it Works http://r.roccit.com/12aIB Link to comment
roccitman Posted March 14, 2015 Share Posted March 14, 2015 Just noticed that when I press return after an operation the answer is not being copied to the clipboard. Deleted and re-loaded the WF and it's still not working. Something else I need to turn on? Link to comment
wolph Posted March 14, 2015 Author Share Posted March 14, 2015 That's weird... it works just fine for me, can you try with this release (I've just uploaded it): https://github.com/WoLpH/alfred-converter/raw/master/unit_converter.alfredworkflow Link to comment
roccitman Posted March 14, 2015 Share Posted March 14, 2015 Odd. Works fine now. Thanks! Link to comment
simongade Posted December 16, 2015 Share Posted December 16, 2015 I need to convert height in feet/inches to cm/meters. Can't figure out how to do that. I'd like to type e.g. 6'1 or 6'1" but doesn't seem to work. Anyone smarter than me? Link to comment
wolph Posted December 16, 2015 Author Share Posted December 16, 2015 That's currently not directly supported, but it's easy to work around it. Just type "6' in inch" followed by a tab, it will give you the size in inches straight away. After that you can simply add them I've added it to the todo: https://github.com/WoLpH/alfred-converter/issues/5 Link to comment
frankvs Posted November 16, 2016 Share Posted November 16, 2016 On 12/16/2015 at 4:54 AM, simongade said: I need to convert height in feet/inches to cm/meters. Can't figure out how to do that. I'd like to type e.g. 6'1 or 6'1" but doesn't seem to work. Anyone smarter than me? You can do that with this workflow with the simple query "units 5'7" cm" Link to comment
blacksnow Posted February 12, 2020 Share Posted February 12, 2020 Hello, Really amazing workflow! Just one question how to count percentages? I want to count these functions, examples: Calculate a percentage of a number: 15% of 80 Calculate a percentage of a quantity: 7.5% of $12.95 Increase a quantity by a percentage: $2400 + 15% Compute a discounted price: 15% off of $29.95 Link to comment
deanishe Posted February 12, 2020 Share Posted February 12, 2020 1 hour ago, blacksnow said: Just one question how to count percentages? @Tyler Eich wrote a workflow just for that here: But generally you use multiplication and decimal fractions instead: 15% of 80 is 80 * .15 7.5% of 12.95 is 12.95 * .075 2400 + 15% is 2400 * 1.15 15% off 29.95 is 29.95 * .85 Link to comment
wolph Posted February 12, 2020 Author Share Posted February 12, 2020 Percentages were already somewhat supported but not in the way you're currently using them. Currently they're only part of ratios (i.e. parts per million) I've created a new version that supports pretty much all of this but it ignores the $ sign since there's no currency support yet. deanishe 1 Link to comment
blacksnow Posted February 12, 2020 Share Posted February 12, 2020 15 minutes ago, wolph said: Percentages were already somewhat supported but not in the way you're currently using them. Currently they're only part of ratios (i.e. parts per million) I've created a new version that supports pretty much all of this but it ignores the $ sign since there's no currency support yet. Wow that was as quick as could possible be. Works perfectly just tested! Thank you so much. And I am sorry for not telling this at the beginning but few more percentage features would be nice: Examples: 15 is what percent of 130? What is the percentage increase/decrease? From 98 to 60 Link to comment
wolph Posted February 12, 2020 Author Share Posted February 12, 2020 I've implemented a version of it but I have to be careful not to break anything else. The syntax is "... to/from/diff/difference/change ..." and "... percentage of ..." Link to comment
blacksnow Posted February 13, 2020 Share Posted February 13, 2020 Once again works like a charm. Thanks so much! Link to comment
hansdaniel Posted May 28, 2021 Share Posted May 28, 2021 Very nice app, sometimes it's hard to convert inches to a meter in your head Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now