Project

wolf

0.0
No commit activity in last 3 years
No release in over 3 years
Devour computational knowledge on the commandline with wolframalpha.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.3.6
>= 0.1.1
 Project Readme

Description¶ ↑

Devour computational knowledge on the commandline with wolframalpha.

Install¶ ↑

To install this gem:

gem install wolf

Setup¶ ↑

Get a free Wolfram Appid (api key) by creating an account here and then clicking on the ‘Get an APPID’ button.

Once you have your own appid, set it in your shell, preferably in your ~/.zshrc or ~/.bashrc:

export WOLFRAM_APPID='YOURKEY'

Or you can set your appid in your ~/.wolfrc:

Wolfram.appid = "YOURKEY"

Usage¶ ↑

wolf displays results to wolfram queries as tables:

# Calculate distance and travel time between places
$ wolf boston to new york
Distance
+-------------+
| 184.3 miles |
+-------------+

Direct travel times
+---------------------+-------------------------+
| aircraft  (550 mph) | 20 minutes              |
| sound               | 14 minutes  30 seconds  |
| light in fiber      | 1.39 ms  (milliseconds) |
| light in vacuum     | 0.99 ms  (milliseconds) |
+---------------------+-------------------------+
...

# Solve an equation
ru wolf 'x^3 - sinx = e^-x'
+--------------------+---------------------------+
| Input              | x^3-sin(x) = e^(-x)       |
| Numerical solution | x ~~ 1.068531813164789... |
+--------------------+---------------------------+

# Compare stocks
$ wolf goog, apple, microsoft
Latest trades
+------+---------------+--------+----------------+--------------------+
| GOOG | $600.30 (GOOG | NASDAQ | 4:02:42 pm EST | 5 hrs 41 mins ago) |
| AAPL | $339.30 (AAPL | NASDAQ | 4:21:45 pm EST | 5 hrs 22 mins ago) |
| MSFT | $27.73 (MSFT  | NASDAQ | 4:00:00 pm EST | 5 hrs 43 mins ago) |
+------+---------------+--------+----------------+--------------------+

Fundamentals and financials
+--------------------------+----------------+----------------+----------------+
|                          | Google         | Apple          | Microsoft      |
+--------------------------+----------------+----------------+----------------+
| market cap               | $192 billion   | $312.6 billion | $233 billion   |
| revenue                  | $27.55 billion | $76.28 billion | $66.69 billion |
| employees                | 23331          | 49400          | 89000          |
...

# Display local weather info
$ wolf weather
Latest recorded weather for boston, massachusetts
+-------------------+----------------------------+
| temperature       | 34 °F  (wind chill: 25 °F) |
| conditions        | cloudy                     |
| relative humidity | 47%  (dew point: 16 °F)    |
| wind speed        | 12 mph                     |
+-------------------+----------------------------+
...

In some cases wolf displays information more concisely than the website itself. Compare the website to:

$ wolf pi
+-----------------------------+---------------------------------------------------------------------------------------+
| Input                       | pi                                                                                    |
| Decimal approximation       | 3.1415926535897932384626433832795028841971693993751058209749...                       |
| Property                    | pi is a transcendental number                                                         |
| Continued fraction          | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, ...] |
| Alternative representations | pi = 180 °                                                                            |
| Series representations      | pi = 4 sum_(k=0)^infinity(-1)^k/(2 k+1)                                               |
| Integral representations    | pi = 2 integral_0^infinity1/(t^2+1) dt                                                |
+-----------------------------+---------------------------------------------------------------------------------------+

If you clicked on the previous link, you’ll notice links to more information about the current result. wolf makes this available via the menu option (-m):

$ wolf pi -m

+-----------------------------+---------------------------------------------------------------------------------------+
| Input                       | pi                                                                                    |
| Decimal approximation       | 3.1415926535897932384626433832795028841971693993751058209749...                       |
| Property                    | pi is a transcendental number                                                         |
| Continued fraction          | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, ...] |
| Alternative representations | pi = 180 °                                                                            |
| Series representations      | pi = 4 sum_(k=0)^infinity(-1)^k/(2 k+1)                                               |
| Integral representations    | pi = 2 integral_0^infinity1/(t^2+1) dt                                                |
+-----------------------------+---------------------------------------------------------------------------------------+

** LINKS **
+--------+-----------------------------+---------------+
| number | Section                     | Choice        |
+--------+-----------------------------+---------------+
| 1      | Decimal approximation       | More digits   |
| 2      | Continued fraction          | Fraction form |
| 3      | Continued fraction          | More terms    |
| 4      | Alternative representations | More          |
| 5      | Series representations      | More          |
| 6      | Integral representations    | More          |
+--------+-----------------------------+---------------+
Choose one link to requery: 

# User types '1'
Choose one link to requery: 1

# To get back
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------+
| Input                       | pi                                                                                                                      |
| Decimal approximation       | 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282... |
| Property                    | pi is a transcendental number                                                                                           |
| Continued fraction          | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, ...]                                   |
| Alternative representations | pi = 180 °                                                                                                              |
| Series representations      | pi = 4 sum_(k=0)^infinity(-1)^k/(2 k+1)                                                                                 |
| Integral representations    | pi = 2 integral_0^infinity1/(t^2+1) dt                                                                                  |
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------+

wolf has more options you can explore with:

$ wolf -h

Some examples of options:

# Only display tables whose titles match the case insensitive regex
$ wolf .me -t=name
Name
+------------------+------------------------+
| full name        | Republic of Montenegro |
| full native name | Republika Crna Gora    |
| internet code    | .me                    |
+------------------+------------------------+

# Print a query's xml response
$ wolf -x 4th monday in march
<queryresult success="true" error="false" numpods="9" datatypes="CalendarEvent,City" timedout=""
timing="1.985" parsetiming="0.559" parsetimedout="false" recalculate="" version="2.0">
...

# Load local xml file(s) to read in console
$ wolf -l fourth_monday.xml
Result
+------------------------+
| Monday, March 28, 2011 |
+------------------------+
...

# Append additional params to a query with --PARAM=VALUE
# Read API docs for available query params
$ wolf --format=html 50 euros
<queryresult success="true" error="false" numpods="4" datatypes="Quantity" timedout=""
timing="2.566" parsetiming="0.115" parsetimedout="false" recalculate="" version="2.0">
 <pod title="Input interpretation" scanner="Identity" id="Input" position="100" error="false"
 numsubpods="0">
   <markup>
   ...

Todo¶ ↑

  • Tests!

  • Better aliasing of commands

  • option to tab delimit results for easy nix slicing + dicing