Categories
windows

Using Git from behind an NTLM proxy

For some reason the Git that ships with Cygwin (v1.6.6.1) won’t do the right thing with NTLM proxies. It seems that Git uses cURL underneath and that cURL can correctly handle NTLM authentication if the options are set correctly.

However, the version of Git I have isn’t capable of passing this information through. In fact, some browsing of the issues that people have with this suggests that there is more than one part of Git that isn’t able to work correctly with NTLM. So even if you’re able to get past the initial connection you probably won’t be able to fetch any of the tree.

The solution, in full then, is to use ntlmaps to act as a proxy to the proxy. All you need to do is to download the latest version of the app from: ntlmaps. Change the config file to include your authentication and proxy details, start it up and then set the proxy to be your new local one:

git config --global http.proxy http://localhost:5865

I can confirm that it works just fine. Not only that you can use it for any app that requires NTLM authentication but does not provide full NTLM support.

Categories
lisp

The Excel Gambit


Excel screen shot of XL-Gambit
XLREPL


In the spirt of shoving Lisp where Lisp should-not-go I have jammed Gambit Scheme into Excel.

If you’re interested in trying it out you should go and get the files RIGHT NOW at GitHub. You just need to add the compiled .XLL into your add-ins and use the formula =GAMBITC(“(+ 1 1)”) in a cell of your choosing.

Please note this is a proof-of-concept. You probably shouldn’t use it for anything important, most importantly because it probably leaks like a sieve. You should also know I only really tested it on Excel 2003. It should load into Excel 2007 but I didn’t try that yet.

Why? Because it’s there, and I’m here

Why did I do it? Well the rationale behind doing this was that I wanted to write an app for Excel in Scheme. I want to do that because I think it would be vastly superior to using .NET or VBA or COM. Having spent a few hours on it I think I could definitely achieve what I set out to do but whether I’ll actually go this route in the end I’m undecided about. More on that later.

Mature like a good cheese

The Excel API, as it turns out, is … well … mature. Now I like old things quite a lot. I’m old, and I like me just fine. One consequence of age is that we get a little extra baggage on the way. This is true of Excel too.

Now, IMHO one of the more challenging aspects of programming a long-lived project is version management. Especially version management of an API. Broken backwards/forwards compatibility of those APIs could be serious impediments to a new Excel’s acceptance. Unsurprisingly then Excel has a number of APIs that have all undergone various enhancements over the years. To me though the switch from Excel 2003 to Excel 2007 was the most significant, requiring the most additional cognitive load to work with. For now, and for simplicity, I have chosen to totally deny the existence of Excel 2007. But I’m coming back to it, oh yes I am.

I Eat Pain For Breakfast

I had read a bit online about the Excel C API and found it all hugely confusing. So I bought a book thinking that that would make it clearer. Although the author does attempt to explain how you might write an Excel add-in he does it in a way that makes programming from it hard. For example, the information I need is spread all-over the book. Answering a single question about Excel’s behaviour with respect to calling the core Excel4/Excel12 function necessitates flicking between the index and more than 10 different page sections.

The reason for this is probably that Excel is really a very versatile tool which is why a lot of the world’s business (large and small :)) seem to operate their database, accounts and customer details from it. So there’s not really one track through the development process. There’s literally hundreds, limited only by your imagination!

Having said that the book in combination with the Excel 2007 SDK was sufficient to pick through the rubble and build something workable. Maybe I’ll try and produce some guides/tutorials of my own to make the topic clearer. Maybe.

On the Gambit side there’s not much more documentation than what’s on the manual HTML page to help. Like the Excel book it is also very densely populated with information. IMHO its main failing is that it could really do with having more documentation of the C macro functions. Did I ever mention that I hate C macros? Well in Gambit these undocumented C macros are effectively what Gambit Scheme is written in and you kind-of need a fairly thorough explanation of how it all fits together to be able to make an effective glue with them. I will be coming back to this later when I try and construct lists from cell ranges.

Finally I decided to do this all in MinGW rather than the more usual VC++. Whilst going this route did cost me a bit of time I’d much rather use the GCC toolchain because I understand it better.

Where-to-now

Now that I have the interpreter in Excel I will probably work on tidying it up for Excel 2007. More importantly though, I want to see if I can exploit Excel 2007’s all important multi-threading capability.

