User contributions for Admin

Jump to: navigation, search
Search for contributionsExpandCollapse
⧼contribs-top⧽
⧼contribs-date⧽
(newest | oldest) View ( | ) (20 | 50 | 100 | 250 | 500)

5 August 2024

  • 15:4515:45, 5 August 2024 diff hist +12 Postgres SetupNo edit summary current
  • 15:4515:45, 5 August 2024 diff hist +308 N Postgres SetupCreated 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

13 July 2024

12 July 2024

  • 02:3802:38, 12 July 2024 diff hist +417 Elixir Todo List ExerciseNo edit summary
  • 01:4601:46, 12 July 2024 diff hist +1,043 N Elixir Todo List ExerciseCreated 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 GenserverCreated 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 ApplicationsCreated 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 AssignsCreated 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 June 2024

  • 19:4419:44, 20 June 2024 diff hist +669 N Compare Identical FilesCreated 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

13 June 2024

12 June 2024

11 June 2024

  • 20:2720:27, 11 June 2024 diff hist +308 Elixir Phoenix SSHNo 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 MachineCreated 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 FunctionsCreated 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

9 June 2024

  • 15:1615:16, 9 June 2024 diff hist +625 User:AdminNo edit summary
  • 15:1515:15, 9 June 2024 diff hist +6 Elixir Phoenix SSHNo edit summary
  • 15:1515:15, 9 June 2024 diff hist +548 N Elixir Phoenix SSHCreated 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

6 June 2024

  • 18:2618:26, 6 June 2024 diff hist +23 How to Upload Files to PhoenixNo edit summary
  • 18:1518:15, 6 June 2024 diff hist +2,408 N How to Upload Files to PhoenixCreated 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 PhoenixCreated 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

2 May 2024

29 April 2024

  • 10:1610:16, 29 April 2024 diff hist +279 N Non-Blocking Error Check ExampleCreated 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

19 April 2024

18 April 2024

5 April 2024

16 March 2024

15 March 2024

(newest | oldest) View ( | ) (20 | 50 | 100 | 250 | 500)