Dec
26

Second Day of Christmas

Second day! Wanted to iterate on my snowflakes from yesterday to have some generated snowflakes.

It’s a bit unpolished, but this is just an exercise, after all.

Without further ado: more snowflakes!

(Also, I did the generation of the snowflake in a separate sketch before integrating it into the snowfall – you can see that here)

Second Day of Christmas – Let It Snow (with source)
Second Day of Christmas – Snowflake (with source)

Dec
25

First Day of Christmas

As an exercise during this Christmas break, I think I will try doing a Processing sketch each day of the 12 Days of Christmas. (If you think that the 12 Days of Christmas end on Christmas Day, get thee to Wikipedia.)

I’d like to get the Java applets embedded into the page, but until I figure out how to get them to play nicely with Wordpress (or roll my own solution for blogging, which I may well do over the break), you’ll have to link out.

Today’s entry is a super quick sketch, indicating my (unfulfilled) desire for a white Christmas. It’s nothing but a super simple drawing setup with an array of custom objects and a nice little use of Perlin noise (a method for smooth variation of movement that I learned from Mario Klingemann at FITC several years ago).

First Day of Christmas – A Little Snowfall (with source code)

Apr
3

Launching an app with AIR

Ran into a relatively unique challenge this week: needing to launch and close an AIR application on a schedule. Now, this could be done on OS X with cron and a bash script, or AT on Windows. However, the specifics of this project dictate that I have solutions for both systems, and above all must be extremely simple to set up, which led me to wondering if I could launch and close an application with another AIR app.

Short version: it’s completely possible. In fact, it’s quite easy. The one catch is that your AIR apps must be published as a native application. (In Flash Builder, “Export to native installer” is on the first page of options when you export a release build.)

The only other bit of setup is defining a supportedProfile in the descriptor file (the .xml file that configures your AIR app – if you’re using Flash Builder, it is built for you when you create the project):
<supportedProfiles>extendedDesktop</supportedProfiles>

Now, we just have to use Actionscript to start up your second app! We use an AIR-only class, NativeProcess. (In fact, it appears you may be able to start any native application with AIR, but don’t quote me on it.)

if(NativeProcess.isSupported)
{
  var file:File = File.applicationDirectory;
  file = file.resolvePath("Application.exe");
  if(!file.exists)
  {
    file = File.applicationDirectory;
    file = file.resolvePath("Application.app");
    if(file.isPackage)
    {
      file = file.resolvePath("Contents/MacOS/Application");
    }
  }
  
  var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
  startupInfo.executable = file;
  var process:NativeProcess = new NativeProcess();
  process.start(startupInfo);
}

And if you need to close the process down, you’ll need to hang onto the reference to the NativeProcess and call process.exit()

Note: My example covers my own example, where I want to code once to deploy twice (targeting both OS’s). On OS X, native applications are actually “packages,” or a standardized folder structure that holds all sorts of goodness. To start the process, you actually have to navigate into the package to start the actual executable; see my code.

For more details, read the docs!

Mar
30

Geo-Tagged Tweets: Schemes

As advertised, I’m working on a visualizer for geo-tagged tweets. My biggest hurdle at the moment, however, is not the displaying of points, but rather actually getting the data. After much complaining and gnashing of teeth regarding the lack of geolocation flags in the Twitter public API, my coworker Ryan Kee pointed out that the Twitter streaming API does allow filtering for locations.

So my issue becomes this: how to digest a stream in Processing. If I’m not mistaken, opening up the Twitter stream opens up a connection that doesn’t automatically close, but just keeps dumping in data. That’s all well and good, but my understanding of Processing’s http capabilities is that it needs to finish loading something before it can read and parse it.

So, I think I need to do some backend voodoo. More specifically, I think I need to open the stream for a limited amount of time, close it, and send on the results that I received in that time.

My initial quick-and-dirty plan is to create a script that will open the stream, collect the response as plaintext, close the stream after 5 seconds, then return the collected response. This means it’s going to be a long response time (~ 5-6 seconds), but it’ll get the job done and allow me to start playing with the data.

A better long term solution would be to have a constantly running script, perhaps on cron, that will (on fairly short intervals) open a stream, collect the response, then write those results to a static file that can be retrieved. That way I could have a static file that would always be 15-30 seconds of tweets, and it would never be more than 30 seconds out-of-date.

Status:

