Skip to content

Instantly share code, notes, and snippets.

@rasjonell
rasjonell / PositionGenerator.kt
Last active October 6, 2023 11:05
Collaborative Position Generator in Kotlin, based on: https://github.com/mweidner037/position-strings
const val LAST_INTERNAL = "~"
class PositionGenerator(private val ID: String) {
companion object {
const val FIRST: String = ""
const val LAST: String = LAST_INTERNAL
}
private val longName: String = ",$ID."
private val firstName: String = "$ID."
@rasjonell
rasjonell / poc-ascii-id.ts
Created July 26, 2023 09:41
POC for short ASCII IDs
type ClientParams = { boardID: number; collaboratorID: string };
/**
* POC of generating short CharIDs per board client. (See the reasoning here: https://miro.atlassian.net/wiki/spaces/PT/pages/3180396935/RFC+Collaborative+Editing+on+Ordered+Sequences#Ways-to-tackle-these-issues%3A)
*
* This algorithm respects the _reserved values_ of the total order generator algorithm on the client.
*
* - Everytime a client connects to the board we generate a ASCII char ID.
* - Everytime a client disconnects from the board, we put their char ID in the `free slots` for recycling.
*
@rasjonell
rasjonell / README.md
Last active February 13, 2023 12:13
Get an embeddable link to PlantUML Diagram Image for MarkDown

PlantUML For Markdown

Installation

  • Download the shell script bellow
  • Make it executable: chmod +x puml-to-md-image.sh

Usage Example

@rasjonell
rasjonell / event_loop.js
Last active December 1, 2022 14:29
Event Loop-like Task Runner with a limit on concurrently running processes
class TaskRunner {
constructor(concurrencyLimit) {
this.count = 0;
this.queue = [];
this.concurrent = concurrencyLimit;
}
add(task) {
const microTask = async () => {
await task();
@rasjonell
rasjonell / authorization.md
Last active September 9, 2022 11:21 — forked from nikneroz/authorization.ex
Elixir + Phoenix Framework 1.3 + Guardian 1.0 + JWT(Refresh, Revoke, Recover) + Comeonin

Elixir + Phoenix Framework 1.3 + Guardian + JWT(Refresh, Revoke, Recover) + Comeonin

User model bootstrap

Let's generate User model and controller.

mix ecto.create # create DB table
mix phx.gen.json Accounts User users email:string password_hash:string # scaffold users structure
@rasjonell
rasjonell / init.vim
Last active July 15, 2022 22:55
My nvim config file
" Plugin setup
call plug#begin()
" Utils
Plug 'seerun/vim-polyglot'
Plug 'jiangmiao/auto-pairs'
Plug 'ap/vim-css-color'
Plug 'preservim/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'karb94/neoscroll.nvim'
Plug 'tpope/vim-surround'