Skip to content

Instantly share code, notes, and snippets.

@craigmbooth
craigmbooth / nloadct.pro
Created February 5, 2013 18:29
This is my replacement for IDL's loadct command. It is pretty much interchangable with the default version but the number of colour tables runs over 100. Also allows easy creation of new colour tables by automatic interpolation from a series of rgb values.
;+
; NAME:
; NLOADCT
;
; PURPOSE:
; Load predefined color tables.
;
; CATEGORY:
; Image display.
;
@craigmbooth
craigmbooth / .gitignore
Last active December 12, 2015 01:48
My default .gitignore file. Deals with the common extensions that I have to ignore, including LaTeX temporary files and Emacs temporary files
# Compiled files
################
*.o
*.so
*.mod
# Emacs temporary files
#######################
*~
\#*\#
@craigmbooth
craigmbooth / generate_credit_card.py
Created July 15, 2012 19:56
Generate Valid Credit Card Number
"""Provides method generate(prefix,length), which for a given prefix and
total length will return a valid credit card number. generate returns
None for invalid inputs.
Credit card numbers have the following form: PPPPPP NNNNNNNNN C
Where P is a prefix that identifies the issuing authority, N is an
account number and C is a checksum digit, calculated with Luhn's
algorithm.
@craigmbooth
craigmbooth / solve_sudoku.py
Created July 12, 2012 12:55
Simple Sudoku Solver
"""Provides methods check_sudoku and solve_sudoku
Expects input of a list of 9 lists, each of length 9, representing
a Sudoku board. Unfilled numbers may be represented with a zero. For
example:
valid = [[5,3,4,6,7,8,9,1,2],
[6,7,2,1,9,5,3,4,8],
[1,9,8,3,4,2,5,6,7],
[8,5,9,7,6,1,4,2,3],
[4,2,6,8,5,3,7,9,1],
[7,1,3,9,2,4,8,5,6],