Skip to content

Instantly share code, notes, and snippets.

View yamanahlawat's full-sized avatar
:shipit:

Yaman Ahlawat yamanahlawat

:shipit:
View GitHub Profile
@yamanahlawat
yamanahlawat / upgrade_shadcn_components.sh
Created January 19, 2025 17:59
Script to bulk update all shadcn/ui components in a Next.js project
#!/bin/bash
# update-shadcn-components.sh
# Script to bulk update all shadcn/ui components in a Next.js project
# Usage: ./update-shadcn-components.sh
# Set error handling
set -e
# Check if we're in a Next.js project
@yamanahlawat
yamanahlawat / upgrade_pyproject.py
Created December 5, 2024 12:58
Upgrade all packages using uv
"""
Script to update pyproject.toml dependencies based on uv.lock file.
Prerequisites:
1. Python 3.11+ (for tomllib)
2. tomli-w package (`pip install tomli-w`)
3. Updated uv.lock file (`uv lock --update` or `uv lock -U`)
Usage:
1. Update your lockfile: `uv lock -U`
@yamanahlawat
yamanahlawat / repeating_characters_replacer.py
Last active January 25, 2017 13:21
Remove repeating characters from a word using regular expressions and nltk wordnet
import re
from nltk.corpus import wordnet
class RepeatReplacer(object):
def __init__(self):
self.repeat_regexp = re.compile(r'(\w*)(\w)\2(\w*)')
self.repl = r'\1\2\3'
def replace(self, word):
@yamanahlawat
yamanahlawat / replacers.py
Created January 25, 2017 12:17
Using Regular Expressions to expand contractions of a Word
import re
replacement_patterns = [
(r'won\'t', 'will not'),
(r'can\'t', 'cannot'),
(r'i\'m', 'i am'),
(r'ain\'t', 'is not'),
(r'(\w+)\'ll', '\g<1> will'),
(r'(\w+)n\'t', '\g<1> not'),
(r'(\w+)\'ve', '\g<1> have'),