-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple version to collect and display data
* Consumes data * Displays data
- Loading branch information
0 parents
commit de438d1
Showing
105 changed files
with
13,375 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
# This file contains the configuration for Credo and you are probably reading | ||
# this after creating it with `mix credo.gen.config`. | ||
# | ||
# If you find anything wrong or unclear in this file, please report an | ||
# issue on GitHub: https://github.com/rrrene/credo/issues | ||
# | ||
%{ | ||
# | ||
# You can have as many configs as you like in the `configs:` field. | ||
configs: [ | ||
%{ | ||
# | ||
# Run any exec using `mix credo -C <name>`. If no exec name is given | ||
# "default" is used. | ||
# | ||
name: "default", | ||
# | ||
# These are the files included in the analysis: | ||
files: %{ | ||
# | ||
# You can give explicit globs or simply directories. | ||
# In the latter case `**/*.{ex,exs}` will be used. | ||
# | ||
included: ["lib/", "src/", "test/", "web/", "apps/"], | ||
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"] | ||
}, | ||
# | ||
# If you create your own checks, you must specify the source files for | ||
# them here, so they can be loaded by Credo before running the analysis. | ||
# | ||
requires: [], | ||
# | ||
# If you want to enforce a style guide and need a more traditional linting | ||
# experience, you can change `strict` to `true` below: | ||
# | ||
strict: true, | ||
# | ||
# If you want to use uncolored output by default, you can change `color` | ||
# to `false` below: | ||
# | ||
color: true, | ||
# | ||
# You can customize the parameters of any check by adding a second element | ||
# to the tuple. | ||
# | ||
# To disable a check put `false` as second element: | ||
# | ||
# {Credo.Check.Design.DuplicatedCode, false} | ||
# | ||
checks: [ | ||
# | ||
## Consistency Checks | ||
# | ||
{Credo.Check.Consistency.ExceptionNames, []}, | ||
{Credo.Check.Consistency.LineEndings, []}, | ||
{Credo.Check.Consistency.ParameterPatternMatching, []}, | ||
{Credo.Check.Consistency.SpaceAroundOperators, []}, | ||
{Credo.Check.Consistency.SpaceInParentheses, []}, | ||
{Credo.Check.Consistency.TabsOrSpaces, []}, | ||
|
||
# | ||
## Design Checks | ||
# | ||
# You can customize the priority of any check | ||
# Priority values are: `low, normal, high, higher` | ||
# | ||
{Credo.Check.Design.AliasUsage, | ||
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]}, | ||
# You can also customize the exit_status of each check. | ||
# If you don't want TODO comments to cause `mix credo` to fail, just | ||
# set this value to 0 (zero). | ||
# | ||
{Credo.Check.Design.TagTODO, [exit_status: 2]}, | ||
{Credo.Check.Design.TagFIXME, []}, | ||
|
||
# | ||
## Readability Checks | ||
# | ||
{Credo.Check.Readability.AliasOrder, []}, | ||
{Credo.Check.Readability.FunctionNames, []}, | ||
{Credo.Check.Readability.LargeNumbers, []}, | ||
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]}, | ||
{Credo.Check.Readability.ModuleAttributeNames, []}, | ||
{Credo.Check.Readability.ModuleDoc, []}, | ||
{Credo.Check.Readability.ModuleNames, []}, | ||
{Credo.Check.Readability.ParenthesesInCondition, []}, | ||
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []}, | ||
{Credo.Check.Readability.PredicateFunctionNames, []}, | ||
{Credo.Check.Readability.PreferImplicitTry, []}, | ||
{Credo.Check.Readability.RedundantBlankLines, []}, | ||
{Credo.Check.Readability.Semicolons, []}, | ||
{Credo.Check.Readability.SpaceAfterCommas, []}, | ||
{Credo.Check.Readability.StringSigils, []}, | ||
{Credo.Check.Readability.TrailingBlankLine, []}, | ||
{Credo.Check.Readability.TrailingWhiteSpace, []}, | ||
{Credo.Check.Readability.VariableNames, []}, | ||
|
||
# | ||
## Refactoring Opportunities | ||
# | ||
{Credo.Check.Refactor.CondStatements, []}, | ||
{Credo.Check.Refactor.CyclomaticComplexity, []}, | ||
{Credo.Check.Refactor.FunctionArity, []}, | ||
{Credo.Check.Refactor.LongQuoteBlocks, []}, | ||
{Credo.Check.Refactor.MapInto, []}, | ||
{Credo.Check.Refactor.MatchInCondition, []}, | ||
{Credo.Check.Refactor.NegatedConditionsInUnless, []}, | ||
{Credo.Check.Refactor.NegatedConditionsWithElse, []}, | ||
{Credo.Check.Refactor.Nesting, []}, | ||
{Credo.Check.Refactor.PipeChainStart, | ||
[excluded_argument_types: [:atom, :binary, :fn, :keyword], excluded_functions: []]}, | ||
{Credo.Check.Refactor.UnlessWithElse, []}, | ||
|
||
# | ||
## Warnings | ||
# | ||
{Credo.Check.Warning.BoolOperationOnSameValues, []}, | ||
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []}, | ||
{Credo.Check.Warning.IExPry, []}, | ||
{Credo.Check.Warning.IoInspect, []}, | ||
{Credo.Check.Warning.LazyLogging, []}, | ||
{Credo.Check.Warning.OperationOnSameValues, []}, | ||
{Credo.Check.Warning.OperationWithConstantResult, []}, | ||
{Credo.Check.Warning.RaiseInsideRescue, []}, | ||
{Credo.Check.Warning.UnusedEnumOperation, []}, | ||
{Credo.Check.Warning.UnusedFileOperation, []}, | ||
{Credo.Check.Warning.UnusedKeywordOperation, []}, | ||
{Credo.Check.Warning.UnusedListOperation, []}, | ||
{Credo.Check.Warning.UnusedPathOperation, []}, | ||
{Credo.Check.Warning.UnusedRegexOperation, []}, | ||
{Credo.Check.Warning.UnusedStringOperation, []}, | ||
{Credo.Check.Warning.UnusedTupleOperation, []}, | ||
|
||
# | ||
# Controversial and experimental checks (opt-in, just remove `, false`) | ||
# | ||
{Credo.Check.Consistency.MultiAliasImportRequireUse, false}, | ||
{Credo.Check.Design.DuplicatedCode, false}, | ||
{Credo.Check.Readability.Specs, false}, | ||
{Credo.Check.Refactor.ABCSize, false}, | ||
{Credo.Check.Refactor.AppendSingleItem, false}, | ||
{Credo.Check.Refactor.DoubleBooleanNegation, false}, | ||
{Credo.Check.Refactor.VariableRebinding, false}, | ||
{Credo.Check.Warning.MapGetUnsafePass, false}, | ||
{Credo.Check.Warning.UnsafeToAtom, false} | ||
|
||
# | ||
# Custom checks can be created using `mix credo.gen.check`. | ||
# | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_build/ | ||
deps/ | ||
.git/ | ||
.gitignore | ||
Dockerfile | ||
Makefile | ||
README* | ||
test/ | ||
priv/static/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["mix.exs", "config/*.exs"], | ||
subdirectories: ["apps/*"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where 3rd-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# Ignore .fetch files in case you like to edit your project deps locally. | ||
/.fetch | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# The version of Alpine to use for the final image | ||
# This should match the version of Alpine that the `elixir:1.7.2-alpine` image uses | ||
ARG ALPINE_VERSION=3.8 | ||
|
||
FROM elixir:1.7.2-alpine AS builder | ||
|
||
# The following are build arguments used to change variable parts of the image. | ||
# The name of your application/release (required) | ||
ARG APP_NAME | ||
# The version of the application we are building (required) | ||
ARG APP_VSN | ||
# The environment to build with | ||
ARG MIX_ENV=prod | ||
# Set this to true if this release is not a Phoenix app | ||
ARG SKIP_PHOENIX=false | ||
# If you are using an umbrella project, you can change this | ||
# argument to the directory the Phoenix app is in so that the assets | ||
# can be built | ||
ARG PHOENIX_SUBDIR=apps/aircraft | ||
|
||
ENV SKIP_PHOENIX=${SKIP_PHOENIX} \ | ||
APP_NAME=${APP_NAME} \ | ||
APP_VSN=${APP_VSN} \ | ||
MIX_ENV=${MIX_ENV} | ||
|
||
# By convention, /opt is typically used for applications | ||
WORKDIR /opt/app | ||
|
||
# This step installs all the build tools we'll need | ||
RUN apk update && \ | ||
apk upgrade --no-cache && \ | ||
apk add --no-cache \ | ||
nodejs \ | ||
yarn \ | ||
git \ | ||
build-base && \ | ||
mix local.rebar --force && \ | ||
mix local.hex --force | ||
|
||
# This copies our app source code into the build container | ||
COPY . . | ||
|
||
RUN mix do deps.get, deps.compile, compile | ||
|
||
# This step builds assets for the Phoenix app (if there is one) | ||
# If you aren't building a Phoenix app, pass `--build-arg SKIP_PHOENIX=true` | ||
# This is mostly here for demonstration purposes | ||
RUN if [ ! "$SKIP_PHOENIX" = "true" ]; then \ | ||
cd ${PHOENIX_SUBDIR}/assets && \ | ||
yarn install && \ | ||
yarn deploy && \ | ||
cd .. && \ | ||
mix phx.digest; \ | ||
fi | ||
|
||
RUN \ | ||
mkdir -p /opt/built && \ | ||
mix release --verbose && \ | ||
cp _build/${MIX_ENV}/rel/${APP_NAME}/releases/${APP_VSN}/${APP_NAME}.tar.gz /opt/built && \ | ||
cd /opt/built && \ | ||
tar -xzf ${APP_NAME}.tar.gz && \ | ||
rm ${APP_NAME}.tar.gz | ||
|
||
# From this line onwards, we're in a new image, which will be the image used in production | ||
FROM alpine:${ALPINE_VERSION} | ||
|
||
# The name of your application/release (required) | ||
ARG APP_NAME | ||
|
||
RUN apk update && \ | ||
apk add --no-cache \ | ||
bash \ | ||
openssl-dev | ||
|
||
ENV REPLACE_OS_VARS=true \ | ||
APP_NAME=${APP_NAME} | ||
|
||
WORKDIR /opt/app | ||
|
||
COPY --from=builder /opt/built . | ||
|
||
CMD trap 'exit' INT; /opt/app/bin/${APP_NAME} foreground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.PHONY: help | ||
|
||
APP_NAME ?= `grep 'app:' mix.exs | sed -e 's/\[//g' -e 's/ //g' -e 's/app://' -e 's/[:,]//g'` | ||
APP_VSN ?= `grep 'version:' mix.exs | cut -d '"' -f2` | ||
BUILD ?= `git rev-parse --short HEAD` | ||
|
||
help: | ||
@echo "$(APP_NAME):$(APP_VSN)-$(BUILD)" | ||
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
build: ## Build the Docker image | ||
docker build --build-arg APP_NAME=$(APP_NAME) \ | ||
--build-arg APP_VSN=$(APP_VSN) \ | ||
-t $(APP_NAME):$(APP_VSN)-$(BUILD) \ | ||
-t $(APP_NAME):latest . | ||
|
||
run: ## Run the app in Docker | ||
docker run --env-file config/docker.env \ | ||
--expose 4000 -p 4000:4000 \ | ||
--rm -it $(APP_NAME):latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Aircraftspotter | ||
|
||
Project to collect and visualize data collected from a ADS-B source. | ||
|
||
The main goal of this project is to play around with the different features of Elixir. | ||
|
||
If you are looking for a nice interface with a Map to show you in real time where each plane is located then this might not be your project. | ||
For those maps please refer to your local `dump-1090`. | ||
|
||
|
||
## Umbrella projects | ||
|
||
The current flow: | ||
|
||
### Aircraft | ||
Phoenix project in charge of parsing and visualizing the collected data. Data comes from the `Fetcher` application. | ||
|
||
### Decoder | ||
Library to help decoding ADS-B data. | ||
The majority of the code has been ported from [dump1090](https://github.com/flightaware/dump1090). | ||
|
||
### Fetcher | ||
Fetches the data from a [dump1090-fa](https://github.com/flightaware/dump1090/blob/master/README-json.md) source | ||
and makes it available via [GenStage](https://hexdocs.pm/gen_stage/GenStage.html). | ||
|
||
The data is being collected by polling the public endpoint. For real time data we would need to listen to the TCP port from `dump1090` | ||
and unfortunately we would need to decode all the ADS-B data again. | ||
|
||
## Requirements | ||
|
||
* Elixir >= 1.7 | ||
* Postgres database | ||
|
||
## Installation | ||
|
||
```bash | ||
mix deps.get | ||
|
||
DUMP1090_JSON_ENDPOINT="http://localhost:8080/data/aircraft.json" mix phx.server | ||
``` | ||
|
||
## Release | ||
|
||
```bash | ||
MIX_ENV=prod mix release | ||
``` | ||
|
||
Define the environment vars located at `rel/config/config.exs` | ||
|
||
## Tests | ||
|
||
``` | ||
mix test | ||
``` | ||
|
||
## Development tools | ||
|
||
* `mix dialyzer` | ||
* `mix credo --verbose` | ||
* `mix test --cover` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
import_deps: [:ecto, :phoenix], | ||
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"], | ||
subdirectories: ["priv/*/migrations"] | ||
] |
Oops, something went wrong.