Application.put_env(:sample, Example.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
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
| <!-- livebook:{"persist_outputs":true} --> | |
| # Distribute | |
| ## Section | |
| A small toy to show how you might, given a stream, do a "fan out", processing different elements in separate streams. Powered by simple primitives like `Stream.resource` and `spawn_link`. | |
| ```elixir | |
| defmodule Distribute 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
| // 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
| // You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
| (() => { | |
| const SHOW_SIDES = false; // color sides of DOM nodes? | |
| const COLOR_SURFACE = true; // color tops of DOM nodes? | |
| const COLOR_RANDOM = false; // randomise color? | |
| const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
| const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
| const THICKNESS = 20; // thickness of layers | |
| const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |
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 MarkdownConverter do | |
| import Phoenix.Component | |
| def convert(filepath, body, _attrs, opts) do | |
| convert_body(Path.extname(filepath), body, opts) | |
| end | |
| defp convert_body(extname, body, opts) when extname in [".md", ".markdown", ".livemd"] do | |
| html = | |
| Earmark.as_ast!(body, annotations: "%%") |
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
| import { FormError } from '$lib/errors.js'; | |
| import { db } from '$lib/server/db.js'; | |
| import { GROUP_QUERY } from '$lib/server/queries/group.query.js'; | |
| import { | |
| expenses_table, | |
| group_members_table, | |
| ledger_table, | |
| users_table, | |
| } from '$lib/server/schema.js'; | |
| import { listify_names, sum_arr } from '$lib/utils.js'; |
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
| FROM golang:1.21.0-bullseye as builder | |
| COPY . /workdir | |
| WORKDIR /workdir | |
| ENV CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all" | |
| ENV GOFLAGS="-buildmode=pie" | |
| RUN go build -ldflags "-s -w" -trimpath ./cmd/app |
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 PentoWeb.UploadLive do | |
| use PentoWeb, :live_view | |
| # @bytes_for_5MB 5_242_880 | |
| @bytes_for_5MB 1_000_000 | |
| @impl Phoenix.LiveView | |
| def mount(_params, _session, socket) do | |
| socket = | |
| 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 TravelerWeb.SearchbarLive do | |
| use TravelerWeb, :live_view | |
| alias Phoenix.LiveView.JS | |
| alias Traveler.Places | |
| def mount(_params, _session, socket) do | |
| socket = assign(socket, places: []) | |
| {:ok, socket, layout: false} | |
| end |