This file contains 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
""" | |
tfd.py -- Scrapes a certain set of comics' websites, and spits | |
out home-grown RSS feeds for them. | |
This is pretty useless now that all of the Sharing Machine comics | |
provide RSS feeds, but might serve as an okay example of old-school | |
screen scraping and XML generation in Python. I hear the cool kids | |
use BeautifulSoup (for scraping) and lxml (for XML generation) | |
nowadays. |
This file contains 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
function bestclass = knn(train_data, labels, example, k); | |
%kNN-- do k-nearest neighbours classification | |
% | |
% BESTCLASS = knn(TRAIN_DATA, LABELS, EXAMPLE, K) | |
% | |
% Takes TRAIN_DATA, a D x N matrix containing N training examples of dimension | |
% D; LABELS, an N-vector of the (positive integer) classes assigned to each | |
% column of TRAIN_DATA; EXAMPLE, a D-vector consisting of the example we | |
% are trying to classify; and K, the number of neighbours to use in | |
% classifying. |
This file contains 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
;A bunch of increasingly complex Scheme procedures I wrote while | |
;learning Scheme. | |
; | |
; By David Warde-Farley -- user AT cs dot toronto dot edu (user = dwf) | |
; Redistributable under the terms of the 3-clause BSD license | |
; (see http://www.opensource.org/licenses/bsd-license.php for details) | |
;Increment a value and return it. | |
(define inc |
This file contains 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
/* Scanner that reads in a Portable Graymap (PGM) file. | |
* | |
* By David Warde-Farley -- user AT cs dot toronto dot edu (user = dwf) | |
* Redistributable under the terms of the 3-clause BSD license | |
* (see http://www.opensource.org/licenses/bsd-license.php for details) | |
*/ | |
enum { PRE_START, PARSE_START, GOT_X, GOT_Y, GOT_MAX } parserstate | |
= PRE_START; |
This file contains 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 numpy as np | |
import scipy.special as spec | |
import scipy.optimize as opt | |
def negative_beta_likelihood(params, sumlogd, sumlog1md, numpts): | |
""" | |
Negative log likelihood for i.i.d. beta random variables, based | |
on the parameters and the sufficient statistics. | |
params -- length-2 array of (log) parameters |
This file contains 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 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 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 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 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, |