Skip to content

Instantly share code, notes, and snippets.

View originalankur's full-sized avatar
🖥️
Coding underway.

Ankur Gupta originalankur

🖥️
Coding underway.
View GitHub Profile
@originalankur
originalankur / asciidoc_code_executor.py
Created September 25, 2025 15:30
AsciiDoc Python Code Extractor and Executor - reads AsciiDoc files, extracts Python code blocks, and executes them interactively with user confirmation.
import re
import os
import sys
import tempfile
import subprocess
from pathlib import Path
from typing import List, Tuple
class AsciiDocCodeExtractor:
def __init__(self, file_path: str):
@originalankur
originalankur / news_analyzer.py
Created August 23, 2025 03:25
News Analyzer - Ensure you have a virtualenv and do `pip install dspy==3.0.2`
import json
from typing import Literal
import dspy
def configure_ollama_lm(model: str = "ollama/gemma3:4b",
base_url: str = "http://localhost:11434"):
"""
Configures DSPy to use a local Ollama model.
"""
print("Connecting to local Ollama model...")
@originalankur
originalankur / spell_and_write.py
Created February 26, 2023 07:34
tokenise the text and sort it. Using it for ensuring that son can spell and write all the words.
import sys
import contextualSpellCheck
import spacy
def filter_words(text):
text = text.strip()
if text in nlp.Defaults.stop_words:
print("in stop word", text)
return False
<script src="https://cdn.safetycop.io/bundle.embed.1982642.min.js" crossorigin="anonymous"></script>
@originalankur
originalankur / feedfinder.py
Created September 3, 2016 21:40
feedfinder with newsblur bug fixes
"""feedfinder: Find the Web feed for a Web page
http://www.aaronsw.com/2002/feedfinder/
Usage:
feed(uri) - returns feed found for a URI
feeds(uri) - returns all feeds found for a URI
>>> import feedfinder
>>> feedfinder.feed('scripting.com')
'http://scripting.com/rss.xml'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pip install networkx distance pattern
In Flipboard's article[1], they kindly divulge their interpretation
of the summarization technique called LexRank[2].
def normalize_line(line):
return [piece.strip() for piece in line.split("|")[1:-1]]
def is_valid_line(line):
return "|" in line
def load(text):
lines = map(normalize_line,
filter(is_valid_line,
text.strip().splitlines()))