One Weird Trick

A cow-orker taught me this awesome trick:

Instead of putting all cables and stuff into a box and letting them get all tangled, put them into transparent plastic bags.

See?

And it’s not like I have OCD, so it’s not a sign of mental problems or anything.  It saves time in the long run!  It actually does!

And the other tip for today is: You can never have too many cables.  But you only need one (or two) of each kind.  Edit your collection!

Guest Blog: Pearls. Before: Swine

By guest blogger Bjørn Konestabo

In the world of candy, there is chocolate. There is liquorice. And then there is gummy. The gelatin based candy from the wondrous animal that just keeps on giving. Among the producers of such delights, the German based Haribo is the original G, molding the first gummy candy in the shape of a bear in 1922. The gummy bear is still their flagship product, and while other candy producers might foolishly boast to be still using their original recipe, Haribo claims to have continuously improved it for more than 90 years.

What sets these collagen-derived ursī apart from the rest are the flavors. While other gummy may contain barely enough flavors to mask the porcine origins, these gummy bears are positively bursting with flavor. The real magic happens when you scoff down multiple bears at once, unleashing a torrent of fruity excitement.

While Haribo has had a local presence in Norway for decades, the full assortment has not been available, most notably their most famous product, the golden bears, “Goldbären”, have been unavailable to norwegian consumers for quite some time, but today they can be found in a cheap household and party supply chain. This is an odd location for a premium product.

So are they the same thing? Amazon reviews suggest that all bears are not created equal, depending on country of origin. Preliminary testing finds the Norwegian sourced bears to be enjoyable, but unable to match cherished childhood memories of the originals. Then again, what is?

Science

The way of finding things out.

The bags seem similar enough. Pictures of fruit featured prominently on both bags. The Norwegian sourced on the left is revealed to come from Denmark. Only the German one offers Freizeitspaß it seems. Production and best-before dates are close enough for comparison, with only a two month disadvantage to the German bag.

There are six flavors of bears: Raspberry, strawberry, orange, lemon, pineapple and apple. Selection of candidate bears revealed color differences that complicated testing. This meant that the tester was not allowed to view the bear before consumption. It is surprisingly hard to guess the correct flavor without a visual cue, and only one flavor was correctly identified: The highest scoring german bear, pineapple.

Test was randomized in the order of bears and blinded.

Results

Type of bearGerman scoreNorwegian score
Raspberry53
Strawberry43
Orange43
Lemon54
Pineapple62
Apple54
Sum2919

It became clear for the tester that the bears could be segmented in two groups. One harder and more chewy, one softer and more flavorful.

Danish version states real fruit juices but not much. Also color additives are used.

Look at all the stuff that’s in the German bag! Brennessel? Stinging nettle? Seriously?

There can be no doubt. The Germans are keeping the good stuff for themselves, and while the ersatz bears are not an unpleasant experience, they fall far short of the greatness of the original.

The Gimp: A Complaint

With free software, you can’t really complain.  It’s free.  The people who made it don’t owe you anything.

On the other side, I try to make software as least annoying as possible.

I try, I fail.  But I try.

Today’s sermon is about The Gimp.

It’s a good program.  It doesn’t crash, and you can usually do what you mean to do after binging a while.

My use case is that I take pictures and then I crop them.  That’s basically it. 

The Gimp authors recently changed how images are saved.  To avoid people losing their valuable work, they’re now always saving images as Gimp packages instead of…  images.   With layers and stuff.  I guess that makes sense.

But it’s not my use case. 

Here’s how I use The Gimp.  I open images.  I crop them.  I save the images.  I exit The Gimp.

I used to be able to just do that.  Open the image.  Crop it.  Hit `C-s’ to save it and `C-w’ to close the image.

