Skip to content

Instantly share code, notes, and snippets.

View Gozala's full-sized avatar
😱
Oh well

Irakli Gozalishvili Gozala

😱
Oh well
View GitHub Profile
@Gozala
Gozala / derp-modules.js
Created October 11, 2012 08:56 — forked from gordonbrander/derp-modules.js
Simple, tiny, dumb JavaScript Modules
(function(exports) {
// Simple, tiny, dumb module definitions for Browser JavaScript.
//
// What it does:
//
// * Tiny enough to include anywhere. Intended as a shim for delivering
// browser builds of your library to folks who don't want to use script loaders.
// * Exports modules to `__modules__`, a namespace on the global object.
// This is an improvement over typical browser code, which pollutes the
// global object.
@Gozala
Gozala / work.clj
Created April 11, 2024 18:35
Sketch of the workflow syntax
;; Type definition for the Blob. It has no inputs and two outputs
; `digest` and `size`. It is kind of like a rule without a body
(Blob : { :digest Bytes :size Int })
(Site : { :url String :headers (Map :key string :value string) })
;; ℹ️ Unlabelled parameter can be refereced by `.`
(Result :error : (:ok . :error .error))
;; Composed task is rule that maps input to tasks and maps task outputs
;; to the output of the composed task
(Multihash : Bytes)
(Blob : {:size Integer :digest Multihash })
(blob/add
:input {:sub DID :blob Blob }
:address (memory/allocate
:space .input.sub
:blob .input.blob)
:content (http/put
:url .address.out.ok.url
stateDiagram-v2
  add: πŸ‘©β€πŸ’» /space/content/add/blob πŸ€–
  add: 🧾 { ok {} }

  allocate: πŸ€– /service/blob/allocate πŸ€–
  allocate: 🧾 { ok { size 123 } }

  wait: πŸ€– /service/blob/receive πŸ€–
 wait: 🧾 { ok {} } 
flowchart LR
    Add[πŸ‘©β€πŸ’» store/add πŸ€–]
    Allocate[πŸ€– blob/allocate πŸ€–]
    Receive[πŸ€– blob/receive πŸ€–]
    Write[πŸ€– blob/write πŸ‘©β€πŸ’»]
    Close[πŸ€– blob/close πŸ€–]
    Claim[πŸ€– assert/location 🌐]

 Add --> Allocate
interface Account {
plan: AccountPlan
// ...
}
interface AccountPlan {
customer: AccountDID
request(): Plan
list(): Plan[]
interface Account {
subscriptions: AccountSubscriptions
// ...
}
interface AccountSubscriptions {
customer: AccountDID
request(): Subscription
list(): Subscription[]
@Gozala
Gozala / db.js
Last active December 14, 2023 19:34
import * as API from '@ucanto/interface'
/**
* @typedef {number} Integer
* @typedef {number} Float
* @typedef {Readonly<Uint8Array>} Bytes
* @typedef {string} UTF8
*
* @typedef {String} Entity
* @typedef {Integer|Float|Bytes|UTF8} Attribute
@Gozala
Gozala / Readme.md
Last active June 8, 2023 07:31
Range hilighting code using getClientRects API

Highlight Selection Ranges

Code here takes a DOM Selection Range instance and creates a highlighting for it by using getClientRects. Approach was inspired by marks although here function attempts to find nearest positioned parent element to the commonAncestorContainer and draw all the highilighting rectangles there, this avoids issues with an overflowing content.

Issues

  • Approach ignores z-index which isn't great as some element might be overlaying the selection in which case it should not appear, but it does if we use high z-index value. If we use low z-index value then some elements (possibly ones containing selection) might end up overlaying selection itself.
  • Rendered selections are scattered all o
type ProviderDID =
| "did:web:web.storage"
| "did:web:nft.storage"
interface Principal {
did(): string
}
interface Space extends Principal {