Skip to content

Instantly share code, notes, and snippets.

@raine
Last active October 25, 2025 20:27
Show Gist options
  • Save raine/b8d42275a188005bd2dadc34b8e05824 to your computer and use it in GitHub Desktop.
Save raine/b8d42275a188005bd2dadc34b8e05824 to your computer and use it in GitHub Desktop.
> Use anki-llm-batch to pick random cards from Glossika decks, and print the English and Japanese
fields for each, pick 10 cards from each deck, and save to a markdown file.
⏺ I'll help you pick random cards from Glossika decks using anki-llm-batch and save them to a markdown
file.
Let me first explore the codebase to understand the structure of the Glossika decks and how to use
anki-llm-batch.
⏺ Bash(anki-llm-batch --help)
⎿  anki-llm-batch <command>
Commands:
… +10 lines (ctrl+o to expand)
⏺ Bash(anki-llm-batch query --help)
⎿  anki-llm-batch query <action> [params]
Query AnkiConnect API with any action and optional parameters
… +20 lines (ctrl+o to expand)
⏺ Let me find the Glossika decks in Anki and get the cards:
⏺ Bash(anki-llm-batch query deckNames)
⎿  [
"_",
"_::Genki I",
… +19 lines (ctrl+o to expand)
⏺ Now let me get the card IDs from each Glossika deck and then sample 10 random cards from each:
⏺ Bash(anki-llm-batch query findCards '{"query":"deck:\"Glossika-ENJA [0001-1000]\""}')
⎿  [
1673568617165,
1673568617167,
… +999 lines (ctrl+o to expand)
⏺ Bash(anki-llm-batch query findCards '{"query":"deck:\"Glossika-ENJA [1001-2000]\""}')
⎿  [
1673568617418,
1673568617420,
… +999 lines (ctrl+o to expand)
⏺ Bash(anki-llm-batch query findCards '{"query":"deck:\"Glossika-ENJA [2001-3000]\""}')
⎿  [
1673568619165,
1673568619167,
… +999 lines (ctrl+o to expand)
⏺ Perfect! Now I'll write a script to randomly sample 10 cards from each deck and get their info. Let
me create a script to do this:
⏺ Bash(cat > /tmp/sample_glossika.sh << 'EOF'
#!/bin/bash…)
⎿  (No content)
⏺ Let me create a better approach using Node.js to sample the cards and get their details:
⏺ Write(sample_glossika.js)
⎿  Wrote 72 lines to sample_glossika.js
#!/usr/bin/env node
const { execSync } = require('child_process');
// Helper to query AnkiConnect
function query(action, params = {}) {
const cmd = `anki-llm-batch query ${action} '${JSON.stringify(params)}'`;
const result = execSync(cmd, { encoding: 'utf-8' });
return JSON.parse(result);
}
… +62 lines (ctrl+o to expand)
⏺ Bash(chmod +x sample_glossika.js && node sample_glossika.js)
⎿  Fetching cards from Glossika decks...
Processing Glossika-ENJA [0001-1000]...
… +4 lines (ctrl+o to expand)
⏺ Perfect! Let me check the generated markdown file:
⏺ Read(glossika_sample.md)
⎿  Read 198 lines
⏺ Excellent! I've successfully created a markdown file with 10 random cards from each of the three
Glossika decks. The file glossika_sample.md now contains:
- Glossika-ENJA [0001-1000]: 10 random cards with English and Japanese sentences
- Glossika-ENJA [1001-2000]: 10 random cards with English and Japanese sentences
- Glossika-ENJA [2001-3000]: 10 random cards with English and Japanese sentences
Each card shows both the English and Japanese text, with HTML tags removed for clean formatting. The
script I created (sample_glossika.js) can be run again anytime to generate a new random sample.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment