Saturday, February 18, 2006

Rails Collections and Partials

I like convention, mostly because it simplifies what needs to be said, because it can be implied. But likewise, it makes it difficult for newcomers to know what these conventions are, because they're usually not written anywhere.

When rendering a partial, a parital has access to all instance variables generated by the controller method. So if you were rendering a method from show_comments, @my_crazy_comment would be available to the partial. But not only that, if the partial is called with

<%= render :partial => "comment_display", :object => @my_crazy_comment %>

The partial would have available to it, a variable called 'comment_display' that points to @my_crazy_comment.

So inside your partial file, "_comment_display.rhtml"

<blockquote>
<%= comment_display.comment %>
</blockquote>
<%= comment_display.author.name %>


The variable "comment_display" will have the comment in @my_crazy_comment. For a collection of partials, it's just as easy.

<%= render :partial => "comment_display", :collection => @all_crazy_comments %>

Where @all_crazy_comments is an array of comments.

If designs were reusable, would I be for it?

So I've been watching Project Runway II...not religiously, but I watch it with the same reason I watched that modeling reality show with Tyra: to see what others are seeing that I'm not. Certainly, one can say that models don't do much. They dress up, look pretty, and walk. But I always had a suspicion that's like saying basketball is just putting the ball in the hoop. While both true, they're gross over-simplifications.

I often joke, while watching Project Runway, that there should be a reality TV show about engineers and coders. "For this challenge, you have to code on an Amiga!" "For this challenge, write your own Sudoku generation algorithm!"

But thinking about it hard, there is always a trend in technology, where first, it has to be functionally working and innovative, before the designers move in and improve it incrementally and aesthetics. In the case of web applications, with the recent surge of the so-called web 2.0 sites, they all have a similar look and feel. Some of this is constrained by the practicality of a common GUI widget set. Some of this is due to the common fonts and the set of pleasing color schemes. However, on the other end of the specturm, you have flash sites with an unusable UI set and overly animated.

What's the balance between something new, aesthetic, simple, yet functional? I suppose this is the holy grail that most designers strive for. I wonder if it's possible to be both technologically innovative and aesthetically innovative in one step?

Thursday, February 09, 2006

Visual CSS Inspector

After coding in Ruby for a while, and omitting semicolons, it's hard to get back in the habit of doing do when writing CSS. I couldn't figure out how to get a CSS to take effect, and it ends up that I didn't put a semicolon down after "width: 250px".

Problems are always entirely stupid after you figure out what the source is. However, this has led me to wonder about the design of HTML and CSS. HTML is now criticized for being to loose and easy-going with users that use it with errors. However, we forget that without that ease-of-use, and ease-of-forgiveness, HTML wouldn't have had the widespread adoption that it does today. We might still be using GOPHER (maybe).

But when it comes to formatting, the effects of which aren't as readily seen as structure, it might do well to have some warnings or error messages. This should be the case for developers, and not normal users. Well, poking around Firefox, I see that under "Tools", there's a DOM and javascript console. Nice.

But I don't think there are the equivalents of CSS checkers. How do you verify visual aesthetics? Maybe it can check for things like overlap between boxes, in different sizes. If general visual aethetics could be measured, then it might be possible to have a Visual CSS evaluator. One can argue that human creativity has a range of aethetics, and that it would be impossible to capture it algorithmically or mathematically. However, I think basics of aesthetics could be captured, because despite the variability of aethetics, they all share commonalities such as symmetry.

And yet, I hope that if something like this ever comes about, it won't be seen as a standard of aesthetics, but more of a tool to run automagically, so that humans won't have to look at it one by one.

Tuesday, February 07, 2006

Nav with google earth

This article has been all over the news. I've been thinking that this was in the works about six months ago when Google Earth came out. I'm not sure whether the pics are real or not, however. Speculation, of course, but I tend to think that Google as a part of it mobile strategy intends to focus on organizing information between contexts. No longer do you have to look up an address on maps first, print out the directions, and go. No longer will you have to transfer that information between contexts onto paper and then electronically again.

