Friday, January 27, 2006

Nitpicking "if" structure

So what would be better?
def method
if !event
return nil
end
return Table.find_first_by_name("oak")
end


def method
return nil unless event
return Table.find_first_by_name("oak")
end


def method
return !event ? nil : Table.find_first_by_name("oak")
end


I figured the first is a bit clearer, but longer...and while the third is shorter, I'm not sure that a coverage tool would flag parts of it as uncovered. And the second...well, having two returns seem kinda ugly. What do you think?

Thursday, January 26, 2006

Soft robots and haptics

"Chance favors the prepared mind."
- Louis Pasteur

Even though I feel like my grasp of advanced math is not as solid as it should be, I don't think it's beyond me to understand it, if I spent enough time on it (and maybe asked someone if I got stuck). But I don't feel like this is innate. Anyone should be able to understand advanced concepts if it were explained correctly. Geniuses might get it faster than others, but everyone should have the mental capacity to grasp abstract concepts eventually.

However, when it comes to creativity, innovation...ahh...that's something that's practiced. But even if you do work on it, sometimes you might not have gotten something that someone else thought of. And in that capacity, I feel that Louis Pasteur's quote above signifies to me the reason why.

I had always been looking for some type of gel substance that received and gave some type of signal as an input device, but usually to no avail. It was with this sitting in the back of my mind where, "Luck favors the prepared."

I was talking to a coworker next door, and he was working on robotics and autonomy. He was excited about a prototype for a body that he had constructed. A common problem for robotics is mobility: wheels can't go everywhere. So what he and his cohorts developed was the concept of a soft robot...a robot with a soft, amorphous body. He showed me a disk with membrane on one side, and plastic on the other. Trapped inside the disk was a dark colored liquid. When you feel the liquid from the side of the membrane, it doesn't feel special...just like liquid under a membrane. But when you put a magnet on the plastic side, it hardened the dark colored liquid, which you could now feel on the side of the membrane. Basically, the idea was to have a sac with this dark liquid as a body that you can control through magnets.

I was playing around with it while talking to him. It was pretty neat. When moving the magnet, you can feel a gel-like hardness underneath the membrane. I was thinking to myself, "This is pretty cool. You can use it to create robots that do massages with this." Immediate after--though I did not express it--I knew that the porn industry would have a field day with such a technology.

And then as I usually do, I reverse whatever I was doing, just to be playful. I stuck the magnet on the plastic side, and started pushing the hardness around through the membrane. As a result, the magnet on the other side was moving around also. I looked at my coworker and said, "You know, you can use this as an input device...I'm sure there are magnetic sensors, right? So you can push the hardness in the membrane around, detect it, and send it electronically somewhere else. You guys probably thought of it already, right?" He was kinda surprised and said, "No, we hadn't thought of that at all." I saw a flicker of an idea in his head, but he didn't divulge what it was. He seemed please with himself.

A week or two later, he came up to me and said, "hey short-timer!" And then he told me that his cohorts were really excited about the idea. Basically, for robotic-assisted surgery, it can be an input device that provides haptics (force-feedback). So, in the future, if you see any soft-membrane input devices for robotic-assisted surgery, it was cuz of me playing around with a membrane. Haha, my little claim to fame.

Rake options and tasks in Rails

I feel stupid for even posting this at all, but after typing:
rake -h
rake --help
rake help


Without too much helpful information, it wasn't until reading docs that I found
rake --tasks
goes a long way in seeing what you're able to do with rake. It kinda opens up your world.

Rails 1.0's fixtures are different than from before

Faster Testing with Rails 1.0

Was wondering wth was going on. Good thing for the web. According to Mike Clark, if you're reading the Rails book, "Agile Web Development with Rails", make sure you take note of the errata with Rails 1.0. The instantiation of fixtures as attributes and hashes are not done by default anymore with Rails v1.0.
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false


The reason being that having to instantiate all those attributes will take too long with a large fixture to test. Now, instanciations are done ON DEMAND with each test. And if they are done, they are cached. Therefore, you can either choose to override and change the use_*_fixtures settings in your test code, or you can change all your code from:
@table["my_fixture"]
to
table[:my_fixture]
table(:my_fixture)

Tuesday, January 24, 2006

RubyForge: RMagick: Hints and Tips

RubyForge: RMagick: Hints and Tips

So for image manipulation, you need imagemagick, and rMagick, which is the ruby layered on top of it. However, I had trouble installed rMagick because it complained about, first imagemagick not being installed (when it was), and then about missing libraries.

