elfs: (Default)
Can you tell us more about the technologies you used to create this web application [Fridgemagnets]? I'd love to hear about the process you went through as you envisioned the project, chose technologies, and figured out how you'd code it.

Well, let's start off with the basics. If you look down at the footer, you'll see this line: "inspired by twittermagents.com and an allergic reaction to all things flash." Now the fact is I love +GOOD and the design sensibilities they had, but something about twittermagents rubbed me wrong. It wasn't just the Flash, although that was certainly part of it. It was the way the user was forced to create a 'fridgemagnet poem by putting them into a constraining box. People don't have a constraining box for their poems on their refridgerator: they just arrange them wherever they can and hope other people can make sense of them. We recognize a 'fridgemagnet poem by recognizing a meaningful and deliberate arrangement of words.

I already had a (fairly) complete toolbox: I knew that if I wanted to reproduce this in HTML5, I would be writing with HTML, Javascript, CSS, and I would probably be using jQuery. To simulate the "scatter" effect I would need a way to do CSS transform, so I searched for a jQuery plug-in that provided them. I would need jQuery-UI for drag-and-drop. And finally, to get the music effect of the original, I would need an HTML5 equivalent: a little searching and I found Buzz.js.

I don't really code in HTML, CSS, and Javascript anymore: I use HAML, Less, and Coffeescript instead. I like these technologies because they eliminate one whole class of errors. (They can introduce bloat and inefficiency, though, but it's easier to optimize a solution than fix a problem.) So my next step was to create a working environment where those were installed, and then write a Makefile to make converting from these pre-processed languages to their results easier.

I started with the HTML, since that was easiest: I knew I had three regions, a "board", a control panel and a footer. The control panel would have only a few things (volume control for the music, the shuffle button when I get around to it, the tweet button too). The last two had fixed heights. The board would have a "results" section to show the poem as it was being rendered.

I assembled some CSS as I was doing this to give the fixed-height items their necessary space.

At this point, I got stuck: what was I really doing here? At first, I was just throwing stuff at it to see how close I could get. I had some lovely backgrounds, and had some music, but what the heck was I really doing?

I wrote out some notes: The board must be resized when the user changes the size or orientation of their display. Words fill the board on start or shuffle event. A word has a bounding box, which defines how it looks and a larger box... No, that wasn't right: The board is full of tiles which have words on them. When a word is moved, we have to determine if it's part of a poem or not. Italicized words became classes, and bolded ones became events. Some events have to be abstracted: "moved" became "dragged" and "dropped," and had visual side-effects: the "pick up" and "put down" routines.

Now, since every tile has (top, left, height, width), I could theoretically know when two tiles were intersecting. I searched for "How to tell if two boxes are intersecting, naive."

The word "naive" is the key there: if someone uses the word "naive" to explain an algorithm, it's because they're going to show why it's naive and explain how to implement the algorithm correctly. This is what led me to game programming and the Separate Axis Theory. I gave myself a crash course in vector mathematics and wrote an SAT library for javascript over the weekend.

Once that was done, it was a fairly simple matter of (1) creating an object to hold each word, (2) adding the words to the board in a "hidden" way, (3) unmasking some 60 or so of them [Math.random < (60 / no. of words)], and (4) animating them to "fly in." All of these were basic jQuery capabilities.

I knew I need them to be drag-droppable, so I read the drag/drop documentation and added that capability.

This was the real fun. I spent a lot of time thinking about the tiles and collisions, and trying different ways of making sense of the problem until I wrote out the basic algorithm. Then it was a matter of reasoning about the results: board, poem, and tile. Was the tile in a poem, or had it left a poem? If the poem split in half, what was the poem "now"? None of this had "side effects," so it was all about geometry and decision making: pure functional stuff. So I made up rules: "The poem determination routines all take a poem and a word, and return a new poem." The new poem might be an exact copy of the original, if all you did was move a word slightly, but as long as my functions did exactly that, I knew they weren't going to break anything else.

After that, it was a matter of rendering the side effect: drawing the "found poem" in the lower left corner.

I had never worked with game algorithms like this, but they were only a short stretch from the clock algorithms I'd used for Arc Experiments. Abandoning my beloved Backbone for a home-made solution was a matter of understanding that I had only one data structure and would save a ton of unneeded code managing it myself. The music API was "just" an API: anyone could use it after reading the documentation.

