Skip to content

Instantly share code, notes, and snippets.

Avatar
😱
Oh well

Irakli Gozalishvili Gozala

😱
Oh well
View GitHub Profile
@Gozala
Gozala / Readme.md
Last active Jul 21, 2022
Range hilighting code using getClientRects API
View Readme.md

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
@Gozala
Gozala / git-gpg.md
Created Apr 12, 2016 — forked from bcomnes/git-gpg.md
my version of gpg on the mac
View git-gpg.md
  1. brew install gnupg21, pinentry-mac (this includes gpg-agent and pinentry)
  2. Generate a key: $ gpg --gen-key
  3. Take the defaults. Whatevs
  4. Tell gpg-agent to use pinentry-mac:
$ vim ~/.gnupg/gpg-agent.conf 
View tab-events.js
"use strict";
const { addObserver, notifyObservers } = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const { getEnumerator } = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
const isBrowser = window => {
try {
return window.document.documentElement.getAttribute("windowtype") === "navigator:browser";
View fail.log
1) ipfs --upgrade-cidv0-in-output=true add --chunker=rabin-262141 --trickle=false --raw-leaves=false --cid-version=0 ../testdata/large_repeat_1GiB.zst
2) ipfs add --chunker=rabin-262141 --trickle=false --raw-leaves=false --cid-version=1 ../testdata/large_repeat_1GiB.zst
3) ipfs --upgrade-cidv0-in-output=true add --chunker=rabin-262141 --trickle=false --raw-leaves=true --cid-version=0 ../testdata/large_repeat_1GiB.zst
4) ipfs add --chunker=rabin-262141 --trickle=false --raw-leaves=true --cid-version=1 ../testdata/large_repeat_1GiB.zst
5) ipfs --upgrade-cidv0-in-output=true add --chunker=size-65535 --trickle=true --raw-leaves=false --cid-version=0 ../testdata/large_repeat_1GiB.zst
6) ipfs add --chunker=size-65535 --trickle=true --raw-leaves=false --cid-version=1 ../testdata/large_repeat_1GiB.zst
7) jsipfs add --chunker=size-65535 --trickle=true --raw-leaves=false --cid-version=1 ../testdata/large_repeat_1GiB.zst
8) ipfs --upgrade-cidv0-in-output=true add --chunker=size-262144 --trickle=true --raw-leaves=false -
@Gozala
Gozala / unixfs.ts
Created Jan 31, 2022
Attempt to define more clearly unixfs encoding
View unixfs.ts
import type { CID } from 'multiformats'
/**
* Logical representation of a raw chunk of a file.
*
* TODO: Clarify when represenation is used instead of `FileChunk`
* representation.
*/
export interface Raw extends PBNode {
Data: ByteView<{
@Gozala
Gozala / api.v0.ts
Last active Jan 6, 2022
Sketch of unixfs-importer API
View api.v0.ts
import type { CID} from "multiformats"
import { Mtime } from "ipfs-unixfs"
export interface Lib {
/**
* Creates a directory importer that can be used to build up directory of
* files. It takes an optional queuing strategy parameter that can be used
* to specify how how many blocks can be queue internally before backpressure
* is applied and writer is blocked. This allows users to specify how much
View demo.js
import { loop, recur } from './loop.js'
export const factorial = (n) => loop((n, acc) => n <= 1 ? acc : recur(n - 1, n * acc), n, 1)
@Gozala
Gozala / example.js
Created Jan 29, 2012
Workaround for lack of "tail call optimization" in JS
View example.js
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround
@Gozala
Gozala / go.js
Created Oct 31, 2013
Go routines for JS
View go.js
// Utility function for detecting generators.
let isGenerator = x => {
return Function.isGenerator &&
Function.isGenerator.call(x)
}
// Data type represents channel into which values
// can be `put`, or `received` from. Channel is
// very much like queue where reads and writes are
// synchronized via continuation passing.
View Focus.elm
module Focus exposing (Model, init, update, onFocus, onBlur, focus, blur) where
import Ref
import Native.Focus
import Html
import Html.Attributes
import Html.Events
type alias Model =
{ ref: Ref.Ref