Skip to content

Instantly share code, notes, and snippets.

@mazz
mazz / app.js
Created Jul 23, 2022 — forked from goofansu/app.js
LiveView upload directly to AWS China S3
View app.js
let Uploaders = {}
Uploaders.S3 = function (entries, onViewError) {
entries.forEach(entry => {
let xhr = new XMLHttpRequest()
onViewError(() => xhr.abort())
xhr.onload = () => (xhr.status === 200 ? entry.done() : entry.error())
xhr.onerror = () => entry.error()
xhr.upload.addEventListener("progress", event => {
if (event.lengthComputable) {
View simple_s3_upload.ex
defmodule SimpleS3Upload do
@moduledoc """
Dependency-free S3 Form Upload using HTTP POST sigv4
https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
"""
@doc """
Signs a form upload.
The configuration is a map which must contain the following keys:
* `:region` - The AWS region, such as "us-east-1"
View remove-all-from-docker.sh
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@mazz
mazz / king_james_bible_verses.csv
Created Mar 18, 2022
king james bible verses.csv
View king_james_bible_verses.csv
We can't make this file beautiful and searchable because it's too large.
id,verse_number,verse_text,verse_ordinal,chapter_number,book_name,book_ordinal,testament,inserted_at,updated_at
3c94a2e3-79f6-4f1c-b3d0-449ebdafff21,1,"Now it came to pass in the days when the judges ruled, that there was a famine in the land. And a certain man of Bethlehemjudah went to sojourn in the country of Moab, he, and his wife, and his two sons.",7129,1,Ruth,8,old,2022-03-18 12:05:15.599759,2022-03-18 12:05:15.599759
952f5809-fa27-4290-bf15-df1163804b98,2,"And the name of the man was Elimelech, and the name of his wife Naomi, and the name of his two sons Mahlon and Chilion, Ephrathites of Bethlehemjudah. And they came into the country of Moab, and continued there.",7130,1,Ruth,8,old,2022-03-18 12:05:15.60342,2022-03-18 12:05:15.60342
edffd9dc-9cbe-4700-9cb9-55b332e068a9,3,"And Elimelech Naomi’s husband died; and she was left, and her two sons.",7131,1,Ruth,8,old,2022-03-18 12:05:15.606126,2022-03-18 12:05:15.606126
@mazz
mazz / ContentView.swift
Last active Feb 24, 2022
Index out of range
View ContentView.swift
import SwiftUI
import os.log
struct ContentView: View {
@StateObject var viewModel: ImageGalleryViewModel = ImageGalleryViewModel()
var body: some View {
ZStack {
TabView {
View vm.swift
struct SectionModel: Identifiable {
public var id: String
public var index: Int
public var title: String
public var subtotal: String
public var items: [MarkItemModel]
public var commentItems: [MarkItemModel]
}
struct MarkItemModel: Identifiable {
View HomeView.swift
//
// HomeView.swift
// Markably
//
// Created by Michael on 2021-07-17.
//
import SwiftUI
struct HomeView: View {
View Dockerfile
# STEP 1 - BUILD RELEASE
# cannot use alpine 3.14.0 because of issue here with bcrypt-elxir compiling using make on docker:
# https://github.com/riverrun/bcrypt_elixir/issues/26#issuecomment-881966412
FROM hexpm/elixir:1.12.3-erlang-24.0.6-alpine-3.13.5 AS build
# install build dependencies
RUN apk add --update git \
build-base \
ffmpeg \
--update npm
View app.css
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "./phoenix.css";
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");
.hidden {
View gist:3906276dbdb8e42aa7c25bd09223ae2e
# STEP 1 - BUILD RELEASE
# cannot use alpine 3.14.0 because of issue here with bcrypt-elxir compiling using make on docker:
# https://github.com/riverrun/bcrypt_elixir/issues/26#issuecomment-881966412
FROM hexpm/elixir:1.12.3-erlang-24.0.6-alpine-3.13.5 AS build
# install build dependencies
RUN apk add --update git \
build-base \
nodejs-current \
nodejs-npm \