06.26.10

1D eye

Posted in General at 12:02 pm by Steven

Barcode scanners get a great algorithmic advantage by having a 1D scanning laser eye. Kinda cool.

06.19.10

Serious omission?

Posted in General at 6:16 pm by Steven

I’m reading The Success of Open Source, which seems to be a pretty interesting analysis of the sociopolitics of open source development models. But I just noticed what seems to be a big omission: I can’t find “BDFL”, “van Rossum”, or “Python” in the index. I have a feeling that he’ll still cover the BDFL topic in there in some guise, but even if so, how can I excuse the absence of Python in a book about the SUCCESS of OPEN SOURCE? Geesh :-/.

05.20.10

C++ error messages

Posted in General at 7:55 pm by Steven

OK, one thing I don’t miss about C++ is the error messages. Here’s an incredibly obtuse way to say something:

In file included from /usr/include/c++/4.4/bits/stl_algobase.h:67,
                 from /usr/include/c++/4.4/bits/char_traits.h:41,
                 from /usr/include/c++/4.4/ios:41,
                 from /usr/include/c++/4.4/ostream:40,
                 from /usr/include/c++/4.4/iostream:40,
                 from ../src/Flipper.cpp:1:
/usr/include/c++/4.4/bits/stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits > > >’:
/usr/include/CGAL/centroid.h:833:   instantiated from ‘CGAL::CGALi::Dispatch_centroid > >, CGAL::Point_2 > > >’
../src/Flipper.cpp:102:   instantiated from here
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:127: error: no type named ‘iterator_category’ in ‘class CGAL::Point_2 > >’
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:128: error: no type named ‘value_type’ in ‘class CGAL::Point_2 > >’
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:129: error: no type named ‘difference_type’ in ‘class CGAL::Point_2 > >’
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:130: error: no type named ‘pointer’ in ‘class CGAL::Point_2 > >’
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:131: error: no type named ‘reference’ in ‘class CGAL::Point_2 > >’

Translation: you don’t need to include ‘centroid.h’.

05.16.10

Offsetting a polyline

Posted in General at 10:33 am by Steven

Thanks to a question on StackOverflow, I did some playing with Java’s Graphics2D. Below is some code to generate an offset of a polyline, i.e. given a polyline (a string of connected line segments), generate a polygon that represents a thick version of that line.

Clearly, the Java guys took some shortcuts here, because the polygon ends up including a lot of interior segments that you don’t really want, etc. However, filling it using a nonzero winding rule covers a lot of sins. And I can understand why they committed those sins, since it’s kinda hard to do in general. Read the CGAL page about offsetting for an intro. Sometime I’ll have to investigate the shortcut methods in the OpenJDK source; looking at this output, I’m definitely curious.

Unfilled

Unfilled

Filled

Filled

import java.awt.BasicStroke;
import java.awt.Shape;
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;

public class StrokePath
{
    public static void main(String[] args)
    {
        // set line width to 6, use bevel for line joins
        BasicStroke bs = new BasicStroke(6.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL);

        // create a path for the input
        Path2D p = new Path2D.Float();
        p.moveTo(50.0, 50.0);
        p.lineTo(65.0, 100.0);
        p.lineTo(70.0, 60.0);
        p.lineTo(120.0, 65.0);
        p.lineTo(40.0, 200.0);

        // create outline of wide lines by stroking the path with the stroke
        Shape s = bs.createStrokedShape(p);
        // output each of the segments of the stroked path for the output polygon
        PathIterator pi = s.getPathIterator(null);
        while (!pi.isDone())
        {
            pi.next();
            double[] coords = new double[6];
            int type = pi.currentSegment(coords);
            switch (type)
            {
            case PathIterator.SEG_LINETO:
                System.out.println(String.format("SEG_LINETO %f,%f", coords[0], coords[1]));
                break;
            case PathIterator.SEG_CLOSE:
                System.out.println("SEG_CLOSE");
                break;
            case PathIterator.SEG_MOVETO:
                System.out.println(String.format("SEG_MOVETO %f,%f", coords[0], coords[1]));
                break;
            default:
                System.out.println("*** More complicated than LINETO... Maybe should use FlatteningPathIterator? ***");
                break;
            }
        }
    }
}

Elicitation

Posted in General at 10:19 am by Steven

Been playing a little bit on Stack Overflow. Got interested after a few of my web searches ended up there and there were actual answers (if you’ve searched the web for programming questions before, you know the value of the average result on a forum site tends to zero).

Among the other potential positive values of answering questions there, I noticed one today: the process tends to elicit memories of knowledge or talents that I had forgotten that I have. Should be interesting.

05.15.10

Is there a word for this?

Posted in General at 6:26 pm by Steven

What’s the word for an answer to a question in an internet forum of the form “Idiot! That’s so easy! Here’s a vague description of an unworkable solution that I clearly haven’t even begun to try myself: …”

I’d figure there’s a one-word description for that since it comprises about 80% of all answers on any given forum.

05.14.10

Libraries, a few things I love about

