• Stars
    star
    111
  • Rank 314,510 (Top 7 %)
  • Language
    Dart
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unsure Calculator

Unsure Calculator

Build Status - Cirrus

If you want to run the Unsure Calculator from source, this repository is for you. Otherwise, please go to filiph.github.io/unsure to learn more about the Unsure Calculator itself, and run itโ€”for freeโ€”from your browser.

Web app

The web calculator is in example/. To run it from source (assuming you have the Dart SDK installed):

$ cd example/
$ pub get
$ webdev serve --release

Now, navigating to http://localhost:8080 will open the page. Changing code in the project will trigger a rebuild. The --release flag is important, because otherwise the web worker won't work.

To publish the example to filiph.github.io/unsure, do the following:

  1. Install peanut (only once): pub global activate peanut
  2. Go to the example directory: cd example
  3. Run peanut: peanut
  4. Push the newly updated gh-pages branch to github: git push origin --set-upstream gh-pages

Command line tool

You can run the command line version of the calculator by executing something like dart bin/unsure.dart "10 * 2~3" from the root of the repository. To get help, run dart bin/unsure.dart --help.

You can compile the tool to a binary executable by running dart2native bin/unsure.dart -o unsure. Then, call the binary like this:

$ ./unsure "10~20 * 42"

An animated gif of the binary in action

This compiled binary starts much faster than if you run the code through dart bin/unsure.dart "...".

Note that the command line tool defaults to 1 million iterations (compared to the 250K iterations of the web tool). That makes it a bit more precise (meaning that the results will be a tiny bit closer to the truth, and the histogram will be smoother). We can do this because Dart (compiled or not) runs a lot faster than JavaScript. That said, in my experiments, 250K iterations is precise enough.

Easy installation

If you don't want to clone the repository and just want to try the command line tool, you can use pub (part of the Dart SDK) to install it:

$ pub global activate unsure

Or, if you have the Flutter SDK installed:

$ flutter pub global activate unsure

You might need to follow instructions that pub gives you, but after that, you can just run unsure as a regular command line program from anywhere.

Package

Apart from that online tool, this is also a (beginning of a) package. Read through bin/unsure.dart to see how it might be used.

Here's a more low-level example of use:

import 'package:unsure/unsure.dart';

void main() {
    var principal = 1000;
    var interestRate = Range(2, 4);
    var time = Range(10, 12);
    
    var calc = Calculation(
      () => principal * (1 + interestRate.next() / 100) * time.next());
    
    var result = calc.run();
    
    print(result.simple);
    print(result.histogram);
    print(result.confidences[99]);
}

In this example, we defined one constant (principal), two ranges (interestRate and time), and a custom callback that computes compound interest given the above. The callback can be arbitrary Dart code: you are not limited to the format understandable by lib/src/parser.dart.

Help needed

There's only so much I (Filip) can do myself. If this is ever going to be a truly open source project, I need to remove myself from a lot of the ownership of this thing.

  • Can you help me publish the CLI binary to popular repositories such as APT, Homebrew, or Nugget? I know how to compile the tool on each platform, but I don't know what to do next.
  • Can you come up with more interesting use case or formula, and write an article about it? The companion article at filiph.github.io/unsure is already too long.
  • Similarly, can you record a video tutorial explaining the use of this tool?
  • Can you help me automate the creation of binaries for each release, for each platform? I hear GitHub actions is the way to do it, but I've never done it.
  • If you're familiar with package:petitparser, can you help me rewrite the formula parser so it's more helpful? In particular, I'd like it to give more helpful feedback to the user.
  • Can you help me automate test coverage reporting?
  • Can you help me make the command line executable more stable?
  • Can you help me make the Unsure Calculator site into a true Progressive Web App?
  • Can you help me put the range (~) notation into more calculators out there?

If you're interested in helping, please see if there's an issue you might assign to yourself, and if not, create it.

Language

I've done some research on what people generally mean when they say things like "certainly" in regular speech. This might be useful when talking about probabilities with untrained statisticians (such as myself).

Noun Adverb Percentage Sigma
All Certainly 100 % -
Almost all Almost certainly 95 % 2
Large majority Quite possibly 68 % 1
Bare majority Possibly 50+ % -

More Repositories

1

state_experiments

Companion repository to the "Build reactive mobile apps in Flutter" talk
Dart
909
star
2

hn_app

The HN reader app developed live on The Boring Flutter Development Show
Dart
487
star
3

tictactoe

Dart
426
star
4

linkcheck

Fast link checker
Dart
405
star
5

english_words