Then a new Gimp version happened.  `C-s’ now tries to save the Gimp bundle instead of the image itself.

So after looking around a bit, I find out that I have to “export” the image instead.  That’s control-shift-e.  Ok.

So move the mouse to that window and click “Export”.

Yes, I do want to replace that file.

Yes, I move the mouse cursor to the “export” button again, because I don’t care at all about these options.

Yes, I do want to close that image I just saved.

So the operation I used to do with one mouse movement, one `RET’, and one `C-s’ is now an operation that takes an approximate gazillion commands and moving the mouse all over the place.

This annoys me.

Gimp people, I know that you’re not evil. 

Probably. 

I know that complaining about free software not doing what you want it to do rates the response “Ok, so start crying, then.  Go head.  Boo.”

I know that I have no reason to complain, because you probably have  perfectly good reasons for changing your program in this weird manner.

But, really, there’s only one sensible way to respond to your new version.

It’s this:

That’s all.

The Internet Help Desk

 About once a month, I get really drunk and answer the Gmane email.  90% is “please remove my

message”, which I do.  If it’s from the person who asks to have it removed.

The other 10% are kinda … assorted.  I think this is of interest to you.  All of you.  So here I present a [redacted] extraction of those 10%s from tonight.  I don’t mean to be mean.  But c’mon.

Prepare to be puzzled.

—————

The below companies are using zeromq in the field of “financial
services”, “game devolpment”, “embedded systems”, ” academic research”,
“aeronatics”.

Microsoft
Zynga
Barclays

But we require the information about for what purpose these all above
companies ar using zeromq.[for example we are planing to use as a
message broker for sending messages between two clients] can you please
provide these informations as soon as possible. I need very early. I ll
be waiting for your reply.”

———–

Search title gets encoded as UTF-8/ISO-8859-1.  You want to wonder if
this is a bug.

———–

I’m building an AngelList profile, and need your help.  Can you do me
a favor and follow me by clicking here:

———–

I’m trying to get in touch with [redacted]. Do you have an email
address or his current contact information? Best Regards,
[redacted] Investigator

———–      

Ich war mir über die Veröffentlichung dieser Email nicht bewusst und
bitte Sie daher meine Personenbezogenen Daten aus dem Beitrag zu
löschen

———–

There’s a message with subject “Google”.  The body says “Cam on”.

———–

We have learned that unauthorized individual(s) secured a link
promoting our website [redacted].com on one or more of your web
properties.

———–

it got returned with this message.  my message is attached here for
you to  see. why was it returned?  i need for aall to know about
[redacted], and its pro capabilities,  and for those who use
[redacted], knocking it down,  saying its not production ready,are
mistaken.

———–

I got your contact in this post
http://permalink.gmane.org/gmane.comp.handhelds.phonegap/[redacted] I wonder
if you could create a new wifi network, entering the ssid and password
in the app and creating the network automatically.

———–

I need your assistance if you can. I accidentally sent a message to
the [redacted] email list last night with a live password in
it. The password is hardcoded in to dozens of machines, so changing it
would be… inconvenient, to say the least. I don’t yet see the message
on your archive page, so I can’t provide the URL link, but I wanted to
see if you could remove the message before it is processed and posted.

———–

This week, due to your GNAME postings, I just suffered the loss of an
important job opportunity, and contract because an individual obtained
the private communications I had not intended for publication by
[redacted]. After the list error I wrote several people on that list
ridiculed me.

As I informed Mr. [redacted], there are treatises between the Nations of
the United States and yours, I believe, Norway, which mandate
compliance with the California State and Federal privacy laws
respectively.

I have sent him as I will probably have to send you a Cease and Desist
Notice, in lieu of a possible Federal Civil Suit for Injunctive Relief,
and damages. If any internet content states that a person in the United
States does not want his personal email posted on the internet, you
must abide by the meaning of the content.

———-

Though the organization [redacted] expressly prohibits the publication
of any archived communications, my personal and private communication
was published on the internet, via GMANE.

Though Mr. [redacted] alleges that he has no liability, the origin of
the privacy violation originated from his negligent management of his
list.  I have notified you of the ANTI SPAM ACT of the US Government
which can be enforced due to the treaties between the US Government and
Norway. You have failed to respond in kind.

The penalties that can be adjudged against you due to your reckless
and knowing violation of the aforementioned act, and my privacy rights
under the California Constitution, the highest law in the land for any
one person living in the State of California, are very high.

The posting cost me a $76K job opportunity.

Displaying Animated Images With ImageMagick

The Internet Is Made For Cats

I’ve spent the day adding support for animated GIFs to Emacs via ImageMagick.  Emacs c
an display animated GIFs already, of course, but not via ImageMagick, so we couldn’t scale animated images.  Which is awkward.

An animated GIF is (basically) just a bunch of images in one blob.  However, the “complicated” thing is that all subsequent images may have transparencies.  So to compute image X, you have to unpack image 1 to X, and apply the non-transparent bits in each iteration.  Apparently.

Most of the work was googling around for how to do this, so to spare other people the same pain, I’m posting the (abbreviated) code here.

The weird indentation is because this is from the Emacs source.

To make this usable, you should also add caching so that you don’t have to compute all the overlays every time.

static MagickWand *
imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
{
  int i;
  MagickWand *composite_wand;
  size_t dest_width, dest_height;

  MagickSetIteratorIndex (super_wand, 0);
  composite_wand = MagickGetImage (super_wand);

  dest_width = MagickGetImageWidth (composite_wand);
  dest_height = MagickGetImageHeight (composite_wand);

  for (i = 1; i <= ino; i++)
    {
      MagickWand *sub_wand;
      PixelIterator *source_iterator, *dest_iterator;
      PixelWand **source, **dest;
      size_t source_width, source_height;
      ssize_t source_left, source_top;
      MagickPixelPacket pixel;
      DisposeType dispose;
      int lines = 0;

      MagickSetIteratorIndex (super_wand, i);
      sub_wand = MagickGetImage (super_wand);

      MagickGetImagePage (sub_wand, &source_width, &source_height,
                          &source_left, &source_top);

      dispose = MagickGetImageDispose (sub_wand);

      source_iterator = NewPixelIterator (sub_wand);
      dest_iterator = NewPixelIterator (composite_wand);

      /* The sub-image may not start at origo, so move the destination
         iterator to where the sub-image should start. */
      if (source_top > 0)
        {
          PixelSetIteratorRow (dest_iterator, source_top);
          lines = source_top;
        }

      while ((source = PixelGetNextIteratorRow (source_iterator, &source_width))
             != NULL)
        {
          int x;

          /* Sanity check.  This shouldn’t happen, but apparently
             does in some pictures.  */
          if (++lines >= dest_height)
            break;

          dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
          for (x = 0; x < source_width; x++)
            {
              /* Sanity check.  This shouldn’t happen, but apparently
                 also does in some pictures.  */
              if (x + source_left > dest_width)
                break;
              /* Normally we only copy over non-transparent pixels,
                 but if the disposal method is “Background”, then we
                 copy over all pixels.  */
              if (dispose == BackgroundDispose ||
                  PixelGetAlpha (source[x]))
                {
                  PixelGetMagickColor (source[x], &pixel);
                  PixelSetMagickColor (dest[x + source_left], &pixel);
                }
            }
          PixelSyncIterator(dest_iterator);
        }

      DestroyPixelIterator (source_iterator);
      DestroyPixelIterator (dest_iterator);
      DestroyMagickWand (sub_wand);
    }

  return composite_wand;
}