Mix.install [
{:exla, github: "elixir-nx/nx", sparse: "exla"},
{:nx, github: "elixir-nx/nx", sparse: "nx", override: true},
{:pythonx, "~> 0.4.7"}
]
This file contains hidden or 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
| defmodule MyApp.Http do | |
| @moduledoc """ | |
| Exposes functions to make HTTP requests and optionally cache the response. | |
| If you want to cache the request, simply add `cache: true` to the | |
| request options. You can also define an option time-to-live (TTL) with | |
| `cache_ttl: ttl_in_milliseconds`. The default TTL is 5min. | |
| Only caches 2xx responses. | |
| """ |
Problem: accidentally pressing 'Esc' when editing a form in a "standard" LiveView modal dialog will discard all edits.
Proposed solution: Make the modal show a confirmation window on close when there have been changes on the form.
LiveView v0.20 was used.
Table of content
This file contains hidden or 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
| defmodule Training.Example do | |
| def train() do | |
| Nx.default_backend(EXLA.Backend) | |
| {:ok, spec} = | |
| Bumblebee.load_spec({:hf, "prajjwal1/bert-medium"}, | |
| module: Bumblebee.Text.Bert, | |
| architecture: :for_sequence_classification | |
| ) |
This file contains hidden or 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
| defmodule ExampleApp.Web.LiveAcl do | |
| @moduledoc """ | |
| ACL checks for LiveView | |
| ``` | |
| use ExampleApp.Web.LiveAcl | |
| ``` | |
| Provides an `on_mount` hook to do ACL checks on mount, for instance | |
| to ensure the current user has access to a given invoice ID. |
This file contains hidden or 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
| defmodule Mix.Tasks.ConvertToVerifiedRoutes do | |
| @shortdoc "Fix routes" | |
| use Mix.Task | |
| @regex ~r/(Routes\.)(.*)_(path|url)\(.*?\)/ | |
| @web_module MyAppWeb | |
| def run(_) do | |
| Path.wildcard("lib/**/*.*ex") |
This file contains hidden or 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
| ### | |
| ### [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. |
This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/
the command zig run my_code.zig will compile and immediately run your Zig
program. Each of these cells contains a zig program that you can try to run
(some of them contain compile-time errors that you can comment out to play
with)
This file contains hidden or 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
| defmodule Ecto.Extension.Query.API do | |
| defmacro cond_(do: block) do | |
| bindings = | |
| Enum.reduce(block, [], fn | |
| {:->, _, [[clause], branch]}, acc -> | |
| [branch, clause | acc] | |
| end) | |
| |> Enum.reverse() | |
| bindings_number = length(bindings) |
NewerOlder