Skip to content

Instantly share code, notes, and snippets.

View bcardarella's full-sized avatar
Out sailing

Brian Cardarella bcardarella

Out sailing
View GitHub Profile
defmodule Task do
defp await_one(tasks, timeout \\ 5_000) when is_list(tasks) do
awaiting =
Map.new(tasks, fn %Task{ref: ref, owner: owner} = task ->
if owner != self() do
raise ArgumentError, invalid_owner_error(task)
end
{ref, true}
end)
import SwiftUI
import LiveViewNative
@LiveElement
struct WebView<Root: RootRegistry>: View {
var body: some View {
WebView(url: URL(string: "http://example.net")).ignoresSafeArea()
}
}
@bcardarella
bcardarella / vml-swiftui.md
Last active September 3, 2025 17:17
VML - SwiftUI

View Markup Language (VML) Specification - SwiftUI

Version 1.0-alpha.1

1. Overview

View Markup Language (VML) is a markup language derived from SGML, designed to represent composable UI frameworks for unidirectional, server-driven rendering. This specification defines the conversion from a server-side view model, such as SwiftUI, to VML.

Specification Note 1.1: Scope The VML specification is concerned exclusively with the structure and rendering of views. It is a unidirectional standard (server-to-client). Mechanisms for handling user interactions, actions, and client-to-server state changes are explicitly outside the scope of this document.

I'd like to vet two scenarios:

  • new Phoenix app
  • existing Phoenix app

Add these deps:

{:live_view_native, github: "liveview-native/live_view_native", branch: "main", override: true},
{:live_view_native_stylesheet, github: "liveview-native/live_view_native_stylesheet", branch: "main", override: true},

reproduce match?

Section

defmodule Foo do

  # stolen from:
  # https://github.com/elixir-lang/elixir/blob/v1.16.3/lib/elixir/lib/kernel.ex#L3401-L3412
  defmacro bar(pattern, expr) do

Section

# The dependency chain is a bit complex, but think of Foo and a

defmodule Lib.Foo do
  defmacro __using__(opts) do
    quote do
      @foo_opts unquote(opts)
 @before_compile Lib.Foo

LiveView Native Livebook

Mix.install(
  [
    {:plug_cowboy, "~> 2.5"},
    {:jason, "~> 1.0"},
    {:phoenix, "~> 1.7.2", override: true},
    {:phoenix_live_view, "~> 0.18.2"},
    {:phoenix_live_reload, "~> 1.4.1", override: true},

Regenerating SSL Cert

cd ssl
rm -rf *
openssl req \
    -newkey rsa:2048 \
    -x509 \
    -nodes \
 -keyout server.key \
** (MatchError) no match of right hand side value: {:error, {{:EXIT, {:undef, [{Comet.ChromeWorker, :start_link, [[name: :"test get object"]], []}, {:supervisor, :do_start_child, 2, [file: 'supervisor.erl',line: 365]}, {:supervisor, :handle_start_child, 2, [file: 'supervisor.erl', line: 724]}, {:supervisor, :handle_call, 3, [file: 'supervisor.erl', line: 422]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 615]}, {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 647]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}, {:child, :undefined, Comet.ChromeWorker, {Comet.ChromeWorker, :start_link, [[name: :"test get object"]]}, :permanent, 5000, :worker, [Comet.ChromeWorker]}}}
upstream phoenix {
server 127.0.0.1:4000;
}
server {
myapp.com
location @phoenix {
include proxy_params;
proxy_redirect off;