04.28.06

NCONC woo!

Posted in Uncategorized at 5:11 pm by UnwashedMeme

slme-profile-package had shown that practically all of the running time was spent in one function that did a lot of list building, and that this function was consing a LOT of memory. I tried to change the appends to nconcs, and after a bit of fiddling the profiling reported that the function was only consing about half as much memory as before. The program also runs a nice bit faster.

The problem I had to fix was that I had some list literals in code, that nconc–true to its nature– was destructively modifying. When recreating a minimal case here SBCL is nice enough to warn me about it, but I don’t recall seeing this when originally solving the problem. There was a lot of other code inbetween that may have been breaking its inferencing though. Another thing to notice is sbcl decided that the length of a constant list was constant=3, except in this case the list isn’t as constant as it appears to be. :-)

CL-USER> (defun foo (a)
	   (let ((b '(1 2 3)))
	     (values (length b)
		     (nconc  b a))))

; in: LAMBDA NIL
;     (NCONC B A)
;
; caught WARNING:
;   Destructive function NCONC called on constant data.
;   See also:
;     The ANSI Standard, Special Operator QUOTE
;     The ANSI Standard, Section 3.2.2.3
;
; compilation unit finished
;   caught 1 WARNING condition
STYLE-WARNING: redefining FOO in DEFUN
FOO
CL-USER> (foo '(bam baz))
3
(1 2 3 BAM BAZ)
CL-USER> (foo '(bam baz))
3
(1 2 3 BAM BAZ BAM BAZ)
CL-USER> (foo '(bam baz bad))
3
(1 2 3 BAM BAZ BAM BAZ BAM BAZ BAD)
CL-USER> (defun foo (a)
  (let ((b (list 1 2 3)))
    (values (length b)
	    (nconc  b a))))

STYLE-WARNING: redefining FOO in DEFUN
FOO
CL-USER> (foo '(bam baz bad))
3
(1 2 3 BAM BAZ BAD)
CL-USER> (foo '(bam baz bad))
3
(1 2 3 BAM BAZ BAD)

01.15.06

The Free Book

Posted in Uncategorized at 4:37 pm by UnwashedMeme

As a collectable card:

The Free Textbook Req. A webserver



Provides:

  • +1 Charisma

When played on a Professor increases the
professor’s charisma. If the professor is one
of the authors then the effect is +3. This
Free Textbooks still count towards the course’s
“Too many textbook” penalty.

“I Don’t have to pay an extra 100 bucks?!”

10.17.05

Common Lisp and SQL

Posted in Uncategorized at 7:00 pm by UnwashedMeme

I like Lisp, to the point of being accused of “having drunk the koolaid.” I read a good number of lisp weblogs (I’m lazy about linking right now). I lurk on #lisp all day long, although a good deal goes by unread I like following the links.

At work I’ve been trying to get a lisp and UCW setup going. However, one of the key components to making htis happen is to be able to reliably talk to a SQL database. Right now we are a predominantly Microsoft shop so charting a path from our current environment to a lisp one is somewhat tricky.

My experience has been less than good. I have tried a number of different setups and found very few combinations that work. I haven’t gotten into what I would consider weird database stuff. Just basic tables, selects and inserts. My unicode test string is: “Iñtërnâtiônàlizætiøn”

The software:

Attempted setup Does it work? Error Unicode string
SBCL -> Postgresql-socket -> postgres No - Doesn’t connect Illegal :ASCII character starting at byte position 0.
[Condition of type SB-IMPL::MALFORMED-ASCII]
the specific byte positions varies, normally in the first 4 but i’ve seen it accross the first 7 or 8.
SBCL -> UFFI -> PostgreSQL library -> postgres YES! Iñtërnâtiônàlizætiøn
SBCL -> UFFI -> UnixODBC -> FreeTDS -> MS SQL Server ‘Bit’ datatype doesn’t work. The value
#<SB-ALIEN-INTERNALS:ALIEN-VALUE :SAP #X082A6A50 :TYPE (* (SB-ALIEN:SIGNED 8))>
is not of type (SB-ALIEN:ALIEN (* (SB-ALIEN:UNSIGNED 8))).
[Condition of type TYPE-ERROR]

I didn’t know true could be negative

“I?t?rn?ti?n?liz?ti?n”
ACL -> :aodbc -> ODBC32 -> MS SQL Server YES! Iñtërnâtiônàlizætiøn
ACL -> Postgresql[-socket] For some values of true Iñtërnâtiônà lizætiøn

Some of the problems might be easy to solve for someone who knows more about the FFIs than I do. But programming in C is not why I am trying to get CL running. There are combinations that work, but this is hardly reassuring.

09.11.05

Civilization IV goodness

Posted in Uncategorized at 1:06 pm by UnwashedMeme

This article gives me a lot of hope. I was kind of worried when I read about cutting down the length of gameplay. I was worried that they were going to remove interesting complexity. However it seems that they are trying to make the game more fluid and easier to control; eg. give the same build orders to several different cities at once.

08.17.05

Opera, text/javascript, and UTF-8.

Posted in Uncategorized at 12:34 pm by UnwashedMeme

I came across what appears to be a minor bug in Opera’s handling of javascript and character encoding. If I send it a stream of text that is accurately described by the header “Content-Type: text/javascript; charset=utf-8″ Opera (at least 8.02) is at a loss for what to do.

When loadng the address directly it just tries to find an external handler for that mime type (and fails for me). If I try to load this bit of javascript through the XMLHttpRequest I get something, however I am not familiar enough with the different east-asian languages to determine what character of beast this is. Suffice it to say that it is not what I intended to get back.

If I change the mime-type to “Content-Type: application/x-javascript; charset=utf-8″ or ‘text/plain’ or ‘text/html’ it works just dandily. Not to difficult of a workaround, but is this really a workaround or “The Proper Way”?

Safari, Firefox, and Internet explorer did not have any problems digesting the ‘text/javascript’. So for trying to follow a de facto standard, which from what I know of Opera they generally try to do, not very good. Most webservers serve ‘application/x-javascript’ so they do have that one in the bag.

This really comes down to: There is no standard javascript mime-type.

A script block with type=”text/javascript” writes: ”
document.write(”foo”);


A script block with type=”application/x-javascript” writes: ”
document.write(”bar”);

My test showed that both of those work in Mozilla and Opera, and I only get “foo” when in IE.

08.16.05

Nanotube Transistors

Posted in Uncategorized at 12:27 pm by UnwashedMeme

YACaNTS (Yet Another Carbon Nanotube Story). Constantly reading more stories of how carbon nanotubes are awesome.

Still looking for the story about carbon nanotube stem cells.

08.12.05

Is it ready yet?

Posted in Uncategorized at 8:36 pm by UnwashedMeme

I’ve been working for the past couple of days to improve our framework for doing partial post-back.
It’s more or less standard AJAX fare, I’m just trying to make it easy to do partial page rendering and replacement that uses our existing ASP.Net control structure.
Works great and was easy to do in Mozilla, but of course Inappropriate Expletive has to make life difficult.

I’ve been trying to make this as resilient to errors as possible. If the AJAX request gets a 400 series error, bail out and try a standard postback. If the server did not send back javascript or gives a 500 series error then print whatever it did get back to the screen.
Replacing the current page with new html in javascript turned out to be more difficult than I expected. According to MSDN you can open the current document, write to it and close it again.
Indeed their sample page does work (in Firefox as well), but when I tried to do the same function through the shell or from the partial postback code it leaves the browser in an inconsistent state at best, and sometimes just crashes it. I ended up clearing the body’s innerHTML, adding an IFrame to the body, and writing everything to that. Not exactly a ‘pretty’ solution.

The communication with the server really needs to be done asynchronously so the browser isn’t blocked while waiting for the server.
With XMLHttpRequest this isn’t to bad.
I’m not as much of a fan of MSXML though. The problem comes from the readyState variable that reports what stage the request is currently on.

From the Mozilla docs:
readonly PRInt32 readyState
The state of the request.
Possible values:

  • 0 UNINITIALIZED open() has not been called yet.
  • 1 LOADING send() has not been called yet.
  • 2 LOADED send() has been called, headers and status are available.
  • 3 INTERACTIVE Downloading, responseText holds the partial data.
  • 4 COMPLETED Finished with all operations.

That makes sense to me. Once 2 roles around I can start querying the headers to make sure I am getting what I expect. If it was set up to deal with a stream, that could start processing at step 3, and then everything is completely available in step 4.
The only change I could see is that it might be useful to someone to have a stage immediately after the request is sent but no part of the response has been received yet. Not entirely sure where this would be useful though.

It seems that the IE developers felt that this was the most important step though. “I’ve sent a request but don’t have any data back yet.”
From MSDN (parentheses theirs):

  • 0 (UNINITIALIZED) The object has been created, but not initialized (the open method has not been called).
  • (1) LOADING The object has been created, but the send method has not been called.
  • (2) LOADED The send method has been called, but the status and headers are not yet available.
  • (3) INTERACTIVE Some data has been received. Calling the responseBody and responseText properties at this state to obtain partial results will return an error, because status and response headers are not fully available.
  • (4) COMPLETED All the data has been received, and the complete data is available in the responseBody and responseText properties.

Not only does state 2 implement that, but state 3 is functionally equivalent as well. Since you can’t query any of the headers or even start processing a partial stream in state 3, from my perspective it isn’t really providing anything extra. The only thing worth hooking here is state 4.

Well, there goes my attempt to speed up the processing by doing as much work as possible in the early states while it is still receiving data. Thanks IE.

08.05.05

Go Team Venture!

Posted in Uncategorized at 9:26 pm by UnwashedMeme

Shweeet.

If you haven’t seen The Venture Bros. you really should try and catch it. It’s awesome.

07.28.05

Why CSS is a good thing.

Posted in Uncategorized at 1:56 pm by UnwashedMeme

Most of the people around here have heard me cursing at CSS, HTML, and browsers. I think PPK is spot on though.

Go read.

07.12.05

Green Tea Frappuccino

Posted in Uncategorized at 4:37 pm by UnwashedMeme

There are some other out there that are speaking well of it. However, I definately didn’t take to it, Russ was of the opinion that it was terrible, and Chris made the excellent point that “The whipped cream on top is pretty good; you could finish that off.”

« Previous entries · Next entries »