I’m really not a backend guy, but most of my backend experience is using the Django framework. I was thinking that my quickest bet might be a little Django view to do what I wanted, but I spent most of last night fighting with my Django install on my Dreamhost server – something about “Premature end of script headers.” Did some googling, but most of the chatter about it that actually offered solutions referred to FastCGI, but Dreamhost has transitioned to Passenger instead. In the end, since there is nothing really relying on the subdomain I was running Django on, I ended up completely nuking the subdomain, recreating and reinstalling. After all of that, no closer to my goal. Might be time to look for different hosting, but that’s a whole different discussion.

Now, I’m not much of a PHP guy, but I think my next attempt will be to write a PHP script to execute my quick-and-dirty 5-second response plan. Need to go learn about “curl” now…

Mar
20

More Processing demos coming

Intended to get more Processing demos posted late last week / this past weekend, but got pulled onto a project at work that launches this coming week, and has completely monopolized my life since Wednesday. Should be easing up in the next few days, so there will actually be more Processing demos coming later on this week. A preview of what I’m thinking about:

  • Geo-tagged tweets in 3D space
  • More generative art
  • Using input from a Kinect

Also open to suggestions… but if you have ideas, maybe you should try making them yourself!

Mar
16

aoIT: Creative Coding

I was asked to do a presentation at the aoIT Conference today in Salt Lake City, UT. Still not entirely sure what aoIT is, but seems to be something about high school kids into programming, and possibly some college credit.

Wanted to make my presentation available online, so my slides can be found here, or you can download my demos bundled with the slides here.

Also, will continue to play with Processing a bit more this week, so additional demos will appear in the next week or so.

(After that, updating will go into its usual uncertain state.)

Jun
8

Help me build a well

I need your help. I want to build a well.

Seriously. I don’t know if you’ve ever heard of charity:water, but they do great work.

Short version: I’m training for a Half Ironman. I’d love for you to follow along with me while I train. While I’m doing that, I want you to help me build a well. Small donations, big donations, a number of small donations—anything you can help with will make a difference. It’s ambitious, but there are some smart, ambitious, motivated people out there, and we should have their backs.

So please, help me out.

My whole life, I’ve been playing, training, competing—in short, I’m an athlete. As an athlete, water is essential. I’m always drinking water—before, after, and during workouts, as well as throughout the day to stay hydrated. And it’s as simple as walking to the sink, turning on the tap, and filling my glass or water bottle.

Some places and some people, though, aren’t so lucky. Almost a billion people around the world don’t have access to clean water. The task of getting water sometimes takes the entire day, yielding a meager supply of dirty, unsafe water—water that will be stretched across drinking, cooking, and sanitation needs, until it is quickly used up.

Smart, motivated people are working to change that. A properly engineered well for a community can provide clean water for 20 years, breaking down to roughly $1 per person per year. The water is safe, and there is enough for proper sanitation—incidence of disease drops dramatically, especially for children under the age of five, who are the most vulnerable. Women who used to spend their days getting water can attend school, work, or care for their families.

My point: I am going to compete in a Half Ironman in late summer, and I’d like you to follow along with me and help provide clean water at the same time.

My campaign goal of $2500 is ambitious, perhaps overly so, but then, doing a Half Ironman is pretty ambitious too. (For reference, $2500 is half the price of the average water project.) Whatever you choose to give will be greatly appreciated. I’ll be posting updates as I train and compete in some other triathlons, so I hope you’ll follow along throughout the summer.

You can hit my campaign site at http://mycharitywater.org/luptakHalfIronman. I’ll be posting updates at a brand new training blog that I’ve set up at adamluptak.com/training. It’s gonna be a fun summer, so let’s get on it.

Jun
7

Life update + self promo

Oh Lord. If you’re one of the roughly 3 people who read my blog, you’ve noticed that I haven’t written in a while. So, what’ve I been up to since I’ve been gone?

PepsiCo multitouch installation

Work, mostly. StruckAxiom pulled off a kamikaze mission for PepsiCo—a multitouch installation on a super short timeline. You can read about the project at the StruckAxiom blog.

Also, on a whim, I tweeted a link to the post I did on the LEGO CL!CK site at FITC, an industry conference that’s been on my radar and inspiring me since school. The most I was hoping for was to get the link retweeted, but instead was asked to repost it on the FITC blog and to be a guest blogger for StruckAxiom on the FITC blog.

