This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Demonstrates breaking up a string in much the same manner as is done by | |
| * the standard library function strtok. It's also an actually practical | |
| * occurrence of a triple pointer (char ***). | |
| * | |
| * Prepared for tutorial purposes by David Warde-Farley, CSC209H Winter 2008 | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Demonstrates the use of fgets() for reading in input, and it's behaviour | |
| * with respect to terminating NULL characters, newlines, etc. | |
| * | |
| * Prepared for tutorial purposes by David Warde-Farley, CSC209H Winter 2008 | |
| */ | |
| #include <stdio.h> | |
| #define BUFSIZE 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Demonstrates the use of strchr to count the number of spaces in a string | |
| * entered by the user. | |
| * | |
| * Prepared for tutorial purposes by David Warde-Farley, CSC209H Winter 2008 | |
| */ | |
| #include <stdio.h> | |
| #include <string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # screencap2dropbox.sh -- Takes a screenshot with Mac OS X's | |
| # 'screencapture' utility, places the output in a publicly accessible | |
| # Dropbox folder ( http://www.dropbox.com/ for more information ) | |
| # and then copies the URL to the clipboard. | |
| # | |
| # By David Warde-Farley, March 18, 2010. Inspired by an earlier Automator | |
| # version by Andrew Louis. | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import numpy as np | |
| import scipy.ndimage as ndimage | |
| import matplotlib | |
| import matplotlib.pyplot as plt | |
| def frac_eq_to(image, value=0): | |
| return (image == value).sum() / float(np.prod(image.shape)) | |
| def extract_patches(image, patchshape, overlap_allowed=0.5, cropvalue=None, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node(object): | |
| def __init__(self, value): | |
| self.value = value | |
| self.next = None | |
| def __str__(self): | |
| """Return a string representation of the list starting here.""" | |
| values = [] | |
| curr = self | |
| while curr is not None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- iplib.bak 2010-07-08 22:30:10.000000000 -0400 | |
| +++ iplib.py 2010-07-08 22:31:09.000000000 -0400 | |
| @@ -1684,6 +1684,14 @@ | |
| if Debugger.has_pydb: | |
| from pydb import pm | |
| else: | |
| + try: | |
| + import pudb | |
| + pudb.post_mortem((sys.last_type, | |
| + sys.last_value, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def kaprekar(s, t=4): | |
| """ | |
| Demonstrate Kaprekar's procedure and its convergence to Kaprekar's constant. | |
| """ | |
| s = str(s) | |
| # t = 3 or 4 will converge; otherwise all bets are off. | |
| assert len(s) <= t | |
| if len(s) < t: | |
| s = ('0' * (t - len(s))) + s | |
| print s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Simple implementation of ROC curve plotting with NumPy and matplotlib. | |
| No bells and whistles, no fancy data structures, just one function and | |
| a (hopefully) very gentle learning curve. | |
| """ | |
| __author__ = "David Warde-Farley <dwf AT cs.toronto.edu>" | |
| __copyright__ = "(c) 2010 David Warde-Farley" | |
| __license__ = "3-clause BSD license" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Make some plots for our 2010 NAR Web Server paper.""" | |
| import sys | |
| import numpy as np | |
| import matplotlib as mpl | |
| mpl.use('Agg') # Don't pop up figures, just render in memory | |
| import matplotlib.pyplot as plt | |
| # Empty dictionaries | |
| bp = {} |