Utilities for working with English words
Dart
206
star
6

egamebook

A procedural sword & sorcery adventure
Dart
192
star
7

conference_darwin

A library for building conference schedules using a genetic algorithm.
Dart
97
star
8

scifi_ui

Taking Flutter's custom UI capabilities to movie UI territory
Dart
89
star
9

dartbin

DEPRECATED: use https://dart.dev/tools/dart2native instead
Dart
60
star
10

little_things

Code for the app in https://www.youtube.com/watch?v=MIepaf7ks40
Dart
57
star
11

selfimproving-dev

The Self-Improving Developer book.
HTML
49
star
12

edgehead

MOVED:
44
star
13

html_unescape

Dart library for unescaping HTML-encoded strings
Dart
40
star
14

darwin

A genetic algorithm library for Dart.
Dart
37
star
15

markov

Markov chain generator in Dart
Dart
35
star
16

filiphnet

Filip Hracek's personal homepage
HTML
30
star
17

human-life

An app for visualizing human life in weeks.
Dart
28
star
18

progress_bar

JavaScript
26
star
19

win95_flutter

A silly experiment with rendering Windows95-like UI in Flutter
Dart
25
star
20

cli_menu

A simple menu (picker) that works on the command line.
Dart
23
star
21

sloth_app

Intentionally slow Flutter app
Dart
23
star
22

fuzzylogic

Fuzzy logic module for Dart.
Dart
22
star
23

flutter_template_maker

A tool for automatically creating Flutter templates from existing Flutter projects.
Dart
17
star
24

prime_finder

Find primes that include meaningful numbers
Dart
17
star
25

observable_flutter_cube

Dart
16
star
26

adaptive_boring

Dart
15
star
27

game_template

Dart
14
star
28

bespoke

Dart
14
star
29

extension_methods_playground

A few samples use cases of Dart extension methods.
Dart
14
star
30

benchmarkhor

Benchmark comparison tool.
Dart
12
star
31

youtube_subs

Prettifies autogenerated subtitles
Dart
11
star
32

sample_downloader

A command-line tool for easy extraction of Dart & Flutter projects from GitHub repositories.
Dart
11
star
33

slot_machine

Dart
10
star
34

game_benchmarks

ShaderLab
10
star
35

t_stats

A Dart library for statistics.
Dart
9
star
36

tmzns

Automatically exported from code.google.com/p/tmzns
JavaScript
9
star
37

wnews

A tiny command-line news reader
Dart
9
star
38

ink-dart

Dart wrapper around Ink.
Dart
7
star
39

startup_namer

An AngularDart web app for naming startups.
Dart
7
star
40

jsonml

JsonML for Dart
Dart
6
star
41

spaceship_combat

Dart
6
star
42

service_worker_helper

Dart
5
star
43

simpleverse

A simple program that is procedurally generating short poems
Dart
4
star
44

startup_namer_flutter

Dart
4
star
45

codelab-experiment

C++
4
star
46

grayshore

Grayshore is an old-school fantasy setting for roleplaying games (like Dungeons & Dragons), computer games and whatever else that needs a consistent world.
4
star
47

gtag_analytics

A minimal Google Analytics interop library for Dart.
Dart
3
star
48

zombie

Dart
3
star
49

goap

Goal oriented action planning in Dart.
Dart
3
star
50

construct3-standalone

A simple Electron wrapper around Construct 3 web app.
JavaScript
2
star
51

another

Another Death of Art: an evolutionary algorithm art project
Python
2
star
52

flame-collision-benchmark

Dart
2
star
53

lochness

Ludum Dare game
Dart
2
star
54

timeline

A simple web-based tool for creating SVG timelines
Dart
2
star
55

devfest_cz

Dart
2
star
56

dart-logo-neural-pilot

Dart
2
star
57

dart-graphml

DEPRECATED: Please do not use this code
Dart
1
star
58

reddit_crawler

A simple command line tool that gets all Reddit submissions about a particular technology
Dart
1
star
59

bodega

Dart
1
star
60

herding-game

Automatically exported from code.google.com/p/herding-game
JavaScript
1
star
61

egamebook_server

Dart
1
star
62

dart-xml

A lightweight XML library for Dart.
Dart
1
star
63

components_codelab

Dart
1
star
64

georgeous

This is a 2 year old exercise in Android app design. Nothing much to see here, really.
Java
1
star
65

text_interpolate

Minimal Dart library for random interpolation between two Strings. To be used for 'animation' - tweening between texts.
Dart
1
star
66

measure

Tools for measuring some performance metrics.
Dart
1
star