... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2009-05-30

"Hello World" Using Long Integers

I enjoyed the Python program exhibited on Poromenos's blog that prints out "Hello World" using curve-fitting. I wanted to play copycat in Java, but wanted to use an exact solution to the equation instead of rounding off. The result is exhibited below.

public class HelloWorld {

    public static void main(String arguments[]) {
        for (int i = 0; i < 13; ++i) {
            System.out.print(f(i));
        }
        System.out.println();
    }
    
    private static char f(int x) {
        return (char)(
                ( 49816166400L
                + 1114492383360L * x
                - 3487560668352L * x * x
                + 4521056833128L * x * x * x
                - 3246967654612L * x * x * x * x
                + 1447974643830L * x * x * x * x * x
                - 423730694651L * x * x * x * x * x * x
                + 83502380214L * x * x * x * x * x * x * x
                - 11141107791L * x * x * x * x * x * x * x * x
                + 991358610L * x * x * x * x * x * x * x * x * x
                - 56296097L * x * x * x * x * x * x * x * x * x * x
                + 1844058L * x * x * x * x * x * x * x * x * x * x * x
                - 26497L * x * x * x * x * x * x * x * x * x * x * x * x
                ) / 479001600L
            );
    }
}

In case you are wondering, I captured a transcript of the Mathematica session where I generated that program (PDF).

2009-05-19

lambdaj

lambdaj uses CGLIB proxy generation and Hamcrest conditional expressions to implement a DSL that allows you to write pseudo-functional collection iterations in Java.  Like this:

forEach(personInFamily).setLastName("Fusco");

Or this:

List sortedByAgePersons = sort(persons, on(Person.class).getAge());

Slick, although all its tricks are done at runtime using proxies and reflection.

2009-05-01

Git Gui Bash Tool on Windows

When on Windows, you can add a Bash tool to the Git Gui by adding a config entry like this:

[guitool "Git Bash"]
	cmd = cmd //c "C:/app/Git/bin/sh.exe --login -i" &
	noconsole = true

Git/MinGW versus Windows

On Windows using the Git/MinGW package, I was trying to use the command git rebase -i HEAD~3 to rewrite history interactively.  By default, VIM is used to edit  the rebase command file.  Unfortunately, it does not function properly in a plain old CMD window.  Also, Wordpad would probably be a better choice anyway.  I ran in to difficult configuring this.  After much experimentation, I discovered that the following Git configuration would work:

git config --system core.editor "cmd //c start //wait wordpad"

The /WAIT is needed to make sure that Git doesn't just carry on immediately after START returns.  START is needed to make it easier to launch Wordpad which does not usually live on the PATH.  Finally, the doubled slashes are need to inhibit MinGW's automatic pathname expansion (which rewrites paths: /c/xyz -> c:/xyz and /wait -> c:/mingwinstalldir/wait).

Blog Archive