RSS hackety org

http://hackety.org

filling your pockets & hat with code

Last checked about 1 hour ago.

25 people have subscribed to this feed.

Feed frequency

post frequency (last month)

PostRank™ filter

latest 15 posts

« older items




Saturday December 6th, 2008

1.0

Inside Shoes 2

hackety org From hackety org, 1 month ago, 0 comments Comment

The second “stable” release of Shoes has flown. We still have a lot to do. But, hey. It’s happening, right?

This time I have some detailed release notes, with screenshots and code fragments to help sort it all out.

The second release of Shoes (called “Raisins” by many) is a culmination of a year of feature-filled additions to the first, experimental release of Shoes (titled “Curious”.)

This release adds a built-in manual, an error console, RubyGems integration, simple asynchronous downloads, an in-memory and database-backed image cache, support for external fonts, and, most prominently, its own unique library for packaging apps into little executables. OS X support is significantly better, as we switched from Carbon to Cocoa.

A lot of these features were fleshed out here on the blog, with your responses proving very so very valuable indeedy.

So, thanks for following along. Shoes 3 ("Policeman") will come around in, oh, January, I’d hazard.

Thursday December 4th, 2008

1.4

The Frustrating Magical Aspect

hackety org From hackety org, 1 month ago, 0 comments Comment

Julien Léonard: Actually, a graphic is foremost a composition of basic shapes and color. It is not their absolute values (that is absolute spatial and color coordinates) but their relations that matters. This is even more true because our visual perceptive chain processes its inputs in a relative way, as paradoxical visual games highlight it.

Tuesday November 25th, 2008

4.1

Seven Years Later, Proce55ing Leaves Beta!

hackety org From hackety org, 1 month ago, 0 comments Comment

Daniel Shiffman: At New York University’s graduate ITP program, Processing is taught alongside its sister project Arduino and PHP as part of the foundation course for 100 incoming students each year. At UCLA, undergraduates in the Design | Media Arts program use Processing to learn the concepts and skills needed to imagine the next generation of web sites and video games. At Lincoln Public Schools in Nebraska and the Phoenix Country Day School in Arizona, middle school teachers are experimenting with Processing to supplement traditional algebra and geometry classes.

Saturday November 22nd, 2008

1.2

Running Hot

hackety org From hackety org, 1 month ago, 0 comments Comment

Yes-s-s, Zed takes me on! Here’s a good part:

Zed Shaw: Why actually blessed me with his presence during one of my hacking sessions and made me feel smarter by association. I showed him Ragel (which he used to write Hpricot), and showed him some vim tricks, and he talked to Obie. It was great just having him warming the air near me.

My coils tend to run VERY HOT. And I fart a lot.


He makes a very sore point about Shoes “taking that wonderfully stable Ruby interpreter his friend Matz wrote to the edges of all that is possible in computing.”

Ouch, that smarts. And it’s totally true. I’ve had a rough time getting Ruby 1.8 to work out. I don’t really have any defense. I don’t see Shoes as this incredible answer to everything. It’s a bit hokey and it’s a bit trite.

Alex Fenton: I admire Shoes but it’s not the best choice for much desktop application programming. It’s not going to “open up a new world”… naming Shoes a ‘toy’ is not a slur; play is important in life. It’s an influential experiment.

I agree with this! It’s a toy, it’s for fun and I trust that nobody takes it very seriously.


Learning Ragel and Lemon at the feet of Zed Shaw was a classic time, for sure.
Tell me more about this passive aggressive thing, though. Do I have to have a deep hidden agenda, a long-standing personal beef or an alterior move in order to simply call a guy Hannah Montana?

Friday November 21st, 2008

7.3

A Costly Parade

hackety org From hackety org, 1 month ago, 0 comments Comment

Adam Wiggins: First, Rubyists love elegance.

Daniel Lyons: Every programmer worth a damn thinks they love elegance.

Monday November 17th, 2008

2.4

Something Like PyArg_ParseTuple For Ruby

hackety org From hackety org, 1 month ago, 0 comments Comment

