Giter Site home page Giter Site logo

kirillosenkov / quickinfo Goto Github PK

View Code? Open in Web Editor NEW
172.0 12.0 28.0 2.05 MB

http://quickinfo.io - a search textbox with extensible "answers" (calculator, unit-converter, colors, ascii/unicode, etc). See demo at http://quickinfo.io/?demo

License: MIT License

C# 99.43% HTML 0.08% JavaScript 0.32% CSS 0.18%

quickinfo's Introduction

Extensible set of little one-off features that Google or Bing are missing, such as color and unit conversions, etc.

NuGet package

screenshot

Demo: http://quickinfo.io/?demo

Motivation

There is a class of search engine queries that search engines aren't great at without dedicated support. These queries have exactly one well-defined answer that is computable or readily available. Search engines by default just show a list of (often poor quality and full of ads) websites instead of showing the answer directly as you type.

Search engines are getting better at it by implementing dedicated "answer" UI, without the need to visit any websites. Examples are calculator, unit conversions, currency exchange rates, stock tickers, etc. But sometimes they still fail, for instance as of October 2015 search engines don't return satisfactory results for RGB(23,175,195). If you have to visit a site for an answer like this, the search engines have failed here.

Quickinfo.io attempts to fill the gap when the search engine doesn't provide an "answer", or their answer is not satisfactory. One should note that http://duckduckgo.com is known for its great extensive collection of answers. http://wolframalpha.com is another example of an "answer" website, which gives great answers, but it also doesn't cover many scenarios, and is also too slow to be useful as a quick one-off lookup tool (doesn't provide results in real-time as you type). I like the vision of Wolfram Alpha, but it is still not extensible by me (I can't plug my own one-off solutions). I want a platform where I can easily add new answers myself using a very simple C# extensibility API. http://duckduckgo.com's answers collection is impressive, but there is no easy extensibility in C#.

All the answers on http://quickinfo.io are instant as-you-type results, no need for the search button.

