All Projects → dwyl → Hits Elixir

dwyl / Hits Elixir

Licence: gpl-2.0
📈 An Elixir implementation of the "Hits" project (a super-basic "Web Page View Counter")

Programming Languages

elixir
2628 projects

Hits Elixir

hits-dwyl-teal-banner

Build Status Inline docs codecov.io HitCount


Elixir implementation of: https://github.com/dwyl/hits

Why?

Because Elixir == ❤️!! see: github.com/dwyl/learn-elixir#why

What?

A basic "web counter", see: https://github.com/dwyl/hits#what

Assumptions / Prerequisites

How?

To run the app on your localhost follow these 3 easy steps:

1. Clone/Download the Code

git clone https://github.com/dwyl/hits-elixir.git && cd hits-elixir

2. Install the Dependencies

Install dependencies and create necessary directories (to store the data):

mix deps.get && mkdir -p logs/agents

3. Run the App

mix run --no-halt

That's it!

Visit: http://localhost:8080/ (in your web browser)

hits-homepage

Or visit any endpoint that includes .svg in the url, e.g: http://localhost:8080/yourname/project.svg

hits-example-badge

Refresh the page a few times and watch the count go up!

hit-count-42

note: I've increased the "zoom" in chrome to 500% for effect.

Now, take your time to peruse the code in /test and /lib, and ask any questions by opening GitHub Issues: https://github.com/dwyl/hits-elixir/issues

Run the Tests

You

mix test

If you want to run the tests with coverage, copy-paste the following command into your terminal:

mix cover

If you want to view the coverage in a web browser:

mix cover && open cover/excoveralls.html

Research & Background Reading

We found the following links/articles/posts useful when learning how to build this mini-project:

Plug (the Elixir HTTP Library)

SHA Cryptographic Hash Functions in Elixir/Erlang

Mix Tasks

Compact sub-string syntax

iex> "1test2" == "test"
false
iex> "1test2" =~ "test"
true

Generate Random Strings in Elixir

:rand.uniform(n)

Unix Timestamp in Elixir

iex> DateTime.utc_now |> DateTime.to_unix
1486035766

iex> System.system_time(:second)
1486035766

iex> System.system_time(:millisecond)
1504975995312
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].