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
// Type assertion utility to ensure one type is a subset of another | |
type Assert<T, U extends T> = U; | |
// Helper type to make all nested properties partial recursively | |
type DeepPartial<T> = { | |
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; | |
}; |
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
// ==UserScript== | |
// @name Toggle with keyboard - sudoku.com | |
// @namespace Violentmonkey Scripts | |
// @match https://sudoku.com/* | |
// @grant none | |
// @version 1.2 | |
// @author rid9 | |
// @description 6/19/2022, 7:21:19 PM | |
// ==/UserScript== |
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
def create(attrs \\ %{}) do | |
%Message{} | |
|> changeset(attrs) | |
|> Repo.insert() | |
|> broadcast(:message_created) | |
end | |
def subscribe do | |
Phoenix.PubSub.subscribe(Chatter.PubSub, "messages") | |
end |
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
@impl true | |
def mount(_params, _session, socket) do | |
message_list = Message.get_latest(100, "default") | |
socket = | |
socket | |
|> assign(message_list: message_list) | |
|> assign(message: %Message{}) | |
|> assign(changeset: Message.changeset(%Message{}, %{})) |
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 ChatterWeb.PageLive do | |
use ChatterWeb, :live_view | |
alias Chatter.Chatroom.Message | |
@impl true | |
def mount(_params, _session, socket) do | |
message_list = Message.get_latest(100, "default") | |
socket = socket |> assign(message_list: message_list) | |
{:ok, socket} |
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 Chatter.Chatroom.Message do | |
use Ecto.Schema | |
import Ecto.Changeset | |
import Ecto.Query, only: [from: 2] | |
alias Chatter.Chatroom.Message | |
alias Chatter.Repo | |
@primary_key {:id, :binary_id, autogenerate: true} | |
@foreign_key_type :binary_id | |
schema "messages" do |
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 Chatter.Chatroom.Message do | |
use Ecto.Schema | |
import Ecto.Changeset | |
import Ecto.Query, only: [from: 2] | |
alias Chatter.Chatroom.Message | |
alias Chatter.Repo | |
@primary_key {:id, :binary_id, autogenerate: true} | |
@foreign_key_type :binary_id | |
schema "messages" do |