The biggest insight was the creation of the Dimensioned prototype, which allowed me to use a "write-only DOM" method. I'd learned about that by following the Javascript Zeitgeist on Delicious. I haven't quite hit it-- as I said, this is a rough draft, but it expresses some essence of the final draft, and I wanted others to see where it was so far. But by using it, I was able to write simple code that said things like "Tell me if these two objects are intersecting," which then made scanning for intersections, and groups of intersections, fairly trivial.

In many ways, programming is more craftsmanship than engineering: we know what tools we have, and we know what things we'd like to do. Sometimes I stretch my skillset out in one direction, and that's what Fridge Magnets does. Reading through the code, you can see little bits that are commented out still: during the "fly in," words aren't supposed to land on top of each other, but they do, because the check just says "they're not colliding," even when they are. It turns out that was okay, visually-- but now I have to say something like "When a user picks up a word, bring its stack order up one so it's 'above' everything else." That may be more visually jarring than sliding it out from under a covering word-- I'll have to see.

Nitinol!

Feb. 28th, 2012 09:33 am
elfs: (Default)
I loved Omni magazine as a kid, the slick Penthouse-for-Science Fiction readers that Bob Guccione published back in the 80s. One of the best articles, one of the few that sticks in my mind, was about the state-of-the-art in metamaterials, and how weird alloys and structured metals were going to change various industries. I was fascinated by the properties of nitinol, a metal that can be forged into different shapes and different temperatures, and will return to those shapes when exposed to other temperatures in a similar range. The magazine was full of the usual futuristic raves about all the interesting uses for this new technology.

Kouryou-chan's braces are made with nitinol. Apparently, the wire is cooled to room temperature, inserted into the mounts on the molars, then fitted to the rest of the appliance and locked down. As the metal warms up to body temperature, it contracts and exerts the force necessary to bring the teeth into line. Different weights of nitinol wire are used throughout the lifespan of the therapy to moderate the force on her teeth as they get closer and closer to their proper alignment.

Now that's kinda cool. I'm living in my own future.
elfs: (Default)


Because Nerd Rage is a great game.
elfs: (Default)
Dear Lazyweb,

I need help with EC2. I'm an EC2 beginner, and I have a one-time task that needs a lot of CPU. I can do it serially, in which case it'll cost me about $200. Or I can run it all at once on many EC2 instances, but I don't know how to do it. The task consists of a series of basic unix commands.

What's the fastest way to get sufficiently up to speed on this that I can build a linux instance ready to do the task, fork off about a thousand of these puppies, and then tell them "go?"

I'm not looking for actual programming advice; I want meta-advice. What books and/or tutorials should I read?


