Skip to content

Instantly share code, notes, and snippets.

View w0rd-driven's full-sized avatar
🌴
Chill

Jeremy Brayton w0rd-driven

🌴
Chill
View GitHub Profile
@zachdaniel
zachdaniel / stream_distribute.ex
Last active May 7, 2024 17:20
A small demo 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`. Open in Livebook: https://livebook.dev/run?url=https%3A%2F%2Fgist.github.com%2Fzachdaniel%2Fd5ab06a9d2362fceeb6d27c37b206e28
<!-- 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

LiveView Forms

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)
)
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: "%%")
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';
@MatthewJamesBoyle
MatthewJamesBoyle / DOCKERFILE
Last active March 11, 2024 15:57
production go dockerfile
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
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
@caspg
caspg / 1_searchbar_live.ex
Last active May 2, 2024 12:40
Example of real-time search bar implementation in Phoenix LiveView and Tailwind. Working example on https://travelermap.net/parks/usa
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
@wesbos
wesbos / nuke-bot-tags.js
Created November 29, 2022 19:48
grease monkey script to remove bot tags
// ==UserScript==
// @name Remove Bot Tags
// @version 1
// @grant none
// ==/UserScript==
function nukeEm() {
console.log('Nuke em!');
Array.from(document.querySelectorAll('a[href*="SaveTo"], a[href*="memdotai"]'))
.map(link => {
@staknine
staknine / live_saas_kit_deploy.md
Last active June 9, 2022 14:37
Steps to deploy LiveSaaS Kit on Fly with Phoenix 1.6.9

Here are the steps to update Phoenix Live SaaS Kit for Fly and Phoenix 1.6.9:

Initial Deployment

  1. git init, git add ., git commit -m "init repo"
  2. Remove generated docker & deploy script files
  • build.sh
  • docker-entrypoint.sh
  • .dockerignore
  • Dockerfile