icanhasnu

Saturday, 08 Mar 2008

I may regret this.

It’s just a little Nu CGI program that I wrote this evening using Grayson Hansard’s advice.

Here’s the code:
#!/usr/local/bin/nush
(puts "Content-type: text/html\n")

(set srandom (NuBridgedFunction functionWithName:"srandom" signature:"vI"))
(set random (NuBridgedFunction functionWithName:"random" signature:"L"))
(srandom ((NSDate date) timeIntervalSinceReferenceDate))
(set index (+ 1 (% (random) 6)))

(puts <<-END
<html>
<head><title>icanhasnu</title></head>
<body>
<a href="http://blog.neontology.com">
<img src="/images/icanhasnu#{index}.jpg" />
</a>
<p><a href="http://flickr.com/photos/thenextweb/1437704797/">
Photo credit: Boris Veldhuijzen van Zanten
</a></p>
</body>
</html>
END)
Comments (0) post a reply