(Subject line explained here.)
elfs: (Default)
I spent a solid two hours figuring out how to do this, so I decided to share with the world. Those of you with small monitors (or other strange habits) might have operating system dock (the thing at the bottom or top of the screen that you use to start programs, check the clock, and see what's running away with your CPU and network) set to "autohide," so it comes and goes as you mouse over it.

If you've ever wanted to simulate that in your HTML, I've figured out how to do it with jQuery. I've even provided a bare-bones skeleton of a dock, along with a working example. Feel free to embellish it at your leisure.
elfs: (Default)
The other day I was driven to shrill madness by a job posting that asked if I could "utilize the word press technology" (to which I responded, "Yes, I can use and develop for Wordpress, but probably not for you").

Just a few minutes ago, I posted an entry wondering about whether or not pornography cheapened some relationships because it depicted sodomy as "expected and normative," and wondered if I hadn't just bitten myself with hypocrisy. (One of the things I will always thank Usenet for: it taught me how to spell "hypocrisy" correctly.) Perhaps I should have said that pornography depicts sodomy as "expected and normal."

There is a difference, however: "Normal" is what people do. "Normative" is what people expect. A normative declaration is a prescriptive one: it says what people ought to do. Pornography might, in fact, depict anal sex as normal: certainly it is in the pornoverse. But it's pornography's depiction of anal sex as normative that is problematic: "All chicks dig getting fucked in the ass" is a normative depiction, and we should challenge that depiction if we can and try to substitute for "all" the much more sensible "some."

Likewise, I think there are places where one "utilizes" Wordpress. If you push it hard enough, plug in enough stuff, and write your own code, Wordpress can be used as a CMS like Joomla or Drupal or even Django, as a base of code that one can utilize: "take full advantage of; to make do with something not originally used for a purpose." For Seattle Metropolitan Credit Union, for example, I "utilized" the Wordpress treewalking engine to create a previously non-existent relationship between post categories and pages. But I doubt the job poster people were seeking that kind of Wordpress development.

Still, if they are, I'm their man.
elfs: (Default)
To spare you all the reams of source code, I'll just point you to my latest geek addition:Template recursion in Django with Treebeard, in which I solve one of the great conundrums of Django: how to draw stuff recursively. Django templates just don't like recursion, and I do.

I'm slowly but surely learning how to express myself in Django. Stuff like this is deep geek head-first no-nonsense, which is why I enjoy it. Now that I've got a heirarchal rendering system and understand how the heirarchal engine works, my next step is to create it as a manipulable list in proper HTML with Javascript handling.
elfs: (Default)
I went through an accidental upgrade Wednesday afternoon. I wasn't paying attention when I installed something, and it sucked in the latest ATI driver for my laptop along with it. Cursing, I tried to back out, only to discover that the stable driver I'd been using since February of last year was no longer supported by the Gentoo team, since too many other people had decided it wasn't stable after all.

I managed to find an old repository of that driver, but installing it didn't work; I got a big "Unsupported Hardware" watermark in the lower right-hand corner, and many of the 3D features were broken. I decided to go for the full upgrade: the latest driver with the latest X server.

It took forever, but when it was over I had it all, and to my pleasant surprise hibernate/suspend still worked as advertised, PopCap games still work wonderfully, and most 3D features are still operant. I haven't had the courage yet to try and run Quake or Prey, but playing games on my laptop is a losing proposition anyway so maybe I won't bother.
elfs: (Default)
I, for one, am ready to reach out and shake the hands our new cybernetic overlords. Really. It's not going to take much to slim down those components an addition 15%, cover her in prosthetic-quality neoskin, and, well, it'll be all over after that. The human race is doomed.



Up next: The Panasonix DX Supervillain Personal Assistant.
elfs: (Default)
WINEPREFIX='/home/elf/.wine' wine 'C:\windows\profiles\elf\Local Settings\Application Data\Google\Chrome\Application\chrome.exe' --new-http --in-process-plugins

Viola'. Chrome on Linux. Sort-of. Change the username as applicable. I put the above into a command in $HOME/bin/chrome. Now I have another test platform. Yay!
elfs: (Default)
Anne C. is a blogger who writes about futurism and the promise of a medical or technological breakthrough that will lead to mental substrate independence in a blog entitled Existence is Wonderful. Normally, I read her for that, but she ocassionally gets personal and writes about her own issues with her aspyness.

In an article entitled Typical Special Needs, Anne points to an article in Time magazine about telecommuting. And one of the things she points out is that telecommuters complain about a lack of social interaction. The article goes on to talk about people who describe human contact as a need, and who go to great lengths to compensate for its lack or even simulate it when there's none about.

Nowhere does this article describe this need for interaction as a disability. Anne writes, "And yet, clearly it is a trait that must be accommodated if some people are to do their jobs properly and maintain their mental and emotional health."

Over the years I've tried to get up to speed on so-called "small talk." I still resent it, I do it badly, I initiate it at inappropriate times and have a difficult time choosing appropriate topics. I tend to model what I've seen other people do because their strategy seems to work for them.

I also understand the benefit of brainstorming. On Tuesday I closed myself in a room with the two other guys in the UI development team and we kicked around different ways of distinguishing between autonomic versus voluntary client-server interaction, so we could enhance security by timing out the session if the user had got up and left. Unfortunately for us, we'd been building the system out without regard for this, and going back, tracking down every interaction the user could have with the system, and distinguishing between those API calls (and there are a lot of them) that the client initiates because it wants to pull an update, and the user initiates because he wants an update, would have been a Herculean task. After kicking the idea around for fifteen minutes, I hit upon an idea to attach a monitor to the browser's keyboard and mouse handlers and sending a signal to the server every few minutes saying "The user is still here," and resetting the server-side timeout window.

The dynamism of interacting with them (and they're both very talented guys themselves, but my solution was an age & treachery sort of thing) helped speed the development, but then I had to go back and write the darn thing by myself. And I'm really not interested in what happened over their weekends. I doubt they're interested in mine.

As Anne says, people like me spend a lot of energy supporting the "special needs" of ordinary people, people who would never describe themselves as having "special needs," who believe themselves to be independent and self-providing, and yet these people balk at the idea that there are folks like me who would be perfectly happy to be left alone for several hours to produce.

Anne mentions that a "trivial" operation for most people (her example is "Call this person and ask them for that,") requires a great deal of effort and preparation. I sometimes rehearse what I'm going to say two or three times before calling a stranger or making a "routine" appointment.

My bugaboo is "writing specifications." These are documents that tell the user exactly what the product should and should not do. For me, there's one and only one language a specification should be written in: the code. Everything else is a cheap simulation. The fact that some people need to have it described to them in something other than Python, C, or ECMA feels like a disability to me.

Anyway, I just wanted to direct your attention to this article, because I think she's on to something here.

Glee!

Nov. 13th, 2007 08:41 pm
elfs: (Default)
These mean nothing to you (but they might make sense to [livejournal.com profile] fallenpegasus):

foo
foo&bar
foo&baz&21342&$@#
foo=zoom&bar&bob=ted=carol=alice
foo&$=
foo&%66%64%65
foo&%66%64%65=zoom
%66%64%65=zoom& foo&
foo
bar&foo
%24%40%23&21342&baz&foo
bar&bob=ted%3Dcarol%3Dalice&foo=zoom
%24=&foo
fde&foo
fde=zoom&foo
&%20foo&fde=zoom


I got the QUERY_INFO string sort and normalize function to work! Whoohoo! Now, on to the rest of the signature!

(Note the fourth example: the input fragment is 'bob=ted=carol=alice', but the equal symbol is a URI reserved character, a CGI argument, and an unreserved initial symbol separating keys from values in CGI arguments and is privileged in the standard; I made the decision to normalize the very first unescaped, but to escape every instance thereafter. I suspect this will not please some people, but it is the best interpretation I can come up with inside the mashup between the specification and RFC 3986).

(Note also the last example with the preceeding '&'; this happens when an empty argument is passed in, i.e. a QUERY_INFO contains '&&'; the empty string bubbles up to the top of the sort list according to asciibetical sorting.)
elfs: (Default)
A comment I made this morning, preserved for antiquity:

"Y'know, it's just: copy the query string, systematically go along it chopping out the '&' while remembering where the string starts, lexgraphically sorting the string (by the way, are you supposed to do the lexgraphical sort after it's been unescaped? (in which you case you'll get syntactically meaningless (not that we care for signature purposes) strings like equation=x=7) in which case the pain in the ass quotient goes up a notch) using QSort, then re-assembling the query info, escaping it, and assembling it with METHOD, SCHEME, HOSTINFO, and the other two data whose names I can't recall because they haven't even dropped onto my radar yet.

Because, y'know, strings like equation%3Dx%253D7 just kinda rock my world."
elfs: (Default)
Code Fairy can Shut. Up. Now.
elfs: (Default)
It occurred to me that there is a third interesting alogrithm that could well lead to an interesting legal conundrum. "Skin Feature Extraction and Detection" is used by a number of filtering programs to detect porn and take the appropriate action; I'm often surprised that the option hasn't been incorporated into GIMP as a "filter the human out of the background" engine.

So, here's the scenario: You use this algorithm first to "detect clothes," and mark all the clothed regions of a body as "damage." Then, using a database entirely of nudes (and I'm quite sure there are tens of millions of those on the Internet), you "repair" the image using the Scene Completion algorithm. It would probably work best against bikini photos.

So, you run this program against the flickr group 'bikinis', or the Google Images search term "in a bikini". What's the likelihood that this algorithm, completely innocently and without human intervention or consideration, will produce something arguably illegal?
elfs: (Default)
Yesterday, [livejournal.com profile] fallenpegasus turned me on to Ariel Shamir's research, entitled Seam carving: content-aware image resizing, which is a fascinating algorithm for removing "seams" (meandering columns or rows of pixels) from an image in a way that retains the most semantically meaningful portions of the image. The technique is fairly geeky, involving calculating gradient paths to take out the seam that would cause the least loss of information, but it seems straightforward and I have at least two publicly available algorithms (one in Java, one in C) for it along with the paper.

My intent is to put it into my work queue. I used to be a big contributor to the NetPBM suite, although the only thing of mine that remains there is the -c flag in giftopnm, my contribution back from my time working with The National Center for Missing and Exploited Children. (They used to send their "Have you seen me?" cards to the web admin as a scanned GIF with all of the case information attached to the image's comment field.) I'd hoped to put seam carving into the NetPBM suite as well.

While I was researching it, I came across another paper by Jamie Hayes and Alexi Efros entitled "Scene Completion Using Millions of Photographs." The idea here is a simple one: if you cut out or damage part of a photograph, you can "restore" some semantic meaning to the damaged part by culling through millions of other photographs looking for something that would seamlessly fit into the damaged portion. Hayes and Efros have created an algorithm that apparently does this very well. The example at the top of the page is quite remarkable.

It's probably revealing that my first thought while reading the abstract was, "Oh, cool. It shouldn't be too hard to create a detect pixilated region algorithm. If I use that to 'damage' the picture and the Scene Completion algorithm to repair it, I can restore an awful lot of important, uh, semantic detail to all those censored images on the a.b.p.e.asians.* newsgroups."

Hell, 99.44% of those images are photoshopped anyway-- not counting the pixellation. Nobody's going to care if her pubic hair is borrowed. The Internet views censorship as damage and routes around it; all I'm doing is trying to help.

It occurs to me that this sort of digital merkin would have two other significant uses: done right, it might scramble watermarks or steganographs, and it might also remove advertising bugs[?].
elfs: (Default)
I had an idea for creating a version of livejournal that couldn't ever be shut down or censored, and I was gonna post it. The post was called "Fisher Price's My First Exoshell," which will give a few people a clue as to what it's about, but I've decided to hold this idea close to my chest for a while.

Elf has other ideas about layering the exoshell so that live objects can participate in trust networks on the internet without their inner processes being intelligible to outsiders, a sort-of Freenet for computronium rather than mere dumb storage. I doubt you could hide the sub-sub process the way you can hide sub-sub filesystems with the evil Quadruple Encryption Technique on static filesystem archives, but it would be fun to experiment.

If only I didn't have to write code for a living, I would do it for this kind of fun.

But I write stories for fun. I'm slowly urging Gwo and Jess into bed. They'll get there. Just so I can deliver lines like:

"But... don't you find that disgusting?"

"Jess, I've never had a body before. I don't know what I'm supposed to find disgusting."
elfs: (Default)
Well, after being mostly down and out all weekend, I'm back. Saturday night I set my computer to work rebuilding all of those things that had been "upgraded" in the past year to work around the Japanese input problem. I woke up Sunday to find my laptop crashed, and when I brought it back on-line all sorts of things were broken. Wireless connectivity, email reader, secure remote login, and most notably my editor, emacs, which is also my Usenet reader and my LJ composer, all broken. It took me all day to bring the damn thing back to a useable condition. I'm not even sure what's finished and what's not, but I seem to have everything back as of this morning. I have wireless (although it complains bitterly when I start it), email, emacs (although I had to build it twice to get motif support into it) and remote login.

Bizarrely, the rebuild isn't finished and yet I now have Japanese input support again.

A couple of things remain broken: the thumbnailer and the Haskell compiler. I need to review them now that I've updated the compiler as well, and see if they're still broken.

I'm blogging from the basement of the King County Courthouse, so my connectivity is a bin flaky. More on that later.
elfs: (Default)
A top-of-the-line Linux distribution (Ubuntu being the current example) costs about ten million dollars a year to produce, whereas Vista costs an estimated two billion dollars a year to produce.

Is Vista a better operating system than Linux? For the average consumer, to a great degree it probably is: it's more polished and provides more raw operating services, although acquiring the software needed to make Vista productive drive up purchasing costs significantly. Is it two hundred times better than Linux?

No. And that's Microsoft's biggest problem.

Linux's biggest problem, on the other hand, is the slow evolution away from desktops and laptops to small, locked devices like cell phones and portable music players with hardware-based DRM, the licenses for which will lock everyone else out of the development market.
elfs: (Default)
If you go look at the Journal Entries Index Page, and you haven't had Java enabled for a long time, you might notice something interesting about the page: the clock has started working again. I've completely re-written the clock in Javascript, which means that it should be accessible to damn near everyone and scales appropriately when applying the Text->Larger option for those whose eyes are getting older.

Just something to share with you before tomorrow's release. And yes, this means that the algorithm is downloadable for those of you able to find your View Source button. It's a complete hack, meant just for this page, and is not to be taken seriously.

If it's borked, obviously, tell me here!

Profile

elfs: (Default)
Elf Sternberg

August 2025

S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31      

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 14th, 2025 02:06 am
Powered by Dreamwidth Studios