- Prefer types over interfaces for simple data structures
- Use interfaces and class OOP for more complex components
- Comments should be used to explain "why" decisions were made with possible source references
- Avoid magic numbers or strings - use constants instead, and if they feel like configuration values, move them to a configuration file
- Avoid default parameter values especially in method signatures since this can lead to unexpected behavior. For example if a method signature has three arguments, then a caller is required to pass in exactly three arguments.
- Avoid null coalescing (??) or fallbacks. All values should always be explicitly set.
- Avoid default parameters / default fallbacks / etc. since this silently obfuscates errors. Errors should always propagate so we can discover potential issues.
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
| # This script will transcribe an audio file (mp3, wav, etc.) to text and then clean the text using a local LLM model via Ollama. Technically, this script will work with any LLM that supports the standard OpenAI bindings with minor adjustments. | |
| # GETTING STARTED: | |
| # 1. Install required python packages (pip install openai python-dotenv) | |
| # 2. Git clone a copy of ggerganov/whisper (https://github.com/ggerganov/whisper.cpp) | |
| # 3. Build the whisper binary (see the whisper.cpp README for instructions) | |
| # 4. Download one of the whisper models (largev2 is the most accurate for all languages, though the base model works reasonably well for English). | |
| # 5. Install ffmpeg (brew install ffmpeg on macOS, apt-get install ffmpeg) | |
| # 6. Install ollama (https://ollama.com/download) | |
| # 7. Download an LLM model (https://ollama.com/library) |
This isn't a guide about locking down homebrew so that it can't touch the rest of your system security-wise.
This guide doesn't fix the inherent security issues of a package management system that will literally yell at you if you try to do something about "huh, maybe it's not great my executables are writeable by my account without requiring authorization first".
But it absolutely is a guide about shoving it into its own little corner so that you can take it or leave it as you see fit, instead of just letting the project do what it likes like completely taking over permissions and ownership of a directory that might be in use by other software on your Mac and stomping all over their contents.
By following this guide you will:
- Never have to run
sudoto forcefully change permissions of some directory to be owned by your account
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
| // requirements | |
| const winston = require('winston'); | |
| const winstonSqlite3Transport = require('./winston-sqlite3-transport'); | |
| class Logger { | |
| winstonLogger; | |
| constructor(db_file) { | |
| this.winstonLogger = winston.createLogger({ | |
| level: 'debug', |
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
| /** | |
| * Convert a JSON string into a standard Javascript Object | |
| * @param x - JSON string | |
| * @returns {{}} - Deserialized object or empty object | |
| */ | |
| static SafeParse(x) { | |
| let obj = { }; | |
| try | |
| { | |
| if(x !== null && x !== undefined) |
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
| /** | |
| * Simple CPU-bound blocking operation for testing purposes | |
| * @param baseNumber - higher the value, the longer the operation will block | |
| */ | |
| static blockCPU(baseNumber) { | |
| console.time('blockCPU'); | |
| let result = 0; | |
| for (let i = Math.pow(baseNumber, 7); i >= 0; i--) { | |
| result += Math.atan(i) * Math.tan(i); | |
| } |