Currently supported answers

  1. Unit conversions:
    1. Weight: pounds to kg and vice versa (190 pounds, 200lb, 43 kg in lb)
    2. Temperature: fahrenheit/celsius (75f, 75 f, 75 fahrenheit, 23c, 23 c, 23 c to f)
    3. Distance: 12 miles, 100 miles in km
    4. Speed
    5. Volume
    6. Area: 1670 sq.ft
    7. Fuel efficiency (29mpg)
  2. Hex/decimal (just type a number)
  3. Ascii table ascii
  4. List of colors: color, colors
  5. Color conversions - convert an RGB triplet to Hex color or hex color to RGB (23 145 175, #eeaaf0)
  6. Factor an integer 2520
  7. Generate a random Guid guid
  8. My IP address ip
  9. Math/arithmetic expressions (24 * 365) * 4 - 1, 22/7 - pi, rnd, Random(100)
  10. Quick sum/average/product of a list of numbers, sort a list (separated by space or comma) 3 7 21 3 3 2 11
  11. Unicode: type a codepoint to see what char it is: U+2021 \u3333
  12. Url decode: 2%20%2B%203 shows the original string (fun exercise: 2%2525252520%252525252B%25252525205)

Type ? for help.

Historical information

It all started when I caught myself using the Windows Calc to convert a hex color to RGB. I thought to myself: this is ridiculous, I'm sitting in front of a supercomputer and punching buttons one by one instead of getting an immediate answer as I type it in.

I kept catching myself, how do I generate a random Guid from command line? Which is a good unit-converter app without ads? What is 130000 * (96 - 36) / 192? I've realized that there are apps and websites to answer all these, but it will take me longer to find a good app than to calculate the answer myself.

So I got into the mindset of "does this question have a single, well defined, computable answer"? "Can I type the question into a simple search box and expect a computer to give an immediate result?" Turns out, this class of questions is more expansive than one might think. I'm thinking of adding ToString() syntax for DateTime, string.Format cheat sheet, some man pages that I often look up, basically make carefully curated information easily accessible from a simple search box. I think it'll be beneficial to centralize all these little lookup utilities and make it so I can customize and extend it to fit my needs.

API and architecture

The core library of answers is in QuickInfo.dll, available as a NuGet package here: https://nuget.org/packages/GuiLabs.QuickInfo. There are multiple front-ends such as QuickInfoWeb (that powers http://quickinfo.io) and Info.exe (console app). Here's how the console app instantiates the engine and gets the answers for the search string:

var engine = new Engine
(
typeof(Ascii),
typeof(Color),
typeof(QuickInfo.DateTime),
typeof(Emoticons),
typeof(Factor),
typeof(Hex),
typeof(HttpStatusCode),
typeof(QuickInfo.Math),
typeof(NumberList),
typeof(RandomGuid),
typeof(UnitConverter),
typeof(UrlDecode)
);
var query = new Query(commandLine);
var answers = engine.GetResults(query);
foreach (var answer in answers)
{
ConsoleRenderer.RenderObject(answer.processorName, answer.resultNode);
}

The result objects returned from the API are an abstract object model: https://github.com/KirillOsenkov/QuickInfo/blob/master/src/QuickInfo/Dom/Node.cs

Basically Node has a set of attributes (name/value pairs) and an optional List of child nodes. HtmlRenderer in QuickInfoWeb project then renders Html responses by visiting the Node tree of the results. ConsoleRenderer in the Info.exe console app visits the Node tree and just prints it to the console.

Contributing

Feel free to open issues to suggest/propose ideas. If you want to contribute a PR, please open an issue first so we can discuss. I will consider accepting high quality pull requests, however in each case I will decide whether the PR adds a solution that fits the spirit of what I want to achieve. Sorry if I decline too specific or exotic functionality. I also can't add answers that won't be useful to the majority of users.

Longer term I want to think about letting people easily add their own answers (and store them in their own private account, like OneNote), but this is far out in the future and I'm not sure I have the time and resources to maintain that.

quickinfo's People

Contributors

0xced avatar abock avatar amadeusw avatar cromica avatar dependabot[bot] avatar kirillosenkov avatar lefttwixwand avatar nugetninja avatar ramtejsudani avatar ryandle avatar tompazourek avatar vladimirreshetnikov avatar vladimirrybalko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quickinfo's Issues

cheat.sh

Part of the vision was to have something like http://cheat.sh - see if it makes sense to integrate in some way

5 mi

should be interpreted as 5 miles

Replace fixer.io with exchangerates.io

While fixer.io provides a free tier it does require and API key. This can be a bit of an issue if the library is used from a desktop application as it will require building a mechanism to provide the access key (and the potential not technical user to create such a key). Using https://exchangeratesapi.io/ is free and doesn't require any key. More than that it's API is fully compatible with fixer.io.

I see 3 potential options:

  1. Replace fixer.io with exchangerates.io in the current implementation.
  2. Build a mechanism that allows specifying the api in the quickinfo library.
  3. I can just build my own currency processor. However I thought it could be potentially beneficial for library consumers.

I would be happy to provide a PR with the changes for the first 2 options if you consider them.

Liquid volume

3 tsp = 1 tbsp
2 tbsp = 1 oz
1/2 cup = 4 oz
1 cup = 8 oz
1 pint = 2 cups
1 quart = 4 cups
1 gallon = 4 quarts

6'5" + 11"

Understand feet\inches notation by providing conversion to metric units and simple arithmetic.

"100 eur in usd" currency conversion throws

System.AggregateException: One or more errors occurred. (Response status code does not indicate success: 404 (Not Found).) ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at System.Net.Http.HttpClient.d__27.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
at QuickInfo.Currency.GetRate(String from, String to) in C:\QuickInfo\src\QuickInfo\Processors\Converters\Currency.cs:line 35
at QuickInfo.Currency.<>c__DisplayClass4_0.b__0(ICacheEntry e) in C:\QuickInfo\src\QuickInfo\Processors\Converters\Currency.cs:line 25
at Microsoft.Extensions.Caching.Memory.CacheExtensions.GetOrCreate[TItem](IMemoryCache cache, Object key, Func`2 factory)
at QuickInfo.Currency.Convert(String from, String to, Double value) in C:\QuickInfo\src\QuickInfo\Processors\Converters\Currency.cs:line 21
at QuickInfo.Units.<>c.<.cctor>b__64_90(Double p) in C:\QuickInfo\src\QuickInfo\Processors\Converters\Units\Units.cs:line 175
at QuickInfo.UnitConverter.GetResult(Double value, Conversion conversion) in C:\QuickInfo\src\QuickInfo\Processors\Converters\Units\UnitConverter.cs:line 251
at QuickInfo.UnitConverter.GetResult(Double value, Unit unit, Unit toUnit) in C:\QuickInfo\src\QuickInfo\Processors\Converters\Units\UnitConverter.cs:line 179
at QuickInfo.UnitConverter.GetResult(Query query) in C:\QuickInfo\src\QuickInfo\Processors\Converters\Units\UnitConverter.cs:line 106
at QuickInfo.Engine.GetResults(Query query) in C:\QuickInfo\src\QuickInfo\Engine.cs:line 55
at QuickInfo.Controllers.AnswersController.GetSingleResponseWorker(Engine engine, String input, HttpRequest request) in C:\QuickInfo\src\QuickInfoWeb\Controllers\AnswersController.cs:line 101
at QuickInfo.Controllers.AnswersController.GetResponse(Engine engine, String input, HttpRequest request) in C:\QuickInfo\src\QuickInfoWeb\Controllers\AnswersController.cs:line 84
at QuickInfo.Controllers.AnswersController.Get(String query) in C:\QuickInfo\src\QuickInfoWeb\Controllers\AnswersController.cs:line 16
---> (Inner Exception #0) System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at System.Net.Http.HttpClient.d__27.MoveNext()<---

Arbitrary precision arithmetic

(((((365) * 4 + 1) * 25 - 1) * 4 + 1) * 25 - 366) * (10000 * 1000 * 60 * 60 * 24) - 1
double is not good enough for this

Remove HTML from responses

The readme mentions getting quick answers from command line as motivation for this project

how do I generate a random Guid from command line

Currently, queries return HTML that is then directly placed in the website.
Would you be open to accepting a PR that refactors all queries to internally work with data structures friendly for programmatic consumption? Ultimately, the Engine could format these response as HTML, plain text or whatever is the flavor of the month.

How would you like these data structure to look like? How about a collection key-value pairs?

Update nuget package

Thank you for building this tool. Would it be possible to update the nuget package with the latest changes? Current version doesn't have support for airport codes nor does the Unicode search.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.