All Projects → xvw → Mizur

xvw / Mizur

Licence: mit
Mizur is a tool to simplify the handling of units, and units coercion/mapping. (it is an evolution of Abacus)

Programming Languages

elixir
2628 projects
macros
77 projects

Projects that are alternatives of or similar to Mizur

Appmetrics
Node Application Metrics provides a foundational infrastructure for collecting resource and performance monitoring data for Node.js-based applications.
Stars: ✭ 864 (+2441.18%)
Mutual labels:  metrics
Unifiedmetrics
Fully-featured metrics collection agent for Minecraft servers. Supports Prometheus and InfluxDB. Dashboard included out-of-box.
Stars: ✭ 29 (-14.71%)
Mutual labels:  metrics
Iota Prom Exporter
Iota Exporter for Prometheus Metrics
Stars: ✭ 33 (-2.94%)
Mutual labels:  metrics
Uncertainty Toolbox
A python toolbox for predictive uncertainty quantification, calibration, metrics, and visualization
Stars: ✭ 880 (+2488.24%)
Mutual labels:  metrics
Prometheus Net
.NET library to instrument your code with Prometheus metrics
Stars: ✭ 944 (+2676.47%)
Mutual labels:  metrics
Ipsec exporter
Prometheus exporter for IPsec metrics.
Stars: ✭ 30 (-11.76%)
Mutual labels:  metrics
Gtm
Simple, seamless, lightweight time tracking for Git
Stars: ✭ 857 (+2420.59%)
Mutual labels:  metrics
Absinthe Metrics
Pluggable metrics for Absinthe based GraphQL backends
Stars: ✭ 34 (+0%)
Mutual labels:  metrics
Ruby Gem Downloads Badge
Clean and simple gem downloads count badge, courtesy of http://shields.io/. You can checkout the application directly at the following URL:
Stars: ✭ 29 (-14.71%)
Mutual labels:  metrics
Nginx Lua Prometheus
Prometheus metric library for Nginx written in Lua
Stars: ✭ 964 (+2735.29%)
Mutual labels:  metrics
Sensu Plugins Process Checks
This plugin provides native process instrumentation for monitoring and metrics collection, including: process status, uptime, thread count, and others.
Stars: ✭ 20 (-41.18%)
Mutual labels:  metrics
Sensu Plugins Network Checks
This plugin provides native network instrumentation for monitoring and metrics collection, including: hardware, TCP response, RBLs, whois, port status, and more.
Stars: ✭ 28 (-17.65%)
Mutual labels:  metrics
Pgwatch2
PostgreSQL metrics monitor/dashboard
Stars: ✭ 960 (+2723.53%)
Mutual labels:  metrics
Analytics
Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
Stars: ✭ 9,469 (+27750%)
Mutual labels:  metrics
I Codecnes
i-Code CNES is a static code analysis tool to help developpers write code compliant with CNES coding rules.
Stars: ✭ 33 (-2.94%)
Mutual labels:  metrics
Pirate
Realtime metrics server written in Go
Stars: ✭ 11 (-67.65%)
Mutual labels:  metrics
Iperf3 exporter
Simple server that probes iPerf3 endpoints and exports results via HTTP for Prometheus consumption
Stars: ✭ 30 (-11.76%)
Mutual labels:  metrics
Cpp Statsd Client
A header-only StatsD client implemented in C++
Stars: ✭ 34 (+0%)
Mutual labels:  metrics
Core
Package core is a service container that elegantly bootstrap and coordinate twelve-factor apps in Go.
Stars: ✭ 34 (+0%)
Mutual labels:  metrics
Go Grpc Prometheus
Prometheus monitoring for your gRPC Go servers.
Stars: ✭ 965 (+2738.24%)
Mutual labels:  metrics

Mizur

Pronounced /'meʒə/

Mizur is a tool to simplify the management, conversion
and mapping of units. The manipulation of measurement units should (at best) be typesafe.

Mizur Logo (A special thanks to @fh-d for this awesome logo !)

Some examples

Basic example

Definition of a metric system for computing distances :

defmodule Distance do 
  use Mizur.System
  type m
  type cm = m / 100 
  type mm = m / 1000 
  type km = m * 1000
end

Using this module provides the following functions:

  • Distance.m/0 : to reference the type Distance.m
  • Distance.cm/0 : to reference the type Distance.cm
  • Distance.mm/0 : to reference the type Distance.mm
  • Distance.km/0 : to reference the type Distance.km

and :

  • Distance.m/1 : to create packed values in the Distance.m type
  • Distance.cm/1 : to create packed values in the Distance.cm type
  • Distance.mm/1 : to create packed values in the Distance.mm type
  • Distance.km/1 : to create packed values in the Distance.km type

and sigils : Distance.sigil_t(value, ['typename']).

Example of common Mizur usage

a = Distance.m(200)
b = Distance.cm(200)
result = Mizur.add(a, b)
assert result = Distance.m(202)

Using infix notation

You can use infix notation for operations on units of measurements using use Mizur.Infix.

As with the import directive, you can use the :except and :only parameters (exactly in the same way as usingimport).

The main difference with import is that use will overwrite the correct operators of the Kernel module.

Manage arithmetic operations on datetime

defmodule MyTime do 

  use Mizur.System
  type sec
  type min  = sec * 60 
  type hour = sec * 60 * 60
  type day  = sec * 60 * (60 * 24)

  def now do 
    DateTime.utc_now()
    |> DateTime.to_unix(:second)
    |> sec()
  end

  def new(year, month, day, hour, min, sec) do
    ndt = NaiveDateTime.new(year, month, day, hour, min, sec) 
    case ndt do 
      {:error, message} -> raise RuntimeError, message: "#{message}"
      {:ok, value} ->
        DateTime.from_naive!(value, "Etc/UTC")
        |> DateTime.to_unix(:second)
        |> sec()
    end
  end

  def to_datetime(value) do 
    elt = Mizur.from(value, to: sec())
    int = round(Mizur.unwrap(elt))
    DateTime.from_unix!(int) #beurk, it is unsafe
  end
  
end

use Mizur.Infix, only: [+: 2, -: 2]
import MyTime

# Create a typed_value of the current timestamp:
a = now()

# Add two days and four hour
b = a + ~t(2)day + ~t(4)hour # I use Sigils... 

# Sub ten minuts 
c = b - ~t(10)min

# Convert into DateTime 
result = to_datetime(c)

Other examples

The test module gives many usage examples : Test module

Installation

If available in Hex, the package can be installed by adding mizur to your list of dependencies in mix.exs:

def deps do
  [{:mizur, "~> 0.1.1"}]
end

Special Thanks

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/mizur/readme.html.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].