If that all works out I might use it to make a custom add-in. I will develop the app from the REPL in Emacs using Gambit Scheme. When it’s done I’ll compile it up into a standalone XLL with Gambit. That’s the plan anyway.

Let me know if you like it, or can see a use for it. Encouragement is always good.

Categories
education flash

Some Sums Sum, Sum Don’t

My eldest daughter has been getting maths homework for a year or two now. We try and do the homework together and I try and make it fun but it’s hard. It’s hard because if she doesn’t understand something by the second time I explain it, then to her I become like the teacher in Charlie Brown. Blah Blah Blah. This is especially true if when I’m explaining elementary mathematics, I make a mistake in my explanation. This happens often and only causes to confuse her royally.

And so it was with the topic of number bonds. My wife discovered, by attending a parent’s maths workshop at the school, that the children were learning that certain numbers in base 10 arithmetic are bonded. The bonds are simply as follows:

  • 1->9
  • 2->8
  • 3->7
  • 4->6
  • 5->5

It’s fairly trivial but also fairly powerful in that once you know these bonds it’s a shortcut for mental arithmetic. We, as adults, know these ‘bonds’ so well that we probably don’t even recognise that we use them. The challenge then is to teach children this trick and thereby speed up their arithmetic ability.

One of the techniques that my daughter’s school uses is to send home ‘games’ that try and reinforce the learning they have done in the class. These games usually consist of a laminated sheet of instructions, a dice or two or other simple props. Usually these games are quite good and instructive. Some times they are totally confusing because they are meant to reinforce what was learnt in class and that doesn’t come across in the instructions. You’d think that I could ask my daughter to explain ‘how’ they should be doing it. It doesn’t work. Kids just aren’t that ‘meta’, that’s why they’re so much fun.

Now I have observed both my children playing on friv and Club Penguin. They are totally immersed in the most crappy Flash apps (although I have to say that most of them are actually quite fun!). So I thought I’d try and see if I could make a Flash game that would teach a little mathematics.

A while ago an ex-colleague posted about a super-cool Flash application he’d made. From that I figured out I could download the SDK and most of what I needed for free. However I thought I’d try the 60-day trial of Flex Builder. The added comfort of Flex builder is that it’s a pre-configured Eclipse for building Flash apps, so progress is pretty smooth-and-fast. Not sure I’d spend the $299 for a personal license though. It’s not that good.

I had always thought that Flash development was complex but it turns out that it really isn’t. If you can program Javascript, then there really isn’t that much extra to learn to make it work because you can use ActionScript (which is a derivative of ECMAscript as Javascript is). The biggest difficulty I found was with laying out text. Something that HTML laps up, but turns out to be really cumbersome in Flex. I’m probably just doing it wrong.

And so the unimaginatively titled ‘Number Bonds’ was born. Enjoy.

If you’re interested in the code it’s here. It’s pretty messy though. I’ve also made a back-story-free page about ‘Number Bonds’ here.

Categories
emacs

Awesomely awesome in its awesomeness

Sometimes some things are just so good that you have to shout about the fact that it’s good even though it does no-one any good.

Emacs is such a thing. It occurred to me today that I’d dearly love to write more for this blog, and one way that I might be able to do that would be if I could edit my posts in Emacs. One web-search later I’m reading about how trivial it is using weblogger and xml-rpc.

60 seconds after that I’m up and running, and writing this post. I didn’t even have to restart Emacs. That’s how awesome it is.

And to think that I used to berate people who used Emacs because I only used vi.

So now I’m praying to the saviour for redemption.

Categories
lisp

Mersenne Twister in Clojure

The Mersenne Twiser is a random number generator that has a lot of applications, particularly in finance. After discovering that there was no Clojure implementation at Wikipedia I decided to give it a try as my first attempt at something useful in Clojure. As it turns out it’s problably not a good candidate to be implemented in a functional language because the whole thing requires modifying a mutable array for every call to (genrand).

I’m not very excited by the solution because it doesn’t seem very lispy. It much more resembles the reference implementation, and gives the same results as it for all the tests I tried.

I’m sure it could be better though.

If it’s of any use to anyone you can find it here.