Calling into Ruby from C is great, but I’ve noticed that I spend a lot of time casting arguments coming into each function.

 rb_scan_args(argc, argv, "11", &port, &opts);
 if (rb_respond_to(port, rb_intern("to_str"))
   StringValue(port);
 else if (!rb_respond_to(port, rb_intern("read")))
   rb_raise(rb_eArgError, "a String or IO object only, please");
 if (TYPE(opts) != T_HASH && !NIL_P(opts))
   rb_raise(rb_eArgError, "options must be a hash");

Ruby is dynamically typed, but object types are a bit more reified in C. The TYPE macro can check an object to see if it’s a T_FIXNUM, T_HASH, T_STRING, T_ICLASS, etc. You can duck type all you want, but when you’re inside an extension, you’ll need to know the type before calling rb_str_cat or rb_hash_aref.

And StringValue does this, it’ll cast using to_str and then make sure you’ve actually a real T_STRING.


I’m disappointed with rb_scan_args. It’s wimpy. The function signatures it uses aren’t very expressive. It’s basically describing arity and that’s it.

One thing I like better in Python’s API, though, is the PyArg_ParseTuple function and its cousins.

 const char *file;
 const char *mode = "r";
 int bufsize = 0;
 ok = PyArg_ParseTuple(args, "s|si", &file, &mode, &bufsize);
 /* A string, and optionally another string and an integer */
 /* Possible Python calls:
    f('spam')
    f('spam', 'w')
    f('spam', 'wb', 100000) */

The function signature is more expressive here ("s|si"), indicating which types are allowed. You don’t have to check the types individually, nor do you need to throw individual exceptions.


Here’s an equivalent I’m working on for Ruby:

 rb_arg_list args;
 rb_parse_args(argc, argv, "s|h,-|h", &args);
 /* a string and optionally a hash OR an IO and an optional hash */

The rb_parse_args function returns the number of the match. If the first signature ("s|h") is matched, you get 1. If the second signature is matched, you get 2.

I’m planting this in a switch statement when I want to overload a method.

 rb_arg_list args;
 /* "k" means Class, "h" means Hash */
 switch (rb_parse_args(argc, argv, "kh,h,", &args))
 {
   case 1: /* "kh" - style(Link, :background => white) */ break;
   case 2: /* "h"  - style(:width => "100%") */ break;
   case 3: /* ""   - style() => {...hash of styles...} */ break;
 }

This is saving me some tedium. In typical shoddy form, my error messages blow. I am undisciplined’s middle name.

Ah, how good it feels to be inspired by Python. A bit good, a bit slimey. I’m like Joe Lieberman, guys.

Monday November 3rd, 2008

5.9

Hpricot Strikes Back

hackety org From hackety org, 2 months ago, 0 comments Comment

This fruit is tiny, shiny and can be spit-polished in a single weekend.

Monday October 6th, 2008

6.0

Mixing Our Way Out Of Instance Eval?

hackety org From hackety org, 3 months ago, 0 comments Comment

 require 'mixico'

 def Builder.capture &blk
   mix_eval(self, &blk)
 end

Saturday September 27th, 2008

3.0

Textarea Resize And Curly Quotes For Conkeror

hackety org From hackety org, 3 months ago, 0 comments Comment

 function resize_textarea_up(field) {
   var h = field.offsetHeight;
   if (h > 120)
     field.style.height = (h - 60) + "px";
 }
 function resize_textarea_down(field) {
   field.style.height = (parseInt(field.offsetHeight) + 60) + "px";
 }
 interactive(
   "resize-textarea-up",
   "Resize a textarea to be smaller.",
   function (I) call_on_focused_field(I, resize_textarea_up)
 );
 interactive(
   "resize-textarea-down",
   "Resize a textarea to be taller.",
   function (I) call_on_focused_field(I, resize_textarea_down)
 );
 define_key(content_buffer_textarea_keymap, "C-up", "resize-textarea-up", $category = "Movement");
 define_key(content_buffer_textarea_keymap, "C-down", "resize-textarea-down", $category = "Movement");

Thursday September 25th, 2008

4.4

A Legend Never To Be Solved

hackety org From hackety org, 3 months ago, 0 comments Comment

Monday September 15th, 2008

6.7

Documents Reveal Django Pony, Caught In Tail Of Lies

hackety org From hackety org, 3 months ago, 0 comments Comment

Tuesday September 9th, 2008

1.5

Sorting Out Libskia

hackety org From hackety org, 4 months ago, 0 comments Comment

Vladimir Vukićević Another graphics library, Skia, has recently appeared as part of the Google Chrome code drop. It’s unfortunate that Google felt they needed to develop their own alternative in a closed fashion instead of joining an existing open source project. The Cairo project, and through it the many open source projects that depend on it, could have benefitted from the work that was done on Skia behind closed doors. Even worse, unlike most of the rest of the Chrome code, Skia is licensed under the Apache Public License v2.0. This creates difficulties in being able to reuse the Skia code in most projects.

However, on a happy note, hopefully it will ignite a performance race between itself and Cairo. I also wonder if Cairo will ever pick up what Skia has in the way of effects and animation. Cairo does have filters, gradients. But not blurs and lighting effects.

The biggest obstacle to using Skia on its own, though, is that Skia is really only partially released. It’s a 403. Allegedly, some folks were able to nab the source during a brief window on March 4th of last year. And the source code in the Chrome tree is a snapshot that lots incomplete. For example, much of the native code (to paint directly to X11, Windows, OS X contexts) seems missing.

For my part, I’d like to see how Shoes would run if forked to be Skia-powered. Can’t seem to hook it all up just yet.


Skia can be built seperately, though.

$ git clone git://github.com/why/skistrap.git
$ cd skistrap
$ make fetch
$ make

Presuming you have the includes and libs for libpng, libjpeg, libgif and libX11, you’ll end up with libskia.so.

There’s also a make test, but I haven’t got it hooked up to X11 quite yet, as there’s no ports/SkOSWindow_Unix.cpp or the like. And it looks like the GL bindings it uses are for other platforms.

Thursday August 28th, 2008

The Funny Chip

hackety org From hackety org, 4 months ago, 0 comments Comment

Henri Bergson: This is just why the tragic poet is so careful to avoid anything calculated to attract attention to the material side of his heroes. No sooner does anxiety about the body manifest itself than the intrusion of a comic element is to be feared. On this account, the hero in a tragedy does not eat or drink or warm himself. He does not even sit down any more than can be helped. To sit down in the middle of a fine speech would imply that you remembered you had a body. Napoleon, who was a psychologist when he wished to be so, had noticed that the transition from tragedy to comedy is effected simply by sitting down.

Oh, is that all? Merely take a seat and it’s comedy? Hot socks. I’m afraid we have seriously overdone it. Prevailing notions of today dictate that a sit must be accompanied by a stamp of the foot, three Porky Pig impersonations and an offstage fart. How outmoded is this Napoleon?

Friday August 15th, 2008

Threaded XMLHttpRequest In Shoes

hackety org From hackety org, 4 months ago, 0 comments Comment

Threads can be tough and don’t suit beginners very well. And, well, Ruby threads can tie up the main app thread.

So, Shoes steals the underpinnings of Ajax to give you asynchronous downloads without needing to get into threading. Many of the young Sneakers are building Twitter and Flickr apps; it seemed the morally upright thing to do. In addition, I was able to use these HTTP threads to load remote images in the background. So, in Shoes, images loaded from the web will appear as they load.

Here’s the simple-downloader.rb from the samples that come with Shoes:

To achieve this, Shoes uses platform code for both threading and HTTP. On Windows, CreateThread and WinHTTP. On Linux, pthread and curl. And, on OS X, NSDownload and NSThread.

Downloading is reduced to a single line:

Shoes.app { download "http://shoooes.net/shoes.png", :save => "shoes.png" }

This happens asynchronously, so shoes.png won’t be there yet when this method ends. It might be huge. It might appear an hour later. You can attach a finish event to be notified when the download is complete.

Shoes.app do
  download "http://shoooes.net/shoes.png", :save => "shoes.png" do |dl|
    alert "Scuse me. Your shoes.png has arrived."
  end
end

Omit the :save option and you can get back the download as a string.

Shoes.app do
  download "http://hacketyhack.net/pkg/osx/shoes" do |dl|
    alert "The latest OS X download is: #{dl.response.body}"
  end
end

You can also attach :method, :headers and :body options to the download, if you want to customize the request beyond that. I studied XMLHttpRequest closely and tried to be sure the same things could be done with this.


As for events, you get four of them: start, progress, finish and error. You can either pass proc objects in as options:

Shoes.app do
  url = "http://shoooes.net/dist/shoes-0.r905.exe"
  status = para "Downloading #{url}"

  download url, :save => "shoes.exe",
    :start => proc { |dl| status.text = "Connecting..." },
    :progress => proc { |dl| status.text = "#{dl.percent}% complete" },
    :finish => proc { |dl| status.text = "Download finished" },
    :error => proc { |dl, err| status.text = "Error: #{err}" }
end

Or, use the method syntax:

Shoes.app do
  url = "http://shoooes.net/dist/shoes-0.r905.exe"
  status = para "Downloading #{url}"

  get = download url, :save => "shoes.exe"
  get.start { |dl| status.text = "Connecting..." }
  get.progress { |dl| status.text = "#{dl.percent}% complete" }
  get.finish { |dl| status.text = "Download finished" }
  get.error { |dl, err| status.text = "Error: #{err}" }
end

The last thing I will mention is that every queued download is attached to the window containing it. When you close the window, the download stops. So, if you’re queueing a download from a temporary popup, be sure to queue it on the main app window.

Wednesday August 13th, 2008

Those Vintage P K D Covers

hackety org From hackety org, 4 months ago, 0 comments Comment

It just baffles me. There’s a landslide of interesting Philip K. Dick covers out there. And yet, were you to pick up The Man in the High Castle, you’d likely wind up with the schmaltzy construction paper torso of astonishment at right. Are those supposed to be surprise lines or something? No, that naked, armless guy is embarassed, poor thing! “Hey, I thought I was posing for a can of Paul Mitchell primping wax! What’s with all this dystopia??”

Couldn’t we have just stick with white tiger on a ledge? Or czech this one!

See, this is exactly the benefit of used books. Aside from the glorious marginalia and ad-hoc footnoting, you get to find a nice, fun cover that isn’t around no more. And where does one go to scoop up used books? You go to AbeBooks, probably.


Here is what AbeBooks looks like:

Some entries have covers, but a lot don’t. Usually they only show the covers of the newest editions.

However, we can grab some editions from the cover library at LibraryThing:

This hack will only add covers to AbeBooks. If Abe already shows a picture (and some booksellers do show a photo of the actual book from their inventory,) then those images will be left alone.

Of course, some entries are still blank. If there is no ISBN. Or if LibraryThing lacks the cover — which is common, but less common than Amazon.


Here’s a shot of an updated book page, with the real cover.

See? A fine, illustrated cover from days of yore. Devoid of panicky torsos and their ilk.

The Greasemonkey script is entitled AbeBooks Covers at Userscripts.org. Find yourself a Clooney-free Solaris.

« older items