I didn't want two copies of the same app floating around on my system, by installing the tarball, so I found this large (and helpful) explanation.
Usually this problem occurs when installing RMagick over a version of ImageMagick/GraphicsMagick ("xMagick") from a binary package such as an .rpm or .deb. The problem occurs because the package installs just xMagick but omits one (or all) of the libraries that it uses, such as the FreeType library or the XML parsing library. Or the libraries are installed but not the header files that RMagick needs.


So I had to look for the gem, which for me is under
/usr/local/lib/ruby/1.8/gems/1.8/gems/rmagick-1.10.0/

And read the config.log file. I found that I was missing "libMagick.so" and "libBZ2.so" I had both of these installed, but I used YUM's "provides" command to find the packaged I needed that provided those libraries. I found the development packages and installed those.
yum provides libMagick
yum install libMagick-devel
yum provides libbz2
yum install libbz2-devel
gem install rmagick

:: Howtos : Keeping Fedora Up to Date with Yum

:: Howtos : Keeping Fedora Up to Date with Yum

I've used linux for a while now, but the intricacies of how the OS works and is put together is still a bit shrouded. I've developed a lot on a linux machine, but haven't really administered one, til recently.

I've always built my apps from source tarballs, mostly because at least this way, I'll know where I installed it /usr/local/ and it's all in one place. With RPMs, I have no idea where it put the files...but then again, maybe that's the point...that I don't have to. But even then, I've found RPMs are to use...mostly because I could never remember the flags.

Then comes yum on fedora. I like it a lot so far. It's a bit slow, but it finds the repositories, knows which packages need to be updated, and numerous other things. It also finds which packages provide a library that you need for another install, which I used to install rmagick gem. The best part is that the commands are whole words. :)

The Nature of Tagging: Public vs Private

By implication, tags are public. However, should tags be public or private? That's been the ongoing debate between me and Chris. Chris's stance is that tags should be private, because he only cares how he classifies things, and not how everyone else classifies things. My stance is that the power of public tagging is in its search of everyone's content, not from its way of classifying individual content.

Tagging is no more than keywords on things for grouping. And if tags were private, it would be no more than that. Gmail has a new feature that allows the user to group contacts. Public tagging gets its power from the aggregation and feedback loop of lots of people's sets of tags. The statement that one wouldn't care how other people classify things is true to you if you don't use other aspects of tagging, namely, the searching of new information through tags. If you only use tagging for classification, then it makes no difference whether the tags are public or private. The power of tagging is not that it's a better classification system; it's a way of utilizing humans to create a search index.

How could the index comprised of an aggregation of other people's tags be anything other than a hodgepodge of random keywords? That would only be true if the set of tags that people use on a particular object would be independent (uncorrelated) with everyone else's set of tags. Now, we know that to be untrue for bookmarks due to del.icio.us's work. This is because words with content are correlated with each other. Therefore, there is a limited set of keywords that people will use for any single piece of content. In fact, it's because of this that search engines can do their job. So while one person's set of keywords may not be the same as another's set of keywords, on average, they will overlap with each other. Thus, if you're searching for more content on the same subject, that's something public tagging does a really good job of. And that's a task that lots of people do on the internet...they're looking for related content.

Now, will [public] tagging work for classifying or searching all other objects? With the rage about Web 2.0, there are some people that think that everything should be tagged. Not necessarily, I say.

Tagging has been demonstrated to work if an object has intrinsic properties; a book is a book to everyone. But what if you're tagging your relationships to an object? I think that changes the nature of tagging a little bit. Because the relationships to an object is not the same for all people; and more importantly, sometimes these relationships are non-transferrable between people. A book will always be a book to anyone, but a book that your father gave you on your eighteenth birthday will be a relationship between that book and only you, and not between that book and anyone else.

That said, there is sometimes a shared (collective) relationship between groups of people and an object. A group of people might feel that Lover's Overlook is a special teenage place for them, but not everyone in the world would share the same relationship to Lover's Lane. But everyone can agree that Lover's Lane is a make-out place because it's an intrinsic property of the object. Therefore, I will have to curb my hard statement before that tagging relationships between objects would be uncorrelated. It will be less correlated than tags on intrinsic properties of an object, but some degree of correlation would exist. And therefore, you can search for all other objects that have the same relationships to people.

