All public logs
Combined display of all available logs of ElixirBlocks. You can narrow down the view by selecting a log type, the username (case-sensitive), or the affected page (also case-sensitive).
- 09:21, 27 December 2024 Admin talk contribs created page How to Think About Phoenix Dead Views (Created page with "Each page (resource) has a route. These routes are assigned a controller and a function from that controller. In the code below, when a user goes to the "/" route a controller named PageController is found and a function named home is invoked. Controllers are simply modules and the third argument (in this case named '''home''') is a function on the controller. <source> get "/", PageController, :home </source>")
- 09:11, 27 December 2024 Admin talk contribs created page Phoenix Flash Message (Created page with "In Phoenix the flash message is invoked from the controller. <source> def create(conn, %{"doink" => doink_params}) do case Doinks.create_doink(doink_params) do {:ok, doink} -> conn |> put_flash(:info, "Doink created successfully.") |> redirect(to: ~p"/doinks/#{doink}") {:error, %Ecto.Changeset{} = changeset} -> render(conn, :new, changeset: changeset) end end </source> The message itself needs to be in the view...")
- 02:16, 8 December 2024 Admin talk contribs created page Update Phoenix Generator (Created page with "<pre> mix archive.install hex phx_new </pre>")
- 07:17, 17 August 2024 Admin talk contribs created page Kill Erlang Processes (Created page with "pgrep erl | xargs kill -9")
- 15:20, 16 August 2024 Admin talk contribs created page How to Install Elixir / Erlang on Ubuntu (Created page with "https://thinkingelixir.com/install-elixir-using-asdf/")
- 15:45, 5 August 2024 Admin talk contribs created page Postgres Setup (Created page with "==Windows== Download postgres from: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads When complete , launch the SQL Shell (psql) prompt application. Press Enter for each item in the list except "password". For password the default password is password. Type the password and hit Enter.")
- 22:54, 17 July 2024 Admin talk contribs created page How to Inspect the State of a GenServer From Console (Created page with "<source> :sys.get_state(pid) # pid of GenServer </source>")
- 22:24, 17 July 2024 Admin talk contribs deleted page Create Mix Application Entry Function (content was: "In Mix.ex <source> # Run "mix help compile.app" to learn about applications. def application do [ mod: {App, []}, # New Code. Set Module that contains that will contain start function extra_applications: [:logger] ] end </source> App.ex <source> defmodule App do use Application def start(_type, _args) do #Start code IO.inspect "App starte...", and the only contributor was "Admin" (talk))
- 06:52, 14 July 2024 Admin talk contribs created page Create Mix Application Entry Function (Created page with "In Mix.ex <source> # Run "mix help compile.app" to learn about applications. def application do [ mod: {App, []}, # New Code. Set Module that contains that will contain start function extra_applications: [:logger] ] end </source>")
- 01:46, 12 July 2024 Admin talk contribs created page Elixir Todo List Exercise (Created page with "<source> defmodule TodoList do defstruct todos: [] def start do loop(%TodoList{}) end def loop(state) do IO.puts("Todo List:") IO.inspect state.todos IO.puts("\nOptions:") IO.puts("1. Add Todo") IO.puts("2. Mark Todo as Done") IO.puts("3. Exit") case IO.gets("Select an option: ") |> String.trim() |> String.to_integer() do 1 -> todo = IO.gets("Enter Todo: ") |> String.trim() new_state = add_todo(state, to...")
- 06:21, 30 June 2024 Admin talk contribs created page Genserver (Created page with "mix new App --sup <b>app/lib/app.ex</b> <source> defmodule App.Service do use GenServer def start_link(state) do GenServer.start_link(__MODULE__, state, name: __MODULE__) end def init(state) do {:ok, state} end def get_state(pid) do GenServer.call(pid, :get_state) end def set_state(pid,state) do GenServer.call(pid, {:set_state, state}) end def handle_call(:get_state, _from, state) do {:reply, state, state} end de...")
- 05:50, 30 June 2024 Admin talk contribs created page How to View All Running Applications (Created page with "<source> :application.which_applications </source>")
- 05:07, 29 June 2024 Admin talk contribs created page Phoenix LiveView Async Assigns (Created page with "== Example== <source> defmodule AppWeb.PageLive do use AppWeb, :live_view alias Phoenix.LiveView.AsyncResult @impl true def mount(_params, _session, socket) do {:ok, assign_async(socket, :number, fn -> {:ok, %{number: really_complicated_function()}} end)} end @impl true def handle_event("generate_number", _, socket) do {:noreply, socket |> assign(:number, AsyncResult.loading()) |> start_async(:get_random_number, fn -> really_c...")
- 19:44, 20 June 2024 Admin talk contribs created page Compare Identical Files (Created page with "<source> defmodule FileComparator do def compare(file1, file2) do IO.inspect File.cwd!() content1 = read_file(file1) content2 = read_file(file2) if content1 == content2 do IO.puts("The files have identical content.") else IO.puts("The files have different content.") end end defp read_file(file_path) do case File.read(file_path) do {:ok, content} -> content {:error, reason} -> raise "Failed to read #{file_path}:...")
- 17:10, 13 June 2024 Admin talk contribs created page How to Upload Files Using Post Controller (Created page with " Create a LiveView and render a form with the multipart attribute. <source> <.form :let={f} action={~p"/transmit/#{switch}"} multipart> <.input field={f[:switch_item]} name="switch" type="file" /> <input type="submit" /> </.form> </source> Create a controller for the route /transmit/#{switch} '''transmit_controller.ex''' <source> defmodule AppWeb.TransmitCont...")
- 17:44, 11 June 2024 Admin talk contribs created page Use Phoenix to SSH into a Server and Download a File to Users Local Machine (Created page with "'''Download_Controller ''' <source> defmodule AppWeb.DownloadController do use AppWeb, :controller def home(conn, %{"switch" => switch}) do {:ok, conn} = SSH.connect( # "sim.com.whatever" user: "root", identity: "/home/user/.ssh/id_rsa_nop", save_accepted_host: false, silently_accept_hosts: true, user_interaction: false ) file_path = "priv/test.json" {:ok, json_data} = conn case File.write(file_path...")
- 01:46, 11 June 2024 Admin talk contribs created page Struct Pattern Matching in Arguments of Functions (Created page with "=Example= <source> %Person{} = person </source> <source> defmodule Person do defstruct [ first_name: nil, last_name: nil, birthday: nil, location: "home" ] def full_name(%Person{} = person) do "#{person.first_name} #{person.last_name}" end def age(%Person{} = person) do days = Date.diff(Date.utc_today, person.birthday) days / 365.25 end def home(%Person{} = person) do %{person | location: "home"} end def away(%P...")
- 19:36, 10 June 2024 Admin talk contribs created page Kill Hanging Process on Linux (Created page with "Use the command "top" to view top hanging process. sudo kill -9 pid_number_of_process")
- 18:40, 10 June 2024 Admin talk contribs created page How to Capture Text of Items When Clicked (Created page with "=Example= <source> defmodule AppWeb.PageLive do use AppWeb, :live_view def render(assigns) do ~L""" <div id="list-container"> <ul> <%= for item <- @items do %> <li phx-click="capture_text" phx-value-text="<%= item %>"><%= item %></li> <% end %> </ul> </div> """ end def mount(_params, _session, socket) do items = ["Item 1", "Item 2", "Item 3"] # Example list items {:ok, assign(socket, items: items)}...")
- 15:12, 10 June 2024 Admin talk contribs created page How to Write an Event Handler in Phoenix (Created page with "==Example== <source> defmodule AppWeb.PageLive do use AppWeb, :live_view def mount(_params, _session, socket) do {:ok, socket} end def handle_event("run", unsigned_params, socket) do IO.inspect "It works!" {:noreply, socket} end def render(assigns) do ~H""" <p phx-click="run">TEST</p> """ end end </source>")
- 01:48, 10 June 2024 Admin talk contribs created page Phoenix Live View Redirect (Created page with "<source> {:noreply, redirect(socket, to: "/download")} </source>")
- 15:15, 9 June 2024 Admin talk contribs created page Elixir Phoenix SSH (Created page with "These are ways to SSH into a server using Elixir/Phoenix. Using the librarian library you can do this: <source> SSH.connect!("test.laptop.local", username: "username", password: "passs", silently_accept_hosts: true) </source> If server has a private key: <source> SSH.connect( "server.host", user: "server.user", port: "server.port", identity: "identity path eg: ~/.ssh/id_rsa_nop", save_accepted_host: false, silen...")
- 18:15, 6 June 2024 Admin talk contribs created page How to Upload Files to Phoenix (Created page with "==Working Live View Example == <source> # lib/my_app_web/live/upload_live.ex defmodule AppWeb.PageLive do use AppWeb, :live_view @impl Phoenix.LiveView def mount(_params, _session, socket) do {:ok, socket |> assign(:uploaded_files, []) |> allow_upload(:avatar, accept: ~w(.json), max_entries: 1)} end @impl Phoenix.LiveView def handle_event("validate", _params, socket) do {:noreply, socket} end @impl Phoenix.LiveView def handle_ev...")
- 15:51, 5 June 2024 Admin talk contribs created page How to Download a Static File from Phoenix (Created page with "<source> defmodule AppWeb.PageController do use AppWeb, :controller def home(conn, _params) do path = Application.app_dir(:app, "priv/test.json") #static directory send_download(conn, {:file, path}) render(conn, :home, layout: false) end end </source>")
- 16:42, 2 May 2024 Admin talk contribs created page Retroactively Change Data Type of Table Field (Phoenix / Ecto) (Created page with "Example: <source> alter table(:name_of_table) do modify :content, :binary end </source>")
- 10:16, 29 April 2024 Admin talk contribs created page Non-Blocking Error Check Example (Created page with "Example of error checking using the ElixirRss module. <source> def fetch_and_parse(rss) do case ElixirRes.fetch_and_parse(rss) do {:ok, _response} = out -> out {:error, _} = err -> err end rescue e -> dbg(e) {:error, :unknown} end </source>")
- 20:19, 25 April 2024 Admin talk contribs created page Phoenix CORS (Cross Origin Resource Sharing) (Created page with "https://victorbjorklund.com/cors-error-phoenix-elixir-cors-plug")
- 16:09, 5 April 2024 Admin talk contribs created page How to Generate a UML Block Diagram of Ecto Database (Created page with "The ecto_erd module lets you generate a block diagram image of your schema by only using a few easy commands. https://github.com/fuelen/ecto_erd")
- 00:44, 15 March 2024 Admin talk contribs created page Router (Created page with "In Elixir Phoenix this is the file responsible for "routing" endpoint requests to data. When you create a new phoenix application named "app" the router is in this directory: '''app/lib/app_web/router.ex'''")
- 02:33, 14 March 2024 Admin talk contribs created page Add an HTML Page to Elixir Phoenix (Created page with "This tutorial describes how to render an HTML page in Elixir Phoenix. THis tutorial does not use Liveview. ==Create the Route== In '''app/appweb/router.ex''' set a route. In the example below, the route is a get request and the endpoint is '''/landing'''. Assign a Controller, in the code below this is '''PageController'''. In the third argument, set an atom that will be the name of the HTML page, in this case it is '''index'''. <source> get "/landing", PageControl...")
- 14:57, 4 January 2024 Admin talk contribs created page User talk:Admin (Created page with "ML Notes == Types of Machine Learning == ===Supervised=== '''Most common form of learning.''' Supervised ML simply means that we have an answer key for every question we’re using to train our machine. That is to say, our data is labeled. So if we’re trying to teach a machine to distinguish if a photo contains a bird, we can immediately grade the AI on whether it was right or wrong. Like a Scantron, we have the answer key. But unlike a Scantron and because it’s...")
- 19:12, 5 December 2023 Admin talk contribs created page How to Render RSS Feeds in Elixir Phoenix (Created page with "This is an example of how to capture and display an RSS feed in Phoenix. You must first install the '''Feedex''' RSS package. * https://www.hex.pm/packages/feedex * https://hexdocs.pm/feedex/Feedex.html * https://github.com/diegocurbelo/feedex Below is a LiveView example that uses the above package to render contents of an RSS feed to the browser. The raw() method comes with Elixir Phoenix and is used to sanitize HTML. ==Example== <source> defmodule AppWeb.PageLi...")
- 02:10, 3 December 2023 Admin talk contribs created page How to Use Built-In Phoenix Authentication (Created page with "{{In_progress}} <hr/> Phoenix has a built in authentication generator. To use the feature, you can run the following command: <source> mix phx.gen.auth Accounts User users </source> You are asked to choose the form of authentication that you want. The 2 choices are LiveView authentication or Controller based authentication. ==LiveView Authentication== ==Controller Based Authentication==")
- 16:07, 28 October 2023 Admin talk contribs created page Template:Liveview basics required (Created page with "This document assumes that you understand the basics of Liveview. This includes: * Phoenix and Elixir installation * Create an empty starter application * How to create a basic Liveview application * How to perform basic form submission * How_to_Iterate_and_Render_Database_Data_in_Phoenix_LiveView...")
- 23:38, 21 October 2023 User account Will talk contribs was created by Admin talk contribs
- 14:07, 20 October 2023 Admin talk contribs created page How to Move a Phoenix Project to a Different Development Server (Created page with " Remove '''_build''' and '''deps''' directories. Make sure your migration files are available in '''priv/repo/migrations''' If you are using a different database, in config/dev make sure your database credentials are set properly for the new database. '''run:''' * mix deps.get + compile * mix ecto.create * mix ecto.migrate * mix phx.server *")
- 14:03, 20 October 2023 Admin talk contribs deleted page How to Move a Project fto a Different Development Server (content was: "#REDIRECT How to Move a Project to a Different Development Server", and the only contributor was "Admin" (talk))
- 14:02, 20 October 2023 Admin talk contribs deleted page How to Move a Project to a Different Development Server (content was: " Remove '''_build''' and '''deps''' directories. Make sure your migration files are available '''priv/repo/migrations''' If you have changed your tables you will need to manually update the migration files. In config/dev make sure your database credentials are set and set a new database if desired. run: mix deps.get + compile mix ecto.create mix ecto.migrate mix phx.server", and the only contributor was "Admin" (talk))
- 16:11, 19 October 2023 Admin talk contribs created page How to Generate a Migration File (Created page with "A migration file lets you update and create table data. ==Generate a migration file== A migration file is generated using a console command. After it is generated, you write code that configures table fields and then invoke the migration file. The command to create a migration file is: <source> mix ecto.gen.migration name_of_migration </source> For this example, I will add a new field named owner <source> mix ecto.gen.migration create_owner_field </source> The mi...")
- 15:55, 19 October 2023 Admin talk contribs created page How to Set a Unique Constraint to a Table Field (Created page with "If you already have a table and retroactively want to set a field to only allow unique values, you need to create a migration with: <source> create unique_index(:table_name, [:field_name]) </source>")
- 13:39, 19 October 2023 Admin talk contribs moved page How to Delete A Table That has many Without Deleting Children to How to Delete A Table That Contains a "has many" Value Without Deleting Children
- 13:38, 19 October 2023 Admin talk contribs created page How to Delete A Table That has many Without Deleting Children (Created page with " If you have a table that you are trying to delete and the table contains a has_many relationship, you may get an error similar to the one below when you attempt to delete the parent table. ===Error=== <source> constraint error when attempting to delete struct: * item_id_fkey (foreign_key_constraint) If you would like to stop this constraint violation from raising an exception and instead add it as an error to your changeset, please call `foreign_key_constraint/3`...")
- 18:59, 18 October 2023 Admin talk contribs created page Working Example of Phoenix Built in Form Component (Created page with " <source> defmodule AppWeb.PageLive do use AppWeb, :live_view def mount(_params, _session, socket) do {:ok, assign(socket, form: to_form(%{}, as: :my_form))} end def handle_event("save", params, socket) do {:noreply, socket} end def render(assigns) do ~H""" <.form for={@form} phx-change="validate" phx-submit="save"> <.input type="text" field={@form[:username]} /> <.input type="email" field={@form[:email]} />...")
- 16:18, 16 October 2023 Admin talk contribs created page How to Use phx-change with a Select Element in Phoenix (Created page with " Example: Render <source> defmodule AppWeb.GroupLive do use AppWeb, :live_view alias App.TestBeds alias App.Groups def mount(_params, _session, socket) do {:ok, assign(socket, testbeds: TestBeds.list_testbeds(), groups: Groups.list_groups())} end def handle_event("select-group", params, socket) do IO.inspect params {:noreply, socket} end def render(assigns) do ~H""" <div> TestBed Name</div> <%= for testbed <- @...")
- 13:10, 13 October 2023 Admin talk contribs created page How to Create an Empty Phoenix Application (Created page with "'''Before You Begin''' {{Phoenix-Installation-Required}} ==What you will do== * Create a new Phoenix application instance ==Create the App== Select a directory, open a terminal and type: <syntaxhighlight> mix phx.new app </syntaxhighlight> This creates a new phoenix application named "app". The terminal will prompt you to download dependencies, select Y for yes. When dependency downloading is complete, you have the choice to connect your app to a database usin...")
- 13:04, 13 October 2023 Admin talk contribs moved page Forms and Event Handlers in Elixir Phoenix to Forms and Event Handlers in Elixir Phoenix Liveview
- 11:39, 13 October 2023 Admin talk contribs moved page How to Understand Forms and Changesets to Understanding Forms and Changesets
- 11:34, 13 October 2023 Admin talk contribs created page How to Understand Forms and Changesets (Created page with "{{In_progress}} In this tutorial you seed database and Ecto "Context" data. You then write controllers and forms while learning how changesets work.")
- 10:24, 13 October 2023 Admin talk contribs created page How to Use Code Generators to Create an App in Phoenix (Created page with "{{In_progress}} ==Create Context== To create Table Data, Schema and Model information you can use this code. The example below creates the database table and the Elixir/Ecto functions needed to interact with it. This code does ''not'' create any HTML, Route or Controller data. <source> mix phx.gen.context Items Item items name:string </source> '''According to the official docs:''' Generates a context with functions around an Ecto schema. <source> mix phx.gen.co...")
- 09:23, 13 October 2023 Admin talk contribs created page How to Create Default Parameters/Arguments for a Function (Created page with " The two backslash characters are used to create default parameters/arguments in a function. <source> def x(item \\ %{})do item # default argument of %{} end </source>")