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
@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 / 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 / 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 / baumgarte-2.32.ipynb
Created May 19, 2020 17:23
baumgarte-2.32.ipynb
Loading
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@indutny
indutny / info.md
Last active November 22, 2016 05:39
"Xcode - lldb" version correspondence

Thank you for participation, we've managed to find these versions together:

  • xcode 8.2 - 360.1.68
  • xcode 8.1 - 360.1.65
  • xcode 8 - 360.1.50
  • xcode 7.3.1 - 350.0.21
  • xcode 7.3.0 - 350.0.21
  • xcode 7.2 - 340.4.119
  • xcode 7.1 - 340.4.110
  • xcode 7.0 - 340.4.70
@indutny
indutny / 0-HOWTO.md
Last active November 4, 2015 17:29
FLUSH+RELOAD in node.js

How to run this

  1. Take any binary that has OpenSSL functions listed in collect.js
  2. Open lldb /path/to/binary
  3. Do disas -n function-name for each function in collect.js
  4. Choose some offset near the end of the function
  5. Subtract 0x1000000000 to get file offset
  6. Put the number in collect.js
  7. Run node collect.js /path/to/binary | node filter.js > log
  8. Let it run for some time to collect enough information