So should tags be public or private? I think that objects with intrinsic properties that people are searching for is very condusive to public tags. However, objects such as 'gifts I received for my birthday' might not be condusive to private tags. You might not care what everyone else received for their birthday. In addition, since they are different people than you, you might not want the same things they got.

I think the application of tags to objects in a system should be carefully scrutinized, rather than just following the assumption that everything is good for tagging. Are there instances of objects that should be privately tagged as opposed to publicly tagged?

Saturday, December 31, 2005

Yum can't find public key

When using Fedora Core, I couldn't get yum to find the correct public keys. Ends up that it's something with rpm. Just do this:
rpm --import /usr/share/rhn/RPM-GPG-KEY
rpm --import /usr/share/rhn/RPM-GPG-KEY-fedora

And it'll work.

Wednesday, December 28, 2005

Human Area Networks and Communications with Context

Human Area Networks are just a name for using human skin (while the human is alive) as a transmission medium.

But to me, the most exciting aspect of communications over human skin is that it gives communication devices "context".

So a post-it note stuck to nothing that says "trash me" will mean just the same action as a piece of paper that says "trash me". But when a post-it reading "trash me" will mean different actions when stuck on a book versus a cabinet.

In the same way, devices in the vicinity of each other can communicate, but it has no context other than geographic closeness (which sometimes is enough). But with communications over skin, it gives the context of an intent by the human to interact with the device they're touching.

This kind of thing could be applied to "needies"
http://www.needies.com/
http://www.gizmodo.com/gadgets/gadgets/needies-jealous-plush-toys-101181.php
Which are "attention-starved stuffed animals" Each one knows when they're being touched, and broadcasts that information to other needies in the room. The ones that aren't being touched will complain, and say things like, "hug me instead!", or "Throw him! Throw him!" So instead of always broadcasting, they will have extra information about the state of the world by which medium they can communicate through.

As another inane example, personal devices being held by the same person running a screensaver can have fish swim from one screen to another screen of a personal device.

Again, the medium of human area networks gives the communications context by human intent, rather than just by geographic vicinity.

Thursday, December 22, 2005

What would you do with a Terabyte?

It wasn't too long ago that having 256MBs of memory or even 1GB of disk space was a big deal. At the time, I thought "Wow! 1GB! What am I going to do with all that space?" Well, as usual, software engineers can never get enough speed or memory. When mp3s and mp4s came about, along with higher bandwidth, suddenly 1GB didn't seem like enough for all the movies and music. Applications themselves took on more complexity and layers of abstraction, and required faster hardware and bigger hard drive, not to mention the operating system.

As one Terabyte looms ahead, the question is, what would you do with 1TB? What would you be able to do that you aren't able to do now?

I imagine that beyond movies and music, there will be other forms of high bandwidth data that aren't available yet. Olfactory data and tacile data should be immense in bandwidth, though currently, we do not have input devices for those senses. If personality-based artificial intelligence becomes commonplace, then that might also be something that requires a large amount of storage. Sensory information for bio implants as well as simulation of augmented and virtual reality will take more and more storage.

I'm not sure how other computing architectures would fit into this, but quantum computers might generate a lot of data due to the sheer parallelism of the architecture.

Friday, December 09, 2005

Authorship and Insect wings

I went to two talks today. The first one talked about using statistical analysis, principle component analysis, and singular value decomposition, to be able to tell if it's the same or different author compared to other text that you ran through the math by computers. It's pretty neat, actually, though the talk was less technical than I'd like. The guy did analysis on the original Hebrew and Greek text versions of the Bible to determine whether it was probable that there were different authors under the same name. There's other things that you can use this for, some invades into privacy, and others don't. You can also use this to analyse source code in order to determine whether it was the same author that wrote something, and whether the person likely wrote code in other software.

http://www.rmcs.cranfield.ac.uk/daps/guidance/microairvehicles/view
The second talk was much better, quite neat, and still on going. The guy was a much better speaker, and he talked about micro air vehicles that mimick the use of controls and aerodynamics in wing design in insects. The problem is more complicated than you can think of first hand, but the most interesting conjuncture that he had was that it was a sensor-rich feedback control system, rather than a controller-rich feedback control system.

Thursday, December 01, 2005

Bachelor cooking

This is a show about easy cooking for bachelors. Really, it's a blog with a videos of how to cook certain things. I don't know about you, but I think this is pretty amazing, especially when you think about what was impossible just 10 years ago. For those of you in your twenties, or older, to have your own cooking show, you needed to pretty much go through one of the networks.

