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 / content-pinning.js
Last active November 6, 2020 10:52
Content Pinning
class Model {
constructor(isShiftPressed=false, marker=null, selection=null) {
this.isShiftPressed = isShiftPressed
this.marker = marker
this.selection = selection
this.tasks = []
}
clone() {
const instance = new this.constructor()
Object.keys(this).forEach(key => instance[key] = this[key])
/**
* @template T, X, A
* @typedef {import('./protocol').Process<T, X, A>} Process
*/
/**
* @template X, T
* @typedef {import('./protocol').Task<X, T>} Task
*/
interface CID {
code: number
version: number
multihash: Uint8Array
bytes: Uint8Array
}
type Future<T> =
| T
| Promise<T>
@Gozala
Gozala / Readme.md
Created April 2, 2020 19:08
Reproducible test case

This is illustrating issue with vscode

use async_std::task;
use juniper::{EmptyMutation, RootNode};
struct Concrete;
enum CustomName {
Concrete(Concrete),
}
#[juniper::graphql_object]
type Tag {
id:ID
name: String! @fake(type:word)
}
type InlineLink {
id:ID
to:Resource!
name:String @examples(values: ["automerge", "pushpin", "local-first", "farm"])
description:String @fake(type:words)
@Gozala
Gozala / Readme.md
Last active March 19, 2020 15:09
WTF Flow ?

WTF Flow

[Flow][] static type checker is a wonderful attempt to bring [algebric data types][] to JS. It is still fairly new project and there for has few WTFs that can pull you down the rabbit hole. This document is attempt to document things that may seem like a WTF from the perspective of JS developer who tries to employ static type checker, or in other words, some items on the list may be very subjective & based on the background of the writer.

Polymorphic type that is a function

It is very likely that one will wind up using [Polymorphic functions][] to solve a more general problem. And if you define type alias for such a function you may be puzzled what is the right syntax should be used for such type definition.

Let's start with:

@Gozala
Gozala / hypermerge.ts
Created February 20, 2020 07:25
Attempt to revist hypermerge interface
type DocID<a> = string
type Doc<a> = a
interface RepoService {
keys: KeyService
create<a>(doc: Doc<a>): Promise<DocID<a>>
read<a>(id: DocID<a>): Promise<a>
change<a>(id: DocID<a>, change: (doc: a) => void): Promise<void>
watch<a>(id: DocID<a>): AsyncIterator<a>
@Gozala
Gozala / javascript_background_thread.js
Created September 19, 2012 01:53 — forked from jameswomack/javascript_background_thread.js
Extend function prototype to run a function as a WebWorker
Function.prototype.runOnBackgroundThread = function (aCallback) {
var _blob = new Blob(['onmessage = '+this.toString()],{"type":"text/javascript"});
var _worker = new Worker((webkitURL.createObjectURL || URL.createObjectURL)(_blob));
_worker.onmessage = aCallback;
_worker.postMessage();
}
var _test = function () {
postMessage((1+1).toString());
}
@Gozala
Gozala / html_iframe.js
Last active July 29, 2019 07:01
nesting frames
// Security Error: Content at about:srcdoc may not load or link to resource://jid1-pss5nuwzdn1n3a-at-jetpack/signals/data/index.html.
let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let HTML_NS = "http://www.w3.org/1999/xhtml";
let toolbar = document.createElementNS(XUL_NS, "toolbar");
toolbar.setAttribute("collapsed", false);
toolbar.setAttribute("style", "height: 80px;");
let toolbox = document.getElementById("navigator-toolbox");