|
1 |
| -# cheatsheet |
2 |
| -A framework for creating and recalling short tidbits that I need to remember |
| 1 | +# Overview |
| 2 | + |
| 3 | +A collection of short tidbits that I need to remember |
| 4 | + |
| 5 | +standalone first - electron - https://github.com/electron/electron-quick-start |
| 6 | + |
| 7 | +Slack app second |
| 8 | + |
| 9 | +# Data |
| 10 | + |
| 11 | +three sets of redis sets |
| 12 | + |
| 13 | +- every keyword |
| 14 | + - [keyword]-keywords |
| 15 | + - [keyword]-problems |
| 16 | + - [keyword]-solutions |
| 17 | + |
| 18 | +The search page has a redis sorted set "~~search" of every matching tidbit with their score. With a new word, this list is updated with the various searches that are done. When finished updating, the page is updated with the most recent list. |
| 19 | + |
| 20 | +JSON data structure |
| 21 | + |
| 22 | +- settings |
| 23 | + - list of ignored words |
| 24 | + - list of allowed characters in tokens |
| 25 | +- library |
| 26 | + - keywords |
| 27 | + - brief problem description (limited to 200 characters) |
| 28 | + - brief solution (limited to 1000 characters. any more is not suited for this tool.) |
| 29 | + |
| 30 | +# Use cases |
| 31 | + |
| 32 | +two main use cases, two rare |
| 33 | + |
| 34 | +- find a snippet |
| 35 | + - type in description of problem |
| 36 | + - quickly finds top results - see below |
| 37 | +- create a snippet |
| 38 | + - type in problem description |
| 39 | + - type in solution |
| 40 | + - asks for keywords |
| 41 | + - adds its own keywords from the problem and solution description |
| 42 | + - lowercase everything |
| 43 | + - turn unneeded characters into whitespace |
| 44 | + - replace(/[^\.\s\da-z]|(\.\s)/g, " ") - from list of allowed characters |
| 45 | + - get rid of unneeded words |
| 46 | + - replace(/\b(the)\b|\b(and)\b|\b(is)\b|\b(to)\b|\b(by)\b|\b(is)\b|\b(in)\b|\b(with)\b/g, "") - built from list of ignored words |
| 47 | + - get rid of unneeded whitespace |
| 48 | + - replace(/\s+/g, " ") |
| 49 | + - end up with just tokens separated by spaces |
| 50 | + - split(" ") |
| 51 | + - weights of keywords |
| 52 | + - manually inputted keyword - 10 |
| 53 | + - from problem description - 3 |
| 54 | + - from solution - 1 |
| 55 | + - adds to json knowledge base and redis sets |
| 56 | +- install knowledge base |
| 57 | + - turn the json into the redis sets |
| 58 | +- edit settings |
| 59 | + - list of ignored words |
| 60 | + - list of allowed characters in tokens |
| 61 | + |
| 62 | +# Pseudocode |
| 63 | + |
| 64 | +on every keystroke, calculate the delta and determine if a new keyword has been entered or removed |
| 65 | + |
| 66 | +new keyword is entered: |
| 67 | + |
| 68 | + members = SMEMBERS [keyword]-keywords |
| 69 | + foreach member in members |
| 70 | + ZINCRBY ~~search 10 member |
| 71 | + |
| 72 | + members = SMEMBERS [keyword]-problems |
| 73 | + foreach member in members |
| 74 | + ZINCRBY ~~search 3 member |
| 75 | + |
| 76 | + members = SMEMBERS [keyword]-solutions |
| 77 | + foreach member in members |
| 78 | + ZINCRBY ~~search 1 member |
| 79 | + |
| 80 | + update display using ZREVRANGEBYSCORE ~~search +inf 0 WITHSCORES LIMIT 25 |
| 81 | + |
| 82 | +new keyword is removed - same as above, except negative numbers |
| 83 | + |
| 84 | + |
0 commit comments