Now, with the advent of blogging and widespread connectivity, I'm repeating what lots of people have said already; we might be moving into a world where you can get started on very little. Granted, you get more crap, but crap is filtered by the commons, and there's a lot more niche markets, as argued by the long tail.

And these could be people you know! I found these two through a friend of a friend.

Friday, November 04, 2005

Amazon Mechanical Turk - Welcome

So we've come around full circle. I think this is a break from normal thinking, and it's not too bad, actually. I wonder if you can make a living off of just being human?

Thursday, November 03, 2005

Coding up that if/else

Something that really irks me in code is when I see something like this:

if (result == FAILED)
print "failed!\n";
return;
else
// do whatever
end


You don't need the "else"! If the "if" statement evaluated to be true, then there's no reason why it would jump out of it. Therefore, there's no reason that the //do whatever part of the code should be inset! Do this a couple times, and you'll have a nightmare of nested code. Keep your code as shallow as possible. Don't nest if you don't have to.

Sharing places in Google Earth

Google earth's coolest feature (imo) is not the stunning visuals, but rather, the image overlays you can put on it, so you can overlay, subway maps, apartments up for sale, etc.

But in addition, and even cooler than that, is that there's a KML format that you can export from google earth that's an XML file that let's you share and transfer waypoints from inside the app. So if you and I belong to the Stonecutter's secret society, and we need driving directions to our secret meeting place, someone in our group can actually change that waypoint, and we would be updated automatically.

This, I think is in line with their aquisitions in the mobile industry in the last year or so. I think that we'll see some type integration between mobile users, and global knowledge and coordination of places.

Yahoo maps in response to google maps

The yahoo maps beta is significant because it's yahoo's response to google maps. And it chooses to use Flash instead of AJAX, which is receiving a lot of hype right now. So that's something to think about in terms of the choice between the two. The argument I've traditionally heard about not using flash is because it has long load times, user's not guarenteed to have it, and it might be over kills. But the fact that it loaded up fairly quickly makes me think there's something more than meets the eye w/ flash.

Friday, October 28, 2005

Hoodwink.d

I think once again, something's brewing under the scope of the net. And it falls under the name of Hoodwink.d It's a bit esoteric as to what it is and what you'd use it for, but I think that's part of the charm/lure. It's definitely for first adopters.

I haven't tried it, but basically, it's an RSS feed for commenters of blogs.

Wednesday, October 26, 2005

Remote Influence, more than Remote Control

I think this is actually a pretty neat technology, even if it has horrific implications as to what you can do with it. But it's like any new technology, you'll have people for and against it for any number of reasons.

But don't be quick to jump the gun. It is more of a motion influencer, rather than an actual mind controller. It makes you feel like in order to keep your balance, you need to swerve left or right.
The technology is called galvanic vestibular stimulation — essentially, electricity messes with the delicate nerves inside the ear that help maintain balance.

I felt a mysterious, irresistible urge to start walking to the right whenever the researcher turned the switch to the right. I was convinced — mistakenly — that this was the only way to maintain my balance.


I think there is potential for good and evil here. I think the article mentions some more evil ways to use it. I will ruminate on the good ones.

Humans are social creatures, and generally like to feel like they're coordinated, to be a part of something bigger. An example of this feeling that I'm talking about is the euphoria of band members or dancers after a performance that went well. A more advanced version of this technology can centrally orchestrate collaborative movements, whether it's a game or performance. And eventually, it would become an experience, when everyone's in sync. Some will like it. Others won't. Just as some like bungee jumping, and others don't.



Tuesday, October 25, 2005

Shut the door, you're letting all the cold air out.

It's commonplace for me and every other fool to stand in front of the fridge with the door open, trying to decide what to eat....and being yelled by our mothers in the process.

So it came to me today...Why are refridgerator doors at home not made of glass, so you can look at food without opening the fridge?

Sunday, October 23, 2005

The essence of tagging

Chris and I had been arguing about the nature of tagging. He believes that tagging should be an activity that's private. He never looks at tags that other people have. I'm more on the side that tagging is an activity that's public. The fact that you have thousands of people labeling things, there will be some overlap in calling it the same thing. In that way, you can find other related things.

I think I just realized the main difference between our philosophies is what type of keywords that we think we would employ. If the tags that you put on an object are intrinsic properties of the object, then there's no problem that it is public. However, if the tags that you put on an object are properties of how it related to you, then that's how they could be seen as private.