Beyond that, you can find and advertise things in the real world with the google nav system. If augmented reality takes off, I think that Google will be positioned to be the medium in which to make money off of advertising when users are searching for places to eat, gas stations, etc while they're cruising in their cars.

Sunday, February 05, 2006

Long Lasting Design

PC world covered their list of top 50 gadgets in the past. I'm don't buy too much into the listings, other than that it is true that the Walkman changed a lot of things in America, and hence it deserves it #1 spot.

What I noticed is that some of the designs on these gadgets are surprisingly modern. I'd see gadgets like these on the shelfs of some stores in order to set itself apart from the crowd without being too gaudy. So I'm looking at gadget designs pre-1990...so that enough time has passed for those designs to look retro if they weren't timeless.

1. Sony Walkman TPS-L2 (1979)


5. Sony CDP-101 (1982)


10. Regency TR-1 (1954)


26. Nintendo Game Boy (1989)


Surprisingly, the sony walkman also looked pretty modern, as well as the Regency radio. Some say that the Regency radio's design was copied by the modern iPod. Like the iPods, they also came in multi colors.

35. Motorola DynaTAC 8000X (1983)


This is an example of not long lasting design. This brick was a foot long and weighed two pounds. It was considered the first mobile phone, and cost $4000. Can you imagine pulling this thing out of your pocket and asking a girl for her number with it? I'm not sure whether it's not a long lasting design simply because of its sheer size in comparison to the gadgets now, making it unwieldy, or if it's just not pleasing to look at.

Saturday, February 04, 2006

Momo, the Comcast guy that cared

My internet's been intermitten the last couple of months. It would go up and down, up and down. It's really quite frustrating, as I rely on it like I do a car or an appliance. So when it's not working, it disrupts my workflow.

We had called Comcast, and most people they hire are not troubleshooters and problem solvers. They just go by the book, instead of thinking about things. The first time we called, the rep told us to put it on a battery backup. That sounded skeptical, but we did it anyway. Then it was changing the outside splitter, and then proclaiming that the splitter in the wall was bad. After going through three of these guys, I finally got Momo, the Comcast guy that cared.

Since it was an intermitten problem, it wasn't readily reproducible. It would of course work while the technician was here. They'd just shrug and say, "It looks good to me." And then they were on their way. Moments later, my internet would be down again. It might be because I scheduled an early morning appt instead of an evening one, where the technicians just want to go home.

However, Momo was a problem solver. He went all the way back to the tap with the signal meter, and found that the connectors were corroded back there. None of the other technicians from Comcast did that. So we were losing about 10dBs just from that connector. So, a tip for all of you out there, there's a greenish pill tube protruding from the ground somewhere in the neighborhood. It's under that cover that has all the neighbor's cable services. You can check out your own connection if you're experiencing the same problem, and none of the technicians don't seem to be systematic in their diagnosis.

I'm calling Comcast to tell them to give Momo a freakin' promotion, because he's doing the world some good. And that Comcast should hire more people that are problem solvers.

Monday, January 30, 2006

Adding primary keys in Rails migrations

Module: ActiveRecord::ConnectionAdapters::SchemaStatements

The API doc on add_column() refers to column_types which say that it can be of type :primary_key. This is not true. add_column cannot use :primary_key as a type. Currently, I have no idea how to indicate that a field is a primary key and needs to be auto incremented.

You might have to drop the entire table and create it again.

Are migrations executed within a transaction?

[Rails] Are migrations executed within a transaction?

As I'm writing migration changes to the database, I find that rollingback is a pain sometimes, because of writing self.down(). When it fails, I have to reset the database. While this really isn't a problem since no real data is in there (and all the fixtures are added automatically), it is an extra step.

I figured migrations would be executed within a transaction, but apparently, it's not. This was the only link I could find about it, and the guy just says you can't. Anyone know why you can't?

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.