Skip to content

Instantly share code, notes, and snippets.

View slava-vishnyakov's full-sized avatar

Slava Vishnyakov slava-vishnyakov

View GitHub Profile
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active May 7, 2024 04:49
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@slava-vishnyakov
slava-vishnyakov / add-docker-compose-to-phoenix
Created April 22, 2023 11:39
Adds docker-compose.yml and package.json to Phoenix app with postgres exposed on random port
#!/bin/bash
# Generate random ports
postgres_port=$((5000 + RANDOM % 1000))
redis_port=$((7000 + RANDOM % 1000))
elastic_port=$((9000 + RANDOM % 1000))
# Set test ports
postgres_test_port=$((postgres_port + 1))
redis_test_port=$((redis_port + 1))