Skip to content

Instantly share code, notes, and snippets.

View indutny's full-sized avatar
🐋
Thanks for the fish!

Fedor Indutny indutny

🐋
Thanks for the fish!
View GitHub Profile
/*
* def.js: Простое наследование в стиле Ruby для Javascript
*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(global) {
// Используется, чтобы сохранить суперкласс и "плагины" ля
// дальнейшего использования
@indutny
indutny / fts5-merging-algorithm.md
Last active February 3, 2023 05:42
Notes on FTS5 Merging Algorithm

Inserting new values

fts5FlushOneHash controls this and it puts a new segment on level 0, and then calls:

  1. fts5StructurePromote for level 0
  2. fts5IndexAutomerge
  3. fts5IndexCrisismerge

Level promotion

@indutny
indutny / 00-fts5-crash-repro.sql
Last active February 3, 2023 05:30
Relatively Small Repro for Crashing FTS5 in Sqlite
CREATE VIRTUAL TABLE x USING fts5(content);
INSERT INTO x(x, rank) VALUES('pgsz', 32);
# Repeat next three lines 2000 times
INSERT INTO x(content) VALUES('hello world');
INSERT INTO x(content) VALUES('how are you');
INSERT INTO x(x, rank) VALUES('optimize', 1);
# If you repeat them less - you can below to see
# what's actually going in the FTS5 index.
@indutny
indutny / bench.js
Created January 25, 2023 06:50
V8 Benchmark for Intl.Segmenter#segment() improvements
const s = new Intl.Segmenter();
const input = 'a'.repeat(100 * 1024);
console.time('segment');
for (const _ of s.segment(input)) {}
console.timeEnd('segment');
@indutny
indutny / ExeLDR.asm
Created December 31, 2010 22:31
Loader for MSDOS EXE files, without MSDOS
;Made by FeDOS (FeDOS SubSystems)
;All Rights Reserved
;FeDOS (ICQ 313-997-813)
[BITS 16]
[ORG 0x0000]
__start:
; mov cx, 0xB800
; mov es, cx
; mov bx, 0h
; mov cx, cs
@indutny
indutny / baumgarte-2.32.ipynb
Created May 19, 2020 17:23
baumgarte-2.32.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@indutny
indutny / 00-totp.js
Last active February 28, 2020 17:24
TOTP collisions
const { authenticator, hotp } = require('otplib');
const SECRET = authenticator.generateSecret();
const map = new Map();
const TOTAL = 100000;
const MAX_DIFFERENT = 1000000;
const STEP = 30;
const OFFSET = (Date.now() / 1000 / STEP) | 0;
!function() {
// Don't forget to scroll all the way down to load all replies!
const elems = document.body.querySelectorAll(
'div.original-permalink-page ' +
'li.ThreadedConversation:not(.ThreadedConversation--selfThread),' +
'li.ThreadedConversation--loneTweet');
for (const elem of elems) {
elem.style.border = '2px solid green';
'use strict';
// Quiz:
//
// Implement `solution` function using only calls to API methods below and no
// other JS primitives (even math).
//
// Correct implementation will print "Success!" once executed
//
@indutny
indutny / crypto-browserify.svg
Last active July 4, 2017 19:13
crypto-browserify CommonJS dependency graph.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.