Skip to content

Instantly share code, notes, and snippets.

View sahilgupta's full-sized avatar

Sahil Gupta sahilgupta

View GitHub Profile
@sahilgupta
sahilgupta / add_to_zshrc.sh
Created September 25, 2024 12:11 — forked from karpathy/add_to_zshrc.sh
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@sahilgupta
sahilgupta / gist:6365511
Created August 28, 2013 12:33
Django SQL logging while working in the shell.
import logging
logging = logging.getLogger('django.db.backends')
logging.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
@sahilgupta
sahilgupta / sudoku_csp.py
Created October 18, 2011 20:17
Sudoku Puzzle solved using Constraint Satisfaction Programming(CSP) library 'constraint'
#We only need to ensure unique values in every row, column and 3*3 blocks
#The rest is done by the library.
import constraint
#Create the list of entire 81 variables, initialised to an empty set
boxes = []
for i in 'A B C D E F G H I'.split():
k = []
@sahilgupta
sahilgupta / itunes_shuffle.py
Created October 15, 2011 02:27
Itunes DJ fast shuffle
#TODO: Add threading to avoid blocking
#TODO: Create a windows service out of this
#TODO: Start the Track somewhere in the middle instead of the very start!
import win32com.client
import random
import time
itunes= win32com.client.Dispatch("iTunes.Application")