User contributions for Admin
5 August 2024
- 15:4515:45, 5 August 2024 diff hist +12 Postgres Setup No edit summary current
- 15:4515:45, 5 August 2024 diff hist +308 N 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."
17 July 2024
- 22:5422:54, 17 July 2024 diff hist +62 N How to Inspect the State of a GenServer From Console Created page with "<source> :sys.get_state(pid) # pid of GenServer </source>" current
13 July 2024
- 05:4405:44, 13 July 2024 diff hist +376 Elixir Todo List Exercise No edit summary current
12 July 2024
- 02:3802:38, 12 July 2024 diff hist +417 Elixir Todo List Exercise No edit summary
- 01:4601:46, 12 July 2024 diff hist +1,043 N 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..."
30 June 2024
- 06:2106:21, 30 June 2024 diff hist +2,397 N 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..." current
- 05:5005:50, 30 June 2024 diff hist +50 N How to View All Running Applications Created page with "<source> :application.which_applications </source>" current
29 June 2024
- 05:0705:07, 29 June 2024 diff hist +2,474 N 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..." current
21 June 2024
- 20:5620:56, 21 June 2024 diff hist −24 User:Admin No edit summary
- 20:1420:14, 21 June 2024 diff hist +1,172 User:Admin No edit summary
20 June 2024
- 19:4419:44, 20 June 2024 diff hist +669 N 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}:..." current
17 June 2024
- 16:3416:34, 17 June 2024 diff hist −7 User:Admin No edit summary
- 16:2416:24, 17 June 2024 diff hist +1,020 User:Admin No edit summary
- 15:1115:11, 17 June 2024 diff hist +31 User:Admin No edit summary
13 June 2024
- 17:1117:11, 13 June 2024 diff hist +111 How to Upload Files Using Post Controller No edit summary current
- 17:1017:10, 13 June 2024 diff hist −9 How to Upload Files Using Post Controller No edit summary
- 17:1017:10, 13 June 2024 diff hist +904 N 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..."
12 June 2024
- 20:1620:16, 12 June 2024 diff hist +200 How to Upload Files to Phoenix No edit summary current
11 June 2024
- 20:2720:27, 11 June 2024 diff hist +308 Elixir Phoenix SSH No edit summary current
- 17:4417:44, 11 June 2024 diff hist +1,274 N 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..." current
- 01:4601:46, 11 June 2024 diff hist +548 N 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..." current
10 June 2024
- 19:3619:36, 10 June 2024 diff hist +86 N Kill Hanging Process on Linux Created page with "Use the command "top" to view top hanging process. sudo kill -9 pid_number_of_process" current
- 18:4818:48, 10 June 2024 diff hist −4 How to Capture Text of Items When Clicked No edit summary current
- 18:4018:40, 10 June 2024 diff hist +652 N 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:1215:12, 10 June 2024 diff hist +361 N 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>" current
- 01:4801:48, 10 June 2024 diff hist +66 N Phoenix Live View Redirect Created page with "<source> {:noreply, redirect(socket, to: "/download")} </source>" current
9 June 2024
- 15:1615:16, 9 June 2024 diff hist +625 User:Admin No edit summary
- 15:1515:15, 9 June 2024 diff hist +6 Elixir Phoenix SSH No edit summary
- 15:1515:15, 9 June 2024 diff hist +548 N 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..."
8 June 2024
- 23:5223:52, 8 June 2024 diff hist +189 How to Upload Files to Phoenix No edit summary
6 June 2024
- 18:2618:26, 6 June 2024 diff hist +23 How to Upload Files to Phoenix No edit summary
- 18:1518:15, 6 June 2024 diff hist +2,408 N 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..."
5 June 2024
- 15:5115:51, 5 June 2024 diff hist +272 N 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>" current
24 May 2024
- 14:3914:39, 24 May 2024 diff hist +242 User:Admin No edit summary
2 May 2024
- 16:4216:42, 2 May 2024 diff hist +90 N 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>" current
29 April 2024
- 10:1610:16, 29 April 2024 diff hist +279 N 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>" current
25 April 2024
- 20:1920:19, 25 April 2024 diff hist +63 N Phoenix CORS (Cross Origin Resource Sharing) Created page with "https://victorbjorklund.com/cors-error-phoenix-elixir-cors-plug" current
19 April 2024
- 17:3617:36, 19 April 2024 diff hist +107 User:Admin No edit summary
18 April 2024
- 20:1220:12, 18 April 2024 diff hist +48 User:Admin No edit summary
- 18:1218:12, 18 April 2024 diff hist +679 User:Admin No edit summary
- 18:0718:07, 18 April 2024 diff hist −72 User:Admin No edit summary
- 18:0718:07, 18 April 2024 diff hist +375 User:Admin No edit summary
- 18:0518:05, 18 April 2024 diff hist +688 User:Admin No edit summary
5 April 2024
- 16:1216:12, 5 April 2024 diff hist +57 How to Generate a UML Block Diagram of Ecto Database No edit summary current
- 16:0916:09, 5 April 2024 diff hist +145 N 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"
16 March 2024
- 04:4304:43, 16 March 2024 diff hist +11 Understanding Forms and Changesets No edit summary
15 March 2024
- 01:1601:16, 15 March 2024 diff hist +817 Understanding Forms and Changesets No edit summary
- 01:1201:12, 15 March 2024 diff hist +53 Understanding Forms and Changesets No edit summary
- 01:0701:07, 15 March 2024 diff hist +179 Understanding Forms and Changesets No edit summary