My first (and so far only—I need to get back on that) original post for FITC was titled “Lessons Learned: Adventures in Multitouch.” It was a pretty heady experience, having my first real post up, but even better was discovering that Lee Brimelow, Platform Evangelist at Adobe, has blogged about it, and highlighted it during his session at FITC Toronto.

Rigby Lake traithlon

Outside of work-related nonsense, I’ve been training. I competed in my first triathlon of the season over Memorial Day Weekend—a sprint triathlon at Rigby Lake. It was a cold, windy, rainy day, and a pretty miserable experience, but I got through it, and have my sights set higher—a Half Ironman at the end of the summer. But more about that later.

So, fingers crossed, you’ll hear from me soon!

Feb
11

Vancouver 2010 Olympic medals

I love the Olympics. It’s a statement that may sound silly, childish, or perhaps a little disingenuous, but I really believe it’s true. I’ve always loved the Olympics – the athleticism, the competition, the warm-fuzzy one-world-isms, I buy into all of it. I’m really kind of a sap for this sort of thing.


Photo by Matthew Field

So the 2010 Winter Olympics start tomorrow, and I’m pretty stoked. The 2010 Olympics in Vancouver – admittedly, I really kind of wish I could go up for it, but oh well. (After all, I never attended any of the events when they were held in Salt Lake City, even though I only lived 3 hours north at the time – I did go see the torch as it came through town, though.) For one thing, they’re in Vancouver – I mean, look at that photo – that’s just ridiculous how cool that is.

The medals, though, are what I wanted to talk about. I love the design of these. The simple, minimal shape, with the subtle Olympic rings in the lower right-hand corner. Further, the shapes etched into the surface are actually the forms of a design in the art style of the indigenous peoples of the Pacific Northwest. It is probably an indication of how white I am, but I have been enchanted with Northwest Coastal art for as long as I remember, and I love that the placement of the design on the medal is randomized, so each medal only has a fragment of a larger whole, and no two medals are alike.

Another awesome aspect of the medals is where the raw materials have come from—a portion of the metal (I haven’t done the math, but my friend Rachel thinks it may be more than 50%) is recycled from e-waste. While it’s certainly only a first step towards sustainability, it’s a fairly ambitious first step. (I’d encourage you to check out Rachel’s well-footnoted post on the matter.) I also wanted to share the following NOVA segment about the making of the medals, which inspired me to write this post.

Mad props and humblest thanks to those involved in the creation of these beautiful pieces.

P.S. Be sure to check out The Big Picture albums of the Olympic Torch Relay (both the torch and the relay are works of beauty too)—both the first and second album.

Feb
4

Trip Back to Math Class

A recent project had me trying to find the distance between a point and a line segment, and a coworker reminded me that the distance from a point to the line can be found from the line perpendicular to the line, which passes through the point. That means figuring out the linear equation that defines the line segment. That’s y=mx+b, if you remember your Algebra days. I was stumped for a little while – stuck on the concept of solving for two variables with Actionscript. Actually, I was stuck on the concept of solving for a single variable in Actionscript, because I was being dumb.

Then, last weekend, laying in bed, I cracked it. Didn’t get around to writing the code until Monday. I wrote a LinearEquation class – capable of being given two points, a point and a slope (m), a point and a y-intercept (b), or a slope and a y-intercept – and builds a linear equation from it, in a manner of speaking – you can give it an x value, and it will return the y value. You can give it a y value, and it will give you the x. You can get the y-intercept, the slope, or the inverse of the slope – which will be the slope of a line perpendicular to that one.

Most importantly, the LinearEquation class has a static function – following the model of Point.distance() – LinearEquation.intersection(). It takes two LinearEquations as params, and returns the point where they intersect.

So we create a line and a point – then we get the inverse slope of the line, and pass that along with the point in to get another line. Then we get the intersection of the two, and voila, we’ve the line segment that is the distance from the point and the line.

Unless of course, that intersection is outside of the first line segment – that’s why LinearEquation gets extended by another class, LineSegment. But I’m not going to tell you all my secrets all at once.

So check out the demo I’ve set up. [ Line Segment / Linear Equation AS3 demo ]

And the practical applications for this? Not really sure yet, but there have to be quite a few. Just to name one or two, perhaps making line-segment checkpoints in a racing game, or part of an AI system where an enemy is shooting at you.

Maybe I’ll share the source sometime soon – if so, you can look for it here.


Warning: gzinflate() [function.gzinflate]: data error in /home/ajl1206/adamluptak.com/blog/wp-includes/http.php on line 1787