sudo apt update && sudo apt upgrade| defmodule NestedWeb.FormLive do | |
| use NestedWeb, :live_view | |
| require Logger | |
| defmodule Form do | |
| use Ecto.Schema | |
| import Ecto.Changeset | |
| embedded_schema do | |
| field :name, :string |
| ### | |
| ### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places. | |
| ###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of | |
| ###. things to watch out for: | |
| ### - Check out the `nix-darwin` instructions, as they have changed. | |
| ### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026 | |
| ### | |
| # I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs). | |
| # So here's a minimal Gist which worked for me as an install on a new M1 Pro. |
After writing Genetic Algorithms in Elixir, I had no real hopes or expectations that numerical computing would become a focus for Elixir. However, to my surprise, the Nx project developed rather quickly, and proved that Elixir could be used for practical machine learning and numerical computing applications. While I don't have any plans (yet) of reworking the examples in my book to take advantage of the acceleration enabled by Nx, EXLA, and other projects, I feel it's necessary to show how you could go about rewriting your genetic algorithms to take advantage of Elixir's new numerical computing libraries.
Nx is a numerical computing library for Elixir which supports the creation and manipulation of multi-dimensional arrays (called tensors in the API), automatic differentiation, and just-in-time (JIT) compilation to CPU, GPU, and other accelerators via pluggable backends and compilers. Nx opens up a realm of possibilities for Elixir dev
| // assets/js/app.js | |
| // ... | |
| import Pickr from "./pickr" | |
| const hooks = { | |
| Pickr | |
| } | |
| // ... |
| import talib | |
| import statsmodels.api as sm | |
| import pandas as pd | |
| def initialize(context): | |
| context.security = symbol('AAPL') | |
| #set_universe(universe.DollarVolumeUniverse(floor_percentile=98.0,ceiling_percentile=100.0)) | |
| def bar_data(OHLC_type, bars_nr): | |
| bar_data_func = (history((bars_nr + 1), '1d', OHLC_type).iloc[0]).astype('float') |
| defmodule MyApp.Periodically do | |
| use GenServer | |
| def start_link do | |
| GenServer.start_link(__MODULE__, %{}) | |
| end | |
| def init(state) do | |
| Process.send_after(self(), :work, 2 * 60 * 60 * 1000) # In 2 hours | |
| {:ok, state} |
| import random | |
| add = lambda a,b: a+b | |
| sub = lambda a,b: a-b | |
| mul = lambda a,b: a*b | |
| div = lambda a,b: a/b if a % b == 0 else 0/0 | |
| operations = [ (add, '+'), | |
| (sub, '-'), | |
| (mul, '*'), |
| # This is an example of metaprogramming in the Elixir language. | |
| # | |
| # We will define a domain specific language (DSL) for the definition | |
| # of a service which is watched by several sensors. | |
| # Each sensor watches some property/functionality of the service and | |
| # returns the result of the check. | |
| # | |
| # To determine if the service is functioning properly, we need functions | |
| # to run all the sensors' code and gather the returned data. | |
| # |
| import Data.Complex | |
| import Control.Arrow | |
| import Control.Monad | |
| fft :: [Complex Double] -> [Complex Double] | |
| fft = fft' . pad | |
| -- perform a fast fourier transform | |
| fft' :: [Complex Double] -> [Complex Double] | |
| fft' [x] = [x] |