Posted in General at 4:44 am by Steven

they’re a great place to practice my particular pointillistic style of info-dabbling.
that subliminal feeling of immersion in a physicalized potential-space.
the cohabitation of old and new, from the ancient-obsolete to the fantastic-futuristic.
the quiet. The noise.
the slow unfolding of a hypercompressed universal homunculus.
the smell and security of paper.
knowing that these other people are like me in a certain way.
the uncountable fragments of freedom recoalescing.

05.07.10

Computer-generated thingy

Posted in General at 10:49 am by Steven

I didn’t quite get the effect I was looking for, but I’m kinda done messing with it.

Springy thing


Click for a closer look.

05.04.10

Untitled

Posted in General at 8:20 pm by Steven

I don’t know why, but I sorta like this. I better post it before I remember that it’s not very interesting at all…

Click for ghastly detail.

Bypasses

Posted in General at 4:24 pm by Steven

There’s the book I was looking for… I looked at this briefly at the library one day, found it intriguing but didn’t really pay a lot of attention to it, then yesterday found myself ‘discovering’ the basic idea of the book again. But having since forgotten the title, and the library having moved the whole section to another place so I couldn’t use place-memory to find it, and failing to find it in the area where I think it should have been moved to, but remembering the general sort of books I was looking for when I did happen upon it, and using the LOC catalog browse-by-call-number feature, I finally found it again: Bypasses.

The basic idea behind the book is that a major problem solving technique that appears in various guises is to transform the problem from one domain to another, solve the transformed problem, then transform the solution back to the original domain. In a pseudo-mathematical manner of speaking: T-1MT. The author gathered examples from different fields and made some arguments about the generalization. Don’t remember a lot about it, but I’m going to find a copy again and read a bit more…

04.25.10

Launching URLs after Ubuntu 10.04 upgrade

Posted in General at 11:28 pm by Steven

I recently upgraded a machine to Ubuntu 10.04, which has been an overall positive experience. But, the one bad thing was that I could no longer launch links from my emails or RSS feeds (using Thunderbird and RSSOwl, respectively).

In searching for the answer, I used
strace -f >trace.txt 2>&1
to try to see what was going on. I found that somehow, something was trying to launch firefox-3.5, which no longer exists (3.5 having taken over as the default version now). Nothing in /etc/ was referring to this… Some searching on the web led me to learn about xdg-open, which calls gnome-open, which uses settings in GConf to figure out how to launch a URL. Launching gconf-editor and finding ‘/desktop/gnome/url-handlers/http’ and ‘/desktop/gnome/url-handlers/https’, I saw that the command for each was ‘firefox-3.5′. Changed those back to ‘firefox’ and everything was cool again.

Now that I see that, I think I used gconf-editor to set those the other way when I first started using firefox-3.5. So it’s sorta my fault, although it wouldn’t be a terrible thing if the install scripts looked for and repaired that sort of error.

04.17.10

Searching for anagrams

Posted in General at 12:16 am by Steven

Occasionally I get on a little anagram kick. Last time, I wrote a little program that let you input a starting text, then interactively create your anagram text. As you typed the anagram text, it would complain if you used a letter that wasn’t available, or suggest words from the dictionary that were available to you. I made the search pretty fast by putting each word in the dictionary into a sort of radix tree, where both internal nodes and leaves had lists of words that could be formed with the letters used thus far on that path.

This time around, I wanted a bit more of an automated approach. I haven’t seen any great results yet, but here are some that are at least sorta evocative:
“The Miss Rhode Island pageant” < => “The time and rags and polishes”
“federal constitution” < => “failure to discontent”
“that girl with sunbonnet eyes” < => “but only the greatness within”
“college teaching is almost a” < => “glance at the seismological”
“a cut over his left eyebrow” < => “over by the sluice of water”

The approach I took this time was to start with an English corpus (well, a couple, appended, totaling 3M words). For each ‘phrase’ (sequence of consecutive words, really) of between 3 and 6 words, I stick the phrase in a list in a hashmap, where the key is the sorted list of letters used in the phrase. After eating through the whole corpus (which bloats the Python hashmap to about 4GB of RAM), I look for any lists of length longer than one, sort and filter the results to be a little more useful, and spew out the results. Even though the input comes from a nominally grammatical source, there’s still plenty of dumb junk, so it still requires a human to pick out the few good answers, and maybe do some word reordering. And even after that, you end up with what you see above, so, ya know, why bother? Just cuz.

04.09.10

Another 100-word story

Posted in General at 11:22 pm by Steven

I’m ‘playing dead’, waiting for them to cut the rope off their bumper and peel away. This sort of outcome is really a drag, but I still like to see it out. I think it gives them a feeling of power. That’s close enough to success, for me. I hear my show described as ‘passive recruitment’. No. I mean, definitely, if someone wants to become a zombie, I’ll give ‘em a bite, but what I’m really trying to do is convey the ineffable sense of freedom that we feel on this side. Or give just ‘em a little thrill. Whatever.

« Previous entries Next Page » Next Page »