Thursday, August 30, 2007
Key Changes
The band with the offensive name goes through a lot of key changes. This is just an extreme version of what rock does already. Where does the E-flat in F7 come from when you're playing in C? It sounds to me like they're going into the dominant more (playing the flat-five to imply a major second).
Wednesday, February 21, 2007
Two SQLServer SQL Tips
1) My transaction log file was gigantic (38GB). I fixed it by doing this:
deleting my log file and then doing this:
2) When I'm writing a script that creates tables, I often want to drop the table if it already exists. Instead of writing out the
Now that I think about it, I wonder whether T-SQL has the equivalent of Oracle's 'CREATE OR REPLACE'. That's basically what I've re-implemented here.
sp_detach_db MyDB,deleting my log file and then doing this:
exec sp_attach_db 'MyDB', '[pathToMDF]\MyDB.mdf'2) When I'm writing a script that creates tables, I often want to drop the table if it already exists. Instead of writing out the
if exists (select ...) drop table over and over again, I created a little stored procedure to do it:
CREATE PROCEDURE drop_table @tableName varchar(255) AS
if exists (select name from sysobjects where name=@tableName and type='U')
EXEC('DROP TABLE '+@tableName)
GO
Now I can drop a table like this: exec drop_table 'MyOldTable'. I created a similar procedure for dropping stored procedures. Now that I think about it, I wonder whether T-SQL has the equivalent of Oracle's 'CREATE OR REPLACE'. That's basically what I've re-implemented here.
Friday, January 26, 2007
FizzBuzz Exposes a Scheme Design Pattern?
I wrote a simple FizzBuzz in Scheme:
Then, inspired by Reg's "overthought" Ruby version, I did a Scheme version of his implementation:
The design pattern I'm talking about concerns multi-arg Scheme functions like
I've had to do this a few times writing Scheme functions, so maybe it's a design pattern! Mark Dominus has pointed out that patterns are a sign of weaknesses in programming languages. So, is this a real weakness in Scheme? Is there another way to recurse with a multi-argument function?
(define (number-interval f t)
(if (<= f t) (cons f (number-interval (+ f 1) t)) '()))
(define (fb n)
(cond
((eq? (remainder n 15) 0) 'FizzBuzz)
((eq? (remainder n 5) 0) 'Buzz)
((eq? (remainder n 3) 0) 'Fizz)
(else n)
)
)
(define (FizzBuzz m n) (map fb (number-interval m n)))
Then, inspired by Reg's "overthought" Ruby version, I did a Scheme version of his implementation:
(define (carbonate n name)
(lambda (x)
(if (and (number? x) (eq? (remainder x n) 0))
name
x
)
)
)
(define (compose . fns)
(define (compose-list functions)
(if (null? functions)
(lambda (x) x) ; identity function
(lambda (x)
(define (g y) ((compose-list (cdr functions)) y))
(g ((car functions) x))
)
)
)
(compose-list fns)
)
(define (FizzBuzz2 m n)
(map (compose (carbonate 15 'FizzBuzz) (carbonate 5 'Buzz) (carbonate 3 'Fizz)) (number-interval m n))
)
The design pattern I'm talking about concerns multi-arg Scheme functions like
compose, above. The composition of a list of functions is the composition of the first with the composition of the rest. But I can't see how Scheme's multi-argument-function syntax is amenable to the natural recursion. So I have to write the compose-list helper function.I've had to do this a few times writing Scheme functions, so maybe it's a design pattern! Mark Dominus has pointed out that patterns are a sign of weaknesses in programming languages. So, is this a real weakness in Scheme? Is there another way to recurse with a multi-argument function?
Tuesday, November 28, 2006
Book 50: Tatja Grimm's World (Vinge)
Disappointing Vinge. But it was his first novel, so maybe that's why. Some exciting scenes, but none of the "wow" factor of "A Fire Upon the Deep" or "A Deepness in the Sky". And his attempts to avoid "as you know, Bob" setups are kind of clumsy (but I guess at least he tried). And neologistic abbreviations are so annoying ("art'ry" for "artillery" -- yeesh!). Stephenson does this too, with "phant'sy". Stop banging me on the head with etymology, you smug jerk!
So that's fifty books! And before December!
So that's fifty books! And before December!
Book 49: H.M.S. Surprise (O'Brian)
Another great Aubrey/Maturin. Very exciting battles and espionage. And Dil was an affecting character, despite her short stay in the story.
Book 48: Darwinia (Wilson)
Reasonably OK. Wilson's books seem to get better in the order he wrote them. Unfortunately, I'm reading them in reverse order! The one standout for me in this book was his establishing Lovecraftian monsters in a hard SF environment.
Tuesday, November 14, 2006
Book 47: Post Captain (O'Brian)
Second Aubrey/Maturin. Crammed with plot and excitement. Maturin's wool suit and bees were hilarious.
Book 46: Going Postal (Pratchett)
Very good. Usual Discworld wackiness, but with a motivating good-versus-evil plot and some character development more believable than Moist von Lipwick's name.
Monday, October 30, 2006
Book 45: Chronoliths (Wilson)
Very good. Similar to "Spin" in that it describes what happens to realistic characters after a science-fictiony incident in the near future. Not quite as good as Spin.
Wednesday, October 25, 2006
Book 42: The Tiger in the Well (Pullman)
Very engaging, engrossing novel. Sally's plight is real and gripping. The climax is not as spectacular as it could have been, but I think that's the point and the meaning of the title: Sally can't solve all her problems herself.
Thursday, October 12, 2006
Book 41: The Shadow in the North (Pullman)
Another Sally Lockhart story. Not gripping, but fairly interesting.
Thursday, October 05, 2006
Book 40: The Catalans (O'Brian)
A more serious (for some meaning of "serious") novel than the Aubrey/Maturin books. Excellent sense of people in a place. And of particular characters -- especially Xavier and his crisis.
Thursday, September 28, 2006
Book 39: The Far Side of the World (O'Brian)
Another Aubrey/Maturin novel. There's more inter-personal intrigue in this one. And more humour. But there's very little overlap with the plot of the movie with the same name: they're chasing another ship in the Pacific and the cook makes a dessert in the shape of the Galapagos islands, but that's it!
Thursday, September 14, 2006
Book 38: The Ruby in the Smoke (Pullman)
Decent Victorian England thriller. Not as good as Pullman's "Golden Compass" series.
Book 37: The Secret Mitzvah of Lucio Burke (Hayward)
I read this book because I went to school with the author. It's good: occasionally funny, quite a bit of Toronto history and one RHHS reference (Mr. Booth the biology teacher). There are some loose ends, so maybe I need to read it again.
Tuesday, September 05, 2006
Book 36: The Violent Bear It Away (O'Connor)
Is the idiot love Rayber resists the same thing as Old Tarwater's faith and prophecy? I don't think so: Old Tarwater's full of fear and hate. This book's conflict isn't good against evil: it's a battle between two confusions. Picking a side in that fight is pointless.
Good writing, though, and very intense.
Good writing, though, and very intense.
Book 35: Desolation Island (O'Brian)
More Aubrey/Maturin. O'Brian's books don't have denouments. As soon as the last plot point's wrapped up, the book ends. Interesting, but disorienting. Anyway, this one's good too. The sea battles are very exciting.
Tuesday, August 29, 2006
Book 34: The Mauritus Command (O'Brian)
Fourth Aubrey/Maturin novel. They're kind of blurring into each other! Very entertaining, though. I feel like I'm learning about sailing.
Subscribe to:
Posts (Atom)