September 30, 2003

Perl script to suck courses files

September 30, 2003 - Categories: -Uncategorized

Back when I didn't have a Download as Archive in the courses system, I used this script to suck all the files.

use English;

open INDEX, "curl -b PHPSESSID=$SESSIONID '$ARGV[1]' |";

while (($s = ) && ($s !~ /select name="login"/)) { }

my @logins;
my @lnames;
my @fnames;
my $i = 0;

while ( =~ /option value="(\w+)"> (.+?), (.+?)) && ($s !~ /smaller/))

my $login; my $timestamp;
while ($s = )
    if ($s =~ /(\w+?);   # skip name
	;   # skip email
	;   # skip first part;
	if ( =~ /^\s*(.+?)\s*$/)
	    $timestamp = $1;
	;   # skip 
	;   # skip 
	;   # skip 
    elsif ($s =~ /nbsp/)
	# $s nbsp;
	;  # td valign = top
	;  # files
	while (($s = ) && ($s =~ /index\.php\?project_id=(\d+)\&login=(\w+)\&file=(.+?)\"/))
	    mkdir $1;
	    mkdir "$1/$2";
	    system "curl -b PHPSESSID=$SESSIONID '$1&login=$2&file=$3' -o $1/$2/$3";
    elsif ($s =~ /html/)
	close INDEX;

Hello world, school, teaching, games — blast from the past

September 30, 2003 - Categories: -Uncategorized

From my 2002.06.20 entry:

12:52 AM on a schoolday that starts at 10:30 AM is probably not the best time to write an S-Files, but what the heck. I haven't been writing. Stories have backed up, and the resulting chaos in my mind appears to have edged out important details like the names of people I'm supposed to know and the details of where I'm supposed to be.

Time to defrag.

I am all the more unusually loquacious because I have just finished writing a lab exercise for the introductory computer science course for which I am a teaching assistant. My pitiful effort at making "Hello, World!" fun and exciting can be found at , with no guarantee that it'll actually even be used in today's CS session. I'm banking on the fact that Dr. Sarmenta probably hasn't prepared materials as detailed as this, as I haven't seen anything like it from, well, any of my CS teachers. I'm _hoping_ that he'll let me deliver the class, which is a far-out possibility but still worth considering. I also hope I'll be awake enough to do so with wit and style.

I love the project submission system I wrote last semester. After editing the postgresql start script so that the postmaster would accept TCP connections, I simply had to set up the database and run a script that obligingly extracted and included all the students in the student data files that the department forwarded to me. All 222 students of CS21A in 9 sections have been set up. How nice.

Teaching. Hmm. I had dinner with Mario Carreon (an old friend from high school competitions) the other night. He teaches at UP and is considering moving to the industry because of the pay. We talked about teaching, mainly, and in the course of our conversation I found myself declaring that yes, this is it - I cannot imagine myself in any other profession except teaching. Especially college level introductory computer science. That's it.

Naturally teaching doesn't stand on its own - I must be teaching _something_, and teaching also offers ample time for research. Enter wearable computing. I'll be getting my gear on the 23rd, if all goes well. Expect lots of files going on and on about how cool it all is.

More past entries

September 30, 2003 - Categories: -Uncategorized

- 2002.06.20 - 2002.06.25 - 2003.02.02 - 2003.01.12 - 2003.01.13 - 2003.12.27

Code for inserting student code

September 30, 2003 - Categories: emacs
(defvar sacha/project-base-path nil "*The path to the project files, excluding the ending /")
(defun sacha/insert-student-files (id)
  (interactive "MID: ")
  (if (file-directory-p (concat sacha/project-base-path "/" id))
        (cd (concat sacha/project-base-path "/" id))
        (mapcar (lambda (item)
                  (print item)
                  (insert "--------------------------------------------------------------------\n")
                  (insert "Your code: " item "\n")
                  (insert "--------------------------------------------------------------------\n")
                  (let ((retval (cadr (insert-file-contents item))))
                    (goto-char (+ (point) retval))
                    (insert "\n")))
                (file-expand-wildcards "*")))
     (insert "***********************************************************\n"
             "You have not yet submitted any files.\n"

Composing messages in Gnus with elisp — emacs

September 30, 2003 - Categories: emacs
(require 'gnus-msg)
(defun dxr-group-mail (To Subject)
  "Start composing a mail."
  (gnus-setup-message 'message
  (message-mail To Subject)))

“How Do We Tell Truths That Might Hurt”?

September 30, 2003 - Categories: -Uncategorized