Repro PDF for SumatraPDF: badly encoded text extraction / copy-paste (Russian). Works correctly in pdfium.
Analysis of mupdf/source/pdf/cmaps/UniCNS-X.h and how to shrink it while keeping the same operations.
pdf_range is three unsigned shorts (low, high, out) — 6 bytes per entry. This table has 16,377 ranges → ~98 KB of .rodata (the .h is ~406 KB of C text only because of hex literals).
Lookup does a binary search on sorted intervals and maps:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // --- Idea 1: Pre-compiled regex --- | |
| const cjkRegex = | |
| /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]|\ud840[\udc00-\udfff]|\ud841[\udc00-\udfff]|\ud842[\udc00-\udfff]|\ud843[\udc00-\udfff]|\ud844[\udc00-\udfff]|\ud845[\udc00-\udfff]|\ud846[\udc00-\udfff]|\ud847[\udc00-\udfff]|\ud848[\udc00-\udfff]|\ud849[\udc00-\udfff]|\ud84a[\udc00-\udfff]|\ud84b[\udc00-\udfff]|\ud84c[\udc00-\udfff]|\ud84d[\udc00-\udfff]|\ud860[\udc00-\udfff]|\ud861[\udc00-\udfff]|\ud862[\udc00-\udfff]|\ud863[\udc00-\udfff]|\ud864[\udc00-\udfff]|\ud865[\udc00-\udfff]|\ud866[\udc00-\udfff]|\ud867[\udc00-\udfff]|\ud868[\udc00-\udfff]|\ud869[\udc00-\udfff]|\ud86a[\udc00-\udfff]|\ud86b[\udc00-\udfff]|\ud87e[\udc00-\udfff]|\ud880[\udc00-\udfff]|\ud881[\udc00-\udfff]|\ud882[\udc00-\udfff]|\ud883[\udc00-\udfff]|\ud884[\udc00-\udfff]/; | |
| export function isCJKRegex(s) { | |
| return cjkRegex.test(s); | |
| } | |
| // --- Idea 2: Early exit if char < 0x3000 --- | |
| export function isCJKEarly(s) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // You can edit this code! | |
| // Click here and start typing. | |
| package main | |
| import ( | |
| "fmt" | |
| "sync/atomic" | |
| ) | |
| // general purpose function that tries fast conversion into provided bufOut |
Cursor best practices
I’m using cursor, so I’m wondering if I should go over best practices of using it first. This is to ensure as I work on my projects, I don’t get overwhelmed by complexity.
- Before using cursor, ask Claude to create a clear and detailed plan in markdown (ask it to ask clarifying questions and then critique its own plan and then regenerate). Add it to instructions.md (so you can ask cursor to refer to it frequently)
- I tell chatgpt what I want to create, then I ask it to provide instructions for another AI which will do the coding. Then I paste everything into the cursor composer agent.
- Basically chatgpt adds another layer of planning which reduces the rate of encountering problems.
- On one project cursor was running into some issues and couldn’t figure it out no matter what, I wasted hours stuck in a loop. Then I started from scratch, but this time I asked chatgpt 01 to write clear instructions for another coding AI. It worked like a charm.
- **Use .cursor/rules (they
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{ | |
| "href": "http://blogs.rdoproject.org/7761/hands-on-linux-sandbox-with-namespaces-and-cgroups", | |
| "description": "Hands on Linux sandbox with namespaces and cgroups", | |
| "extended": "", | |
| "meta": "e00cc75e6b9940c23bf4d1463f3ca953", | |
| "hash": "dfcd7a85564dcfea336b8a3c1f091f09", | |
| "time": "2016-06-05T01:07:31Z", | |
| "shared": "yes", | |
| "toread": "no", | |
| "tags": "linux namespaces cgroups sandbox" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* http://localhost:9307/a-ytv9/implementing-notion-like-table-of-contents-in-javascript.html */ | |
| .toc-wrapper { | |
| position: fixed; | |
| top: 1rem; | |
| right: 1rem; | |
| z-index: 50; | |
| max-height: calc(100vh - 2rem); | |
| overflow-y: auto; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io/fs" | |
| "os" | |
| "os/exec" | |
| "path" | |
| "path/filepath" | |
| "strings" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fontCheck = new Set([ | |
| // Windows 10 | |
| 'Arial', 'Arial Black', 'Bahnschrift', 'Calibri', 'Cambria', 'Cambria Math', 'Candara', 'Comic Sans MS', 'Consolas', 'Constantia', 'Corbel', 'Courier New', 'Ebrima', 'Franklin Gothic Medium', 'Gabriola', 'Gadugi', 'Georgia', 'HoloLens MDL2 Assets', 'Impact', 'Ink Free', 'Javanese Text', 'Leelawadee UI', 'Lucida Console', 'Lucida Sans Unicode', 'Malgun Gothic', 'Marlett', 'Microsoft Himalaya', 'Microsoft JhengHei', 'Microsoft New Tai Lue', 'Microsoft PhagsPa', 'Microsoft Sans Serif', 'Microsoft Tai Le', 'Microsoft YaHei', 'Microsoft Yi Baiti', 'MingLiU-ExtB', 'Mongolian Baiti', 'MS Gothic', 'MV Boli', 'Myanmar Text', 'Nirmala UI', 'Palatino Linotype', 'Segoe MDL2 Assets', 'Segoe Print', 'Segoe Script', 'Segoe UI', 'Segoe UI Historic', 'Segoe UI Emoji', 'Segoe UI Symbol', 'SimSun', 'Sitka', 'Sylfaen', 'Symbol', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana', 'Webdings', 'Wingdings', 'Yu Gothic', | |
| // macOS | |
| 'American Typewriter', 'Andale Mono', 'Arial', 'Aria |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "kind": "drive#fileList", | |
| "etag": "\"dNzmxTQXf93-URXXV2e6HTjz4Uc\"", | |
| "selfLink": "https://www.googleapis.com/drive/v2/files", | |
| "nextPageToken": "~!!~AI9FV7TLkZbjkzrcrQWqhRUpOMAeA1WkjFDTn3zHXVv9Bigb-9iLCYw1O-ezzFljevtOfWIZHjy_rDWE0T7_taMq9ue72WfcfGr4r8VKaM-pqUFxxBP0o8rc8qCJPeQv_jatR0rlEjSnK8kw0WwyrsH5TniY5bdOrXh-_I1ikH26dtRCjTXQcQBAfaKhQapG63E5TNk4UdOcuvp3pGlIxKA7IP59ycgYEHFfGEN7cF3DUz9JnuCbjBjK3eS6XB1J8UqBVzgeL1kdRZo5j9lfMIC6sQHihLH9-haQR7pfqT6dbm-ffNtoCITzTuv4aCrP21Qbq5LqdzcZ", | |
| "nextLink": "https://www.googleapis.com/drive/v2/files?pageToken=~!!~AI9FV7TLkZbjkzrcrQWqhRUpOMAeA1WkjFDTn3zHXVv9Bigb-9iLCYw1O-ezzFljevtOfWIZHjy_rDWE0T7_taMq9ue72WfcfGr4r8VKaM-pqUFxxBP0o8rc8qCJPeQv_jatR0rlEjSnK8kw0WwyrsH5TniY5bdOrXh-_I1ikH26dtRCjTXQcQBAfaKhQapG63E5TNk4UdOcuvp3pGlIxKA7IP59ycgYEHFfGEN7cF3DUz9JnuCbjBjK3eS6XB1J8UqBVzgeL1kdRZo5j9lfMIC6sQHihLH9-haQR7pfqT6dbm-ffNtoCITzTuv4aCrP21Qbq5LqdzcZ", | |
| "incompleteSearch": false, | |
| "items": [ | |
| { | |
| "kind": "drive#file", |
NewerOlder