Skip to content

Instantly share code, notes, and snippets.

def presign_upload(entry, socket) do
uploads = socket.assigns.uploads
bucket = FaithfulWord.config([:s3, :bucket])
dbg(socket.assigns.upload_path_prefix)
## HACK to generate dir path on s3 by uploading an empty .gitkeep file
## this must be done before the upload occurs
# gitkeep_file = File.read!("gitkeep")
@mazz
mazz / user_channel.ex
Created March 21, 2024 03:35
user channel
defmodule MarkablyWeb.UserChannel do
use Phoenix.Channel, hibernate_after: :infinity
alias Phoenix.Socket.Broadcast
alias Markably.Pipeline.Timing
@impl true
def join("user:" <> user_id, _payload, socket) do
dbg("join MarkablyWeb.UserChannel")
dbg(user_id)
@mazz
mazz / logtrace.log
Last active February 6, 2024 21:34
passwordless_auth_live.ex
defp handle_validation(socket, {:ok, _user_pin}) do
Accounts.UserPin.purge_pins(socket.assigns.auth_user)
sign_in_token =
socket.assigns.auth_user
|> Accounts.generate_user_session_token()
|> Base.encode64()
# sign_in_token is still valid up to here
dbg(sign_in_token)
[watch] build finished, watching for changes...
Rebuilding...
Done in 911ms.
[debug] Upgrading connection to websocket
[debug] Shard connection up, waiting for consumers to boot
[error] ** State machine <0.715.0> terminating
** Last event = {info,{gun_upgrade,<0.735.0>,
#Ref<0.3877279376.554958849.24784>,
[error] ** State machine <0.715.0> terminating
** Last event = {state_timeout,connect_timeout}
** When server state = {connecting_http,
#{stream => nil,seq => nil,
'__struct__' => 'Elixir.Nostrum.Struct.WSState',
session => nil,conn => <0.720.0>,
gateway => <<"gateway.discord.gg">>,
last_heartbeat_ack => nil,
last_heartbeat_send => nil,
heartbeat_interval => nil,shard_num => 0,
defmodule Word.Repo.Migrations.CreateMusic do
use Ecto.Migration
def change do
execute "CREATE EXTENSION IF NOT EXISTS citext", ""
create table(:music, primary_key: false) do
add :id, :id, primary_key: true
add :absolute_id, :integer
add :uuid, :uuid
import SwiftUI
import LNPopupUI
import LNPopupController
import Combine
import KSPlayer
struct BlurView: UIViewRepresentable {
var style: UIBlurEffect.Style = .systemMaterial
func makeUIView(context: Context) -> UIVisualEffectView {
return UIVisualEffectView(effect: UIBlurEffect(style: style))
defmodule MyApp.Multimedia.ProgressTrack do
use MyApp.Schema
import Ecto.Changeset
import Ecto.Query
import Ecto.Changeset
alias MyApp.Repo
schema "progress_track" do
# field(:video_id, :integer)
@mazz
mazz / vidstack-hook.js
Created June 8, 2023 05:29
vidstack-hook.js
/*
Docs: https://hexdocs.pm/phoenix_live_view/js-interop.html#client-hooks
Usage: when using phx-hook, a unique DOM ID must always be set.
<div phx-hook="ExampleHook" id="someUniqueId"></div>
*/
// import 'vidstack/styles/defaults.css'
// import 'vidstack/styles/community-skin/video.css'
@mazz
mazz / channel.ex
Created May 28, 2023 14:58
channel.ex
@required_fields [
:name,
:org_id,
:owner_id,
:channel_category_id,
:slug,
:item_ids
]
@optional_fields [:visibility, :ordinality, :slug, :poster_path, :description, :content_type]