Saturday, May 23, 2009
Star Trek Rocks (spoiler free)
Monday, May 11, 2009
One cat, a chihuahua, and a turtle
Friday, April 3, 2009
A high-level language on the JVM
Alex Payne: I think programmers who’ve never worked with a language with pattern matching before should be prepared to have that change their perceptions about programming. I was talking to a group of mostly Mac programmers, largely Objective-C developers. I was trying to convey to them that once you start working with pattern matching, you’ll never want to use a language without it again. It’s such a common thing that a programmer does every day. I have a collection of stuff. Let me pick certain needles out of this haystack, whether its based on a class or their contents, it’s such a powerful tool. It’s so great.
Robey Pointer: I wanted to talk a bit more about starting to use Scala. It definitely wasn’t a flippant choice we made over a few beers one night. We actually agonized over it for quite a while. Maybe not agonized, but certainly discussed it for a long time. One of the biggest draws for us to Scala as opposed to another language, was that once you’d started writing in a really high level language like Ruby, it can be difficult and kind of annoying to go back to a medium level language like Java, where you have to type a lot of code to get the same effect. That was a really big draw for us. With Scala we could still write this really high level code, but be on the JVM.
That's from an Artima interview about the guys behind Twitter evaluating Scala.
It sounds about right to me. Scala is adventuresome in the high-level features it gives you access to, e.g. pattern-matching, higher-order functions, and mixins. However, it runs and is integrated with the JVM, so you can always use a Java library or write in low-level Java if you run into performance issues or need some API that Scala doesn't provide.
Saturday, March 14, 2009
SMTP relaying from OS/X
relayhost = mail.vc-graz.ac.at
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth
smtp_sasl_security_options = noanonymous
Note that if your mail relay runs on port 26, you can put the port number on the relayhost line, like this:
relayhost = mail.vc-graz.ac.at:26
Friday, March 13, 2009
Ivan Krstic on security-friendly languages
Now, while I’m already grossly overgeneralizing, I think the first group is almost useless, the second group is almost irrelevant, and the third group is absolutely horrible at explaining what the hell they’re talking about.He and the commenters then give some good introductory links.
Wednesday, March 4, 2009
Installing top-level code with JavaScript's eval
http://piecesofrakesh.blogspot.com/2008/10/understanding-eval-scope-spoiler-its.html
The following page also discusses the problem, but has a really good collection of comments:
- window.eval, what I tried to begin with
- window.eval, but with a with() clause around it. Some people report better luck this way.
- window.execScript, a variant of window.eval
- window.setTimeout
- adding a script tag to the document
What I did in each case was try to use the technique to define a function foo() at the global scope, and then try to call it. I tested these browsers, which I happen to have handy:
- Safari/Mac 3.1.1
- Firefox/Mac 3.0.6
- Firefox/Linux 2.0.0.20
- Firefox/Windows 3.0.3
- IE 6.0.2900.xpsp_sp3_gdr.080814-1236 updated to SP3
- Chrome 1.0.154.48
- window.eval: FF
- window.eval with with: FF
- window.execScript: IE, Chrome
- window.setTimeout: Chrome, FF, Safari
- script tag: IE, Chrome, FF, Safari
- The window.execScript function is available on IE and Chrome, and when present it does the right thing.
- The window.eval function only works as desired on Firefox.
- Adding a with(window) around the window.eval does make a difference, but I couldn't get it to do precisely what is needed for GWT. In particular, GWT does not have a bunch of "var func1,func2, func3" declarations up front, but such vars are assumed in some of the other web pages I read.
- I could not find a synchronous solution for Safari. Instead, setTimeout and script tags work, but they won't load the code until a few milliseconds have gone by.
- Script tags work on all browsers.
- Surprisingly, I couldn't get setTimeout to work on IE. From some web browsing, it looks like the setTimeout callback might run in the wrong scope, but I didn't investigate far. On IE, execScript is a better solution for the present problem.
if (window.execScript) {window.execScript(script)} else {var tag = document.createElement("script")tag.type = "text/javascript"tag.text = scriptdocument.getElementsByTagName("head").item(0).appendChild(tag)}
For the versions that install the code asynchronously (setTimeout or script tags), I changed the window.foo() line to be:function installFoo() {var script = "function foo() { alert('hi') }"// varying part}installFoo()window.foo()
window.setTimeout(function() { window.foo() }, 100)
// window.evalwindow.eval(script)// window.execScriptwindow.execScript(script)// window.eval with a withvar $w = windowwith($w) { $w.eval(script) }// setTimeoutwindow.setTimeout(script, 0)// script tagvar tag = document.createElement("script")tag.type = "text/javascript"tag.text = scriptdocument.getElementsByTagName("head").item(0).appendChild(tag)
Friday, February 6, 2009
Why not inject dependencies "manually"?
MockService mock = new MockService();
Client client = new Client(mock);
client.go();
assertTrue(mock.isGone());
private ClientFactory() {}
public static Client getInstance() {
Service service = ServiceFactory.getInstance();
return new Client(service);
}
}
