Skip to content

Instantly share code, notes, and snippets.

@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")