Thursday, December 07, 2006

Adaptive polling as an alternative to HTTP streaming

I've been fairly interested in how the HTTP protocol works lately. For a long time, I didn't think much of it. It sat on top of the TCP/IP layers, and there wasn't much I need to do with it. It did what it was suppose to do: let clients fetch pages from servers upon request.

But then I started reading about REST (about a year after the hubbub), and in general about why stateless connections are desirable (it's scaleable). This lead me down equally saturated road of AJAX and eventually some joke about Comet. What was coined as "Comet" was really a play-on-words for another cleaning product applied to another old web technology--namely persistent HTTP connections.

Traditionally, HTTP doesn't allow servers to push data to clients. With the way the web is architectured, most clients are behind firewalls and routers, so the server has no way of knowing which machine to push it to, unless it was talked to first. In other words, only clients can initiate data requests. This isn't enough sometimes, as servers might need to push data to clients, such as live stock ticker feeds in your web browser without page reloading.

The trick to persistent HTTP connections was to get clients to initiate the XHR connection to the server first, and for the server to not immediately reply to the request. The server will hold off on replying (leaving an open connection from the client) until there's actually a message to be sent back to the client (i.e. when there's a new stock update). And that way, it'll look like a server-push. And then the client initiates another connection all over again after a certain wait.

This is the way that LivePage and JotSpot Live implements their responsive apps. However, the concern for most people is that it doesn't scale--at least not when they tried it circa 1998. A server having thousands of open connections to clients will probably buckle, although Twister might have already solved this problem, but I haven't looked into it much yet.

Another concern of mine is that the Ajaxian pattern of HTTP streaming can also require the client and the server to hold state. This is because a server does not know what version of the last set of updates it has received. Therefore, the client sends the server what version it has had (state), and the server will only reply if it has a newer version. This seems to violate the REST architecture. While I only have the original 2000 thesis to say this is not scalable, it seems to make servers a bit more complex.

So why not use polling? Usually, it's because too much polling is wasted bandwidth. And not enough polling, you have stale data. So depending on the nature of the data that you're trying to stream, polling may or may not be a solution. However, it is stateless, and it should scale better, as long as polling isn't overdone.

That lead me to wonder if there was adaptive polling. Why not have clients try and predict their polling frequency based on past observations of their past polling to optimize their polling success. Polling success is defined as every time they poll, they get 1) new data and 2) freshest data.

It ends up that it's a very similar problem in two other fields (and I'm sure many others): web caching and sensor networks. In web caching, you want to cache web pages, so that you can show clients results faster if the page hasn't changed. How do you know the page has changed, and when to throw away the cached copy and obtain a fresh one? In sensor networks, each connection is expensive in terms of energy consumption. How do you know when a node has fresh data, and how often should you poll to obtain polling success? In this case, a master node is analogous to the client and a slave node is analogous to the server.

There's an additional issue to consider. One wouldn't want all the clients hammer the server all at once for a poll. That would make it seem like a flash mob to the server at periodic intervals. It would be best if the clients can spread out their requests, so that the traffic to the server is more constant. That way, the server wouldn't be overloaded. How do you coordinate the polling times of thousands of clients? Wouldn't that create more traffic on the network for the clients to ask each other? I'm guessing no, because the delay in response time from the server would indicate how busy it was at this moment. Using that as a type of "pheromone" from other clients (indicator left by other clients), a client should be able to adjust its offset time for its next polling request.

Sunday, December 03, 2006

Splatting in case statements

RedHanded � Wonder of the When-Be-Splat

I always feel like I'm playing catch up to Rubyists.

BOARD_MEMBERS = ['Jan', 'Julie', 'Archie', 'Stewick']
HISTORIANS = ['Braith', 'Dewey', 'Eduardo']

case name
when *BOARD_MEMBERS
"You're on the board! A congratulations is in order."
when *HISTORIANS
"You are busy chronicling every deft play."
end


That's pretty damn cool. The thing about new languages is that when you're learning to write with it, you'll write it in the style of the old language that you're use to. C programmers will write C++ as if it were C. Java programmers will write Python as if it were Java. Therefore, you might think that there isn't much to be gained from the new language other than some syntactic sugar sprinkled here and there.

As least for me, being open to other constructs like blocks, closures written more like functional programming has lead to more succinct and readable code.

a = [1, 2, 3]
Hash[*a.collect { |v|
[v, v*2]
}.flatten]


I would have done this with a for loop before, and that's probably less readable. But I have to admit, succinct code only has meaning if you know the vocab.

Thursday, November 16, 2006

FireBug for all other things

When working with RJS templates, it can be a pain, especially if you roll your own javascript in there. There's almost no way to debug it, so you have to be very very careful, or use your brain-the-compiler.

But aside from that, try out Firebug. It's a pretty need in-browser javascript debugger for Firefox.

Sunday, November 12, 2006

Symbol conversation in MMORPGs

Blue Rabbit�s Climate Chaos - Adventure Games - GamersHood - Online Games Paradise

This was something that was shown to me by Alison. I just tried it out, just to see what was fun about it. Didn't play much, but I was struck by the fact that this game decided to employ pictograms instead of words for conversation.

Now, I don't know why Blue Rabbit employed this mode of conversation. Perhaps it's because the target audience is young children.

However! I think this would be key to building a more dynamic MMORPGs. I haven't played World of Warcraft, so I don't know if quests are static. But I remember in Everquest, the quests were the same, time after time. Oh sure, there might be grace periods where it wouldn't be there, but for the most part, the same person would have his daughter kidnapped time after time.

Instead of having static quests, I think it would be better to have dynamic quests. It gives a better sense of realism to the world that the gamer is playing in, if the NPCs(non player characters) had different needs at different times.

In the Sims, each NPC is an agent with goals and needs. And it basically interacts with its environment to fulfill those goals and needs as time progresses. But never do any of the characters ask another Sim to fulfill those needs for him. Sure, they have conversations with each other to fulfill the direct need for being social. But they never ask the messy roommate to clean up his mess. They always get irritated and clean it up themselves, or rely on the player to make someone else clean it up.

With a simplified vocabulary of pictogram language, an NPC would be able to express what he desires. And that would be up to the player in the quest to fulfill it. These goals, like in the Sims would change as the environment and needs change.

file_column is easy to use

HowToUseFileColumn in Ruby on Rails

File_column really is a cinch to use. But not without knowing that you needed:

add_column :entry, :image, :string

in the migration. And here I was reading through file_column code. Things are always clearer in hindsight. But it did teach me a few tricks here and there, about how to add dynamic methods to objects.

Thursday, November 09, 2006

Annologger update: Commenting is available!

It's got no pictures of stars, but it's simple. Commenting is up for annologger!

Human verification CAPTCHAs will be done tomorrow, so that you don't get comment spam. In the meantime, get your friends, your readers, your fans, to comment, comment, comment away.

Friday, November 03, 2006

Annologger Update: By popular demand, Annolog Badges available

I'm happy to announce that you can now get annologger badges for your blog or website! What's a badge you say? It's basically a code snippet generated for you that you can cut and paste into any webpage, blog or otherwise. That way, you can floss your events on your blog now. :)

You can get your own annolog at http://www.annologger.com. Under the goodies section, you can create your own annolog badge.

It took longer than I had anticipated, due to not ever working with rjs templates before. I'll write a tutorial up later. On to comments for your annolog!



Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Late to the RESTful party

Apparently, I'm the last fool to really read about it. I only first heard about REST maybe 2 months ago by a long post by one of the rails guys.

Lately (as in the last 6 months), there's been a resurgence in figuring out the HTTP protocol. It's suppose to be RESTful. Mainly, the idea that network architecture are seen as a collection of resources identified uniquely by a URI. And that the whole network application is simply the user in a large state machine, where traversing the different resources equate to state transitions. This has implications of server and client design to be simpler.

Each HTTP request also has a method associated with it. The methods in HTTP most commonly used are GET and POST. In the early days of the web (ie when we were in college), I saw that forms submitted by GET or POST, and for a long time, I had no idea what the difference was. GET is intended to "read" but make no state changes in the server, and POST is intented to make state changes. So doing form submissions with GET is not only semantically wrong, but insecure, since it puts form contents in the url.

In addition to GET and POST, there are others, (I never knew). And the bunch of them map well to CRUD(Create, read, update, delete) operations. And using the native HTTP methods, you can take advantage of things already built into HTTP, like caching (for scalibility) without having to build it yourself.

Here's a simple intro , and I think one of the articles that spawned the discussion. This is the original disseration on RESTful architecture, if you want to read it.

Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Tuesday, October 31, 2006

Annologger Update: now with microformats and iCal


It's been long overdue, but I've added features that I've wanted for some time--mainly microformats and iCalendar. iCalendar isn't fully featured yet, meaning if you subscribed to it using your outlook calendar, you cannot update your annolog from your outlook calendar. That said, I'm working on it, and trying to keep the code base organized and healthy, so that it's not a mess that can easily be broken. It's like cleaning up your kitchen as you cook.

So while it might not look like much, there have been some minor bug fixes and major refactoring to get these features in. Thanks for the feedback so far, and keep them coming. :)




Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Thursday, October 26, 2006

Time can be needlessly complicated

International standard date and time notation

To think that of all things I could have picked to build, it was something centered around time. Having worked on a sunrise/sunset and moonrise/moonset calculator, you'd think that I would have learned my lesson.

Time is difficult because there's always exceptions to the rule, and some specifics are unclear on first thought.

Does midnight belong to the beginning of the day, or the end? Is the end date and time of an all day event inclusive or exclusive? It ends up that luckily, there were plenty of smart people that thought about all of this decades before I came about, but they like to write in a boring prose, in specs like ISO8601.

By the way, midnight belongs to the beginning of the day, and all day events have exclusive end times. However, that's not what people mean when they say they're going to iceland from october 18th to october 22nd. When people say that, the date is inclusive. Aye.

And do you store all times in UTC? Depends on the application. Throw in time zones, there's even more confusion, not to mention taking day light savings into account. And if you really want to get nitpicky, there's always leap years and leap seconds to think about.

Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Saturday, October 14, 2006

Enumerable still...

Still playing around with Enumerables. It was almost not worth mentioning, but it's a short post. I was looking for a short way to read in a file's contents all into memory all at once. Normally you wouldn't do this, because it eats up memory if you do it this way. But my files were short.
File.open('README', 'r') do |file|
file.inject { |contents, line| contents << line }
end

This will open up a file README and return the entire contents as a string. It's pretty cool, since I don't have to muck around with temporary variables much...and it's readable...well, if 'inject' makes sense to you. Also cool is that, like Java container classes, as long as you implement 'each' in your Ruby class, you get all the ones in Enumerable for free. You just have to include it.


Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Friday, October 13, 2006

Screencast of Annologger

Screeniac � Annologger.com

I'm usually pretty busy so I don't search often on the web for what people have been saying about Annologger. But for the first thing that I put out, it's both a bit exciting and apprehensive to hear about it.

I had a really hard time choosing a name for it. To this day, I'm still not quite satisfied with the name, but apparently, people get what it is. So that's good news.

And secondly, it seems easy enough to use, so people seem to get it. I've had a lot more japanese users lately, (presumably from this review and others), and they seemed to put more stuff on there than 'test'.

But all in all, I need to put in the other features that I've been dying to get done, so people get see what its potential is.

Time to get back to work.

Tuesday, October 10, 2006

Singleton classes not seemingly the same as Singleton pattern

So I was looking at someone else's code today, and I saw this:

module Formats
class BasicNestedFormat
class << self
def foo
...foo code...
end
end
end
end


Huh? What did "<< self" mean? I guess I didn't read my Ruby book closely enough. It's apparently a "singleton class", which doesn't seem to be exactly a "singleton pattern".

A "singleton class" is a sole metaclass that 'holds' methods for a single object. It would have been called a 'metaclass', except that it's not the class of a class, but a class of a class that only exists for that one object.

Keep in mind that this is the case because you can add methods to objects in ruby at runtime. Since everything in Ruby is an object(even the classes), it has to go somewhere, and in an anonymous metaclass is where it goes.

One can almost think of them as 'static' methods in Java. However, because objects can be added methods at runtime, they don't necessarily belong in the class, but to the metaclass of an object that only belongs to that object.

They're not like 'static' classes of Smalltalk or Java. You can call self (like this in Java) in Ruby's 'static' methods.

It's a curious construct because you can use it to specify 'static' methods all in one go. It's the equivalent of the following:

module Formats
class BasicNestedFormat
def self.foo
...foo code...
end
end
end


Apparently, you can also use it to do prototype factories. There's more to it than meets the eye. You can find better explainations here and here.

Ruby is weird.


Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Thursday, October 05, 2006

The need to write code, the need to ease reading

Lately, I've been doing more thinking, reading, prototyping, and moving, than I've actually been writing code. One of the things that got me thinking enough to write this post was the classic syndrome of software developers and engineers to be gripped by the "Not invented here" syndrome.

Some would say that's because engineers and developers like to create. That's part of it too, but I think it's also partially because we only get better if we write things ourselves. The only way to learn about something fully is to actually do it. The problem is, a lot of things that we would learn by doing, has already been done for a while now. Beyond linked lists and parsers, most anything you can think of has already been done. Not that we can necessarily do it better, but doing it is half the fun, and it's the only way you can get better.
You won't become a better programmer by passively studying other people's code. Similarly, you don't magically become a better writer by reading a lot of books. You become a better writer by.. wait for it.. writing. - Jeff Atwood
So it's a balancing act between using other people's code and reusing code to be more productive, and writing your own to learn and reduce dependencies.

Another aspect that compells people to write things themselves is that
It's harder to read code than to write it. - Joel S.
I think it's because code, like math, like poetry, is dense. There are meanings and implications that aren't literal and aren't at the surface. There are implications for what gets written at every line, and relies on a culture and context behind it to fully understand it. This is why it's hard to read math equations, Alexander Pope(first one that came to mind), and much less code.
But that doesn't mean that there can't be language constructs to faciliate the ease of reading code. Python does it as a language choice that restricts whitespace. Maybe the computer doesn't care about whitespace, but people surely do.

I have recently found that iterators with descriptive names actually help in reading code. Instead of a generic for or while loop, it kinda helps to have collect, and inject.

It would be nice if code was self-documenting, meaning that you would be able to tell what the code was doing from what the method names and variables were, rather than the comments around it. It would be nice if method signatures were all you needed to know what to put into a method (and no, static typing doesn't help completely here). I wonder if language constructs could help out with it, or would we always need to rely on the stylistic tastes and discipline of the individual programmer to write readable code and documentation?



Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Looking for cumulation in Ruby?

Module: Enumerable

This is pretty basic, but I only recently discovered it. I have a task that I do often in code. Usually, there is some list of things that I'd need to go through, and tack it on to another list if it meets some condition.

funny_posts = []
posts.each do |post|
if post.is_funny?
funny_posts << post
end
end

The same problem appears when I try to summate all the things that fit some condition. I dislike having the initialization there in the beginning. Is there a better/prettier way? I would have thought collect() would be it, but it is mapping one value for another. It's almost like a function in math--a certain input gives you a certain output.

So it was finally that I saw inject(), and it seems to be what I want.

funny_posts = posts.inject([]) do |funny_posts_thus_far, post|
if post.is_funny?
funny_posts_thus_far << post
end
end

I think that'll work. The difference doesn't look like much, but somehow it bothers me when I have that floating assignment before the loop. It's easy during maintainance that someone moves 'funny_posts=[]' far away from the loop, when semantically, it's a part of how the loop will work correctly.

inject() also applied to cases where you're trying to find the maximum in a list.

# find the longest word
longest = %w{ cat sheep bear }.inject do |memo,word|
memo.length > word.length ? memo : word
end
longest #=> "sheep"

I guess it's the difference between functional programming and procedural...using return of value instead of relying on side effects. I use to write off functional programming as something that was antiquited, but now, I'm finding gems here and there in functional programming. It makes me wonder how procedural took off so rapidly. Perhaps programmers think easier in procedural programming?

Update: I guess I should read Enumerable more closely. The example I had with collecting funny posts is done with a method called partition() in Enumerables.

Sunday, October 01, 2006

The names of things

In a number of fairy tales and old legends, the name of a fairy, a monster, or a god was pivotal to the story. 'To know someone's name is to control them', it is said. I actually never gave it much thought growing up. How silly. What's in a name? A Rose by any other name would smell just as sweet.

But when it comes to ideas and concepts, a name is pretty important. Naming a variable, class, or method correctly means that there's some convention the reader of the code can go by to be able to infer how to use it. It's a type of documentation.

So when it comes to finding names for things, I have a hard time. How are 'agreements' and 'disputes' related? Are agreements and disputes the same type of thing? If so, what is the name of that thing? Or are they not the same type, but merely the same thing in different states? An agreement is the alignment of opinion between two parties where a dispute is the disalignment of opinion between two parties?

How about the person that 'seconds a motion'? What do you call that person? What do you call the person that brought up the motion in the first place?

When I think about it, public method signatures should be well designed, so that, like well designed tools, it should be obvious how to use it. However, 'obvious' comes with a background and context, and even culture.

Update:
According to wikipedia, A person that makes the motion is a mover. The person that seconds a motion could be called a supporter. And according to my lawyer and english major friends, agreements and disputes are apples and oranges, apparently. agreements and disagreements are more on the same type.

Saturday, September 30, 2006

Designing iPod vulnerability into it makes it cuddly

Everyone often raves about apple design. How sleek they look. How cool they look. However, there are sometimes practical design aspects that people complain about. Namely, I remember the first generation Nanos would have a faceplate that scratched easily.

However, I wonder if there is a side to the design that hadn't been considered. For a device like the iPod, it had the requirement of storing large amounts of data, but flash devices weren't that big in size yet. Therefore, hard drives were the only choice. However, we all know that electronics and especially hard drives are sensitive to shock. It would lose its performance and its ability to store data if it was knocked around all the time.

Whether it is intentional or a consequence of making it look sleek, the exterior of the iPod, and perhaps its vulnerability, leads people towards behavior that make them take care of it. They buy protective accessories for it, and I'm sure they throw it around less than their phones.

It would be brilliant if that was part of the requirements and spec: to get people to take care of their iPod by making it both sleek and vulnerable. It's much the same way (in function, not in emotion) that a certain instinct gets triggered when we see cute fuzzy things, except Apple managed it without fur or a large forehead.




Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Sunday, September 17, 2006

Waiting for camera manufacturers

Jeffrey Veen

You know I'm not writing code since I've been posting a lot, and also reading feeds. But one last post...

"But simplicity isn't just interface improvements, but acknowledging the right tool for the job. One of the things that has always impressed me about the iPod, for example, is that the devices have no capacity for editing metadata, deleting or moving songs, or any of the other mundane tasks of maintaining your music library. Instead, designers at Apple moved all those tasks to iTunes, exploiting your computer's keyboard, mouse, and screen real estate. Flickr takes the same approach. They could have waited for camera manufacturers to add GPS chips or asked cameraphone users to thumb in their location. They chose, however, to exploit the fact that metadata can be added asynchronously without much penalty."

spoke to me. I have been thinking about this, and was wondering if geo metadata was in pictures. My initial thought was, camera vendors really need to move beyond just taking pictures. Cameras should send photos to a repository automatically over wifi, or cameras should record not only when but also where you took a photo.

Sometimes, you can't, because you don't have any control over those products. Therefore, you make due with whatever interface is available to tie things together first, and then slowly make it better.

Simple yet deep

Point and shoot software - Signal vs. Noise (by 37signals)

I think 37signals has it right with making things simple, and emphasizing simplicity, at least on a first use basis. But I still maintain something that Guy Kawasaki said in his book, art of the start...

I'm paraphrasing, but basically simple for new users, but deep for veteran users. There's something to be said about keep mastering a product over time.

New users, no matter how tech savvy, like simple to use. But there's something to be said for the constant exploration of a device (or domain for that matter). I liken it to driving stick after learning to drive automatic.

It's often hard to build the two conflicting things in a product...control vs simplicity. But I think it's important to think of deepness as well.

Too little focus in the information we get

My Whole Life in Happy Little Folders, by Jeffrey Veen

Jeffrey Veen was complaining that it seemed like all he did was un-bold things in RSS feeds. There's just so much info that you get overwhelmed. This was one of the primary reasons I unsubscribed to ridiculously prolific blogs like smartmobs, and now signal vs noise has hell of a lot more noise now. I still subscribe due to the few gems that get dropped occasionally. But once I find others that are more quality and less quantity, I'm ready to drop them off my feed reader.

But other than complaining about blogs, this was the primary reason that I moved from bloglines to reader google. I found that having the number of unread items just felt like I was being a slacker by not reading it. Google reader is much more unforgiving. News you don't read just become that--news you don't read, and it just scrolls on by as the days past by.

It's not something foresight would have seen, unless you've actually used a feed reader before. But I'm glad that google got that right with their feed reader.

I think there's always phases to technology, as others pointed out. But beyond the adoption curve, there is the phase where the users are over-saturated, and need some type of filter. This is often overlooked in my opinion.

Saturday, September 16, 2006

The FIRST keynote of Steve Jobs 1984

cyberian.nomad.blog: The FIRST keynote of Steve Jobs 1984 - a Legend !

I often wonder what it'd be like to go back to the past knowing what you know. It's been a good 22 years since 1984. The technology back them seems primative, although you recognize a lot of the same elements that you do now.

Could some people envision 2006 if we were to tell them about it in 1984? I think some would. And others, were probably more optimistic about certain things. Notice the AI thing with the Macintosh talking.

What would it be like in 20 years? I have to admit, I am optimistic about the advance of technology. I have dreams for the future. I dream that computing will really be ubiquitous, and that mobile computing and information gathering will be more common. I dream that augmented reality will come to be common place, whether on PDAs, cell phones, eye glasses, contacts, VRDs, or ocular implants. Devices, whether microwave to cell phones, will really begin to interoperate on open standards, and have a collective intelligence for the whole house. I dream that bio interfaces will allow the blind to see, to store information, or to access information. I dream that quantum computers will start to appear on the market. And I dream that code will be modular, reuseable, simple to read, and simple to maintain. haha.

Friday, September 15, 2006

First Principles of Interaction Design

AskTog: First Principles of Interaction Design

To be honest, this is a boring list of things to read through. Some seem obvious and common sense. But you'll find that in design, often times, obvious is shadowed by functionality and common sense is hard when you have constraints. This might have been better reading if it contained examples, like in The Design of Everyday Things.

But what I noticed was that these principles were very similar to those of game design. I can't pinpoint the article this afternoon, since I read it close to six years ago. But there was an article on gamasutra that talked about how hard it was to design games to make the player happy.

The game designer has to balance the hardness of the game. Too challenging, the game will be unobvious and frustrating (like this game was purported to be). Too trivial, the game will lose the interest of its players quickly (like Eat the stick.

I remember another thing about consistency. One game designer was talking about how he met a gamer, and the gamer had the idea that once you go to another section of the game, all the properties of the spells you could cast would change. The game designer went into detail about how this was one of the worst mistakes that early game designers make. Consistency affords a sense of building up a knowledge of the world around you from a player point of view.

If every time you went to another section of the game, and you had to relearn the mechanics of the game all over again, it would probably piss you off.

In a lot of ways, there are parallels between game design and application design. I also remember all those comic strips in the 90's satirizing how kids can't get jobs playing video games growing up. I think that's more and more untrue, with the way the gaming industry is unfolding. The idea the games are a diversion and are for children will be a thing of the past.

Monday, September 11, 2006

Friendships aren't binary

I feel old. Partially because social networks separate me from friends that are merely two years younger. I am part of the 'Friendster' generation. I was able to sign up for that, before the meteoric rise of 'MySpace', and 'Facebook'. I ignored MySpace invitations, writing it off as 'nothing special' (I also thought that Britney Spears was going to be a one-hit wonder), and by the time facebook rolled around, I had already left graduate school.

While I'm excited about social network applications, my opinion of social network apps was that they didn't actually DO anything. Beyond the novelty of being able to see my network, trouncing about the network didn't actually let me get anything DONE. No wonder why people called them the biggest waste of time. Perhaps, like bad TV, it was just a reaction to a guilty pleasure.

However, it was recently that I was able to sign on to Facebook, because I found that there is an alumni web mail service that I was able to utilize. I liked the Facebook interface immediately. Unlike friendster, it was clean, and it was fast. It didn't feel cluttered at all.

On the friends page, it would tell you that a profile was updated, and yet, I didn't know what. So I never really browsed, knowing that I won't want to spend time trying to find it. Therefore, I was pleasantly surprised by the mini-news feeds: now I knew exactly what was updated, so I don't have to look around for it.

Here, I was able to see what my network was doing. What groups they were joining, what messages they were posting. Perhaps here-in lies the utility of a social network; an individual would know what's going on with his or her friends. The flipside of this feature was that most people felt like their privacy was invaded.

It's odd, because I, as a newcomer, didn't have much expectations of how things worked, so I more readily accepted the mini-news feeds. Therefore, I wonder if facebook had this feature in the beginning, would there be as much of a protest? Perhaps it would have had slower growth?

I think the assumption that facebook developers had was that
  1. users wouldn't mind that their friends knew what they were up to because of #2
  2. everyone named as friends were trusted
  3. all friendships are created equal
In reality, often times, the people in your friendship list might not be friends, but contacts, or campers. And even if the only people that you accepted were friend friends, not all friends are created equal. I think it's safe to say we all have aspects of ourselves that we show in front of some friends but not others. I remember I had friends in college that did weed or drank a ton, but they never invited me out with them to do it.

Given that, I can definitely see how they went ahead and did it. And often times, as a developer, if you don't simplify things, you'll never get anything done.

One, facebook's reaction to the backlash was a pretty good one, in my opinion. They put out a major announcement, as well as give one-click options to remove it by choice within two days. I applaud them for it. However, they managed to keep things simple. Choice can easily come with its strange bedfellow, complexity.

Second, perhaps, the model for naming friends should be changed. Perhaps it shouldn't be activated by individuals, but rather, inferred through activities. Then, you can be able to tell between active friends, and long lost friends. You would also be able to tell the context of the relationship, as well as which domain it falls under. Then perhaps, privacy would be less of an issue with a selected multicast of information, such as photos, who I'm dating, and where I'm going.



Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Sunday, September 10, 2006

Cavets for doing what you love

The usual thing that you hear we tell kids is "you can be whatever you want to be" when it's really not entirely true. A more accurate saying might be, "you can be whatever you work hard at, even if you might not be the best." For adults, the line is, "do what you love."

What if you suck at what you love? If American Idol is any indication, passion doesn't always equal aptitude. Beyond American Idol, there are plenty of people that are always 'striking it out on their own' that are still doing so. There's plenty of actors and actresses that are waiters and waitresses. I suppose the assumption is that when you do what you love, you will spend time doing it, instead of going out, instead of playing video games, instead of watching TV. You'll keep going at it even after failure and rejected. And the biggest assumption is that you'll get better as you keep going at it.

So keep at it. And get better.



Wilhem has built Annologger, a tool that lets people worship your dentist appointments.

Thursday, August 31, 2006

Getting Started - UIDWiki

Getting Started - UIDWiki: "Turn on Javascript errors for extensions. Normally the Javascript console only displays errors for web pages, not for Firefox or its extensions. Go to the URL about:config and turn on javascript.options.showInConsole."

This'll help speed development.

Sunday, August 27, 2006

Moving people versus building things.

My sister often marvels at my ability to build things.
You know, I always feels useless around you because you have tangible skills.
Being an engineer, I often found envy from the liberal arts majors on having 'tangible skills'. I was in a business writing class that was required of all majors, where we learned the basics of writing letters, resumes, and memos. During the resume writing session, we were doing peer critiques.

Looking at the number of projects that I've done, the programming languages I knew, the liberal arts majors exclaimed "Wow, you actually have skills!"

However, I find that the ability to move people is just as important. There are many things you can do as an individual nowadays. We have plenty of tools and information available for us to do that, more than ever. And yet, there are certain types of things where you need a group of people to move forward with together. And in order to do that, one has to be able to guide people in the same direction, to be able to move them in the same direction.

That, I find to be a skill more enviable.

Friday, August 25, 2006

Temporal Expressions as a cousin to Regular Expressions

When thinking about recurring dates, I realized that it's actually a pretty tough problem. How do you represent recurring dates in a database? Ideally, you don't want all the instances of recurring dates from the epoch until the End of Time. I had an inkling that it should be possible to express a generalized sense of a range of dates, but I didn't really know exactly how that would manifest itself.

That's when I started looking for what people had done before me, since I dislike reinventing the wheel. The first thing I came upon was this recurrence python module. Reading his comments in the code, I thought being able to express dates as an equivalent of a polynomial made a lot of sense.

In fact, functions are condensed form of a set of numbers. Not all sets of numbers can be expressed by functions, but most of the ones that we care about can usually be. That makes them useful. Are there equivalent of 'functions for dates'?

That's when I ran into Runt, a ruby library that deals with recurring dates, which are based off of temporal expressions pattern by Martin Fowler.

But it wasn't exactly what I had in mind when I read 'temporal expressions'. I was thinking that Martin Fowler came up with something like regular expressions, but for time. After reading the tutorial, it wasn't exactly what I had in mind. It used classes and patterns to represent recurring dates, rather than an expression, like a function.

So we come to the crux of my musing. Are there the equivalent of regular expressions for time, and would it be a good idea to use it?

When I first started using regular expressions, I thought it was hard to use. Not only could I not remember what some of the symbols meant, but it was dense and not easy to read. A complicated regex quickly got out of hand. I wondered if there were alternatives to regex. And apparently I wasn't the only one either(and that post was from 2001).

If I were to use something like regex for date and time, like a temporal expression--tempex*, I wouldn't want something syntactically like regex. It's really rather hard to read, even if it's powerful (read "dense": can say alot with a little).

In drawing the parallel between regex and functions, that could be the reason why people find math arcane: the expressions in math and regex both can say alot with a little.

One should be able to represent dates and times in a matter that you can express sets of dates succinctly, and event better, be able to do operations on them, such as union, intersect, and difference.

I was surprised that it seems like there's nothing out there that I can find that is a regular expression for time. This shouldn't be the case. Runt is the closest thing that I can find so far. Anyone else know of anything else out there?

* I'll have to pick some other name later. people already use the term for natural language processing of time-related phrases, in addition to Martin Fowler's usage for the pattern

Friday, August 18, 2006

Back to coding

I've been getting back into the swing of things after a brief haitus. Currently, there's a code freeze, so I can catch up with the tests. I know I'm not suppose to do it backwards like this, but when you're sketching out how things should work, updating both code and tests are tedious.

I figured this is a good time to update all the tests, so code freeze for about 3 days. Code coverage at...53%

I'll do more tonight. Then it's off to do more cool and exciting features!
  • RSS feeds
  • iCal publishing
  • better date/time selector
  • end dates that matter
  • photo posting
  • "I'll go if I can"

Friday, August 04, 2006

Major Nelson's Xbox 360 can blog

Major Nelson's Xbox 360 can blog

devices can blog...it's a readable log, really. Machines often log events that happen to them, but never really in a human readable form with style and prose. This illustrates that it's definitely amusing and possible, especially if personality engines were invented and utilized.

But in the end, the devices reflect its owner, and how they live their lives. As more and more devices log your life, you can compile stats and see how you actually live it in the long run, and be able to make changes and adjustments if you wish. This, to me, would be the ultimate personal information. Privacy in this term would have to be strictly protected.

Wednesday, August 02, 2006

Wheel robots makes designers rethink cars

This article about Smart Cities Team at MIT excited me a bit, not so much because of its potential (which is neat), but more the fact that they rethought the engineering of the car.
The MIT concept car is a complete re-think of vehicle technology. For a start, there is no engine, at least in the traditional sense. The power comes from devices called wheel robots. "These are self-contained wheel units that have electric motors inside,"

A traditional engine puts engineering and design restraints on what type of wheel rotations and movements are available. Because of this restraint, we've gotten so use to the idea of a car only having steering in the front two wheels.

With wheel robots, all the wheels can rotate independent of each other. That means that you can rotate while you're going forward, or slide into a parallel parking space. When new technology becomes available, we should take a step back and rethink why design and engineeering decisions were made in the first place.

Saturday, July 29, 2006

Annologger update: now with pretty templates

Post and publish a schedule of events for your friends, your readers, your fans, no matter who you are.


I've just released v0.3 of Annologger. Now it supports pretty templates, as well as tweaks on UI interface. There are lots of little things that I've changed here and there to facilate ease of use.

The templates are from OpenWebDesign.org. These templates are all public domain, thanks to Chris Pearson, James Koster, and Pat Heard(template not shown) for submitting their fine work to OWD. Hopefully, the more people use annologger, the more exposure they'll get as designers.

It's been hard work in the past week, and I had lost track of all time. I had thought it was Weds when it was really Friday.

Tuesday, July 25, 2006

How to apply min-height in IE and other browsers � WordPress Support

How to apply min-height in IE and other browsers � WordPress Support:

#insideWrapper {
min-height: 500px;
height: auto !important;
height: 500px;
}


Another common problem with IE. This is a good fix for having min-height supported on both firefox and IE.

Announcing Annologger

Post and publish a schedule of events for your friends, your readers, your fans, no matter who you are.

I'm officially announcing Annologger. It is now up and running on beta. It's free to join.

Annologger lets you post and publish a schedule of events to the web. Each schedule listing not only displays the events in an organized matter, but also facilitates interaction between you and your readers.

This is a sample of a live annolog that is generated by Annologger. Try it out, and give me feedback.

PNG in Windows IE

PNG in Windows IE

This has been a pain in my butt for some time now. No more GIFs! I think lots of people probably already know this trick, but it's definitely worth mentioning.

However, it still doesn't fix the problem of using transparent PNGs for backgrounds in IEs.

Monday, July 24, 2006

What sucked about getting your feet wet in J2ME

The last two days were spent on trying to get the JavaME Wireless Tookit from Sun up and working with EclipseME. It's been a frustrating experience, to say the least.

I did find this webpage with a lot of information on hacking and modding your V3 RAZR. It's got a neat little story on the history behind the RAZR.

But aside from the cute diversion, I found on a forum at MotoX, that RAZR V3 isn't capable of upgrading its Java CLDC from 1.0 to 1.1, even if you flashed the firmware.

So it looks like I'll have to go find a phone with CLDC 1.1 to get anywhere.

Patching tests for Salted Login Generator

It's odd, but I was having problems with the SaltedLoginGenerator for Rails. I wasn't able to run the tests at all with rake. I was getting:

/usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb" "test/unit/entry_test.rb" "test/unit/user_test.rb" "test/unit/localization_test.rb" "test/unit/stencil_test.rb" "test/unit/publisher_test.rb" "test/unit/annolog_test.rb"
/usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:74:in `load_specification': undefined method `parse' for Time:Class (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb:307:in `date='
...clipped...

and then later on, after a fix (I'll describe it later), I was getting:

/usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb" "test/unit/entry_test.rb" "test/unit/user_test.rb" "test/unit/localization_test.rb" "test/unit/stencil_test.rb" "test/unit/publisher_test.rb" "test/unit/annolog_test.rb"
/home/wil/proj/3cgworkspace/annologger/config/../test/mocks/test/time.rb:5: undefined method `cattr_accessor' for Time:Class (NoMethodError)

I think that problem was that I had an older version of rails and ruby, so I've updated to both ruby 1.8.4 and rails 1.1.4. And because I didn't generate rails with the new version, I had to insert these two lines requiring both 'rubygems' and 'time' into my test_helper.rb under test/, before requiring the environment file in config

ENV["RAILS_ENV"] = "test"
require 'rubygems' # patch to fix undefined 'cattr_accessor'
require 'time' # a patch to fix undefined `parse'

require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'

class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the

Thursday, July 20, 2006

Finding easy-to-read web content

Finding easy-to-read web content: "Posted by T.V. Raman, Research Scientist

Like most of you, when I search the web, I want to find relevant information with a minimal amount of distraction. But because I can't see and I use a device that converts web text to speech, I'm even more in tune with the distractions that can sometimes get in the way of finding the right results. If the information I'm after is on a visually busy page, I have to sort through that page to find the text I want--an extra step that can sometimes be very time-consuming."

It'd be nice if this could be used for filtering out ads.

Saturday, July 15, 2006

The uniqueness of mobile devices as a platform

About a year ago, I searched on the web for opinions on what are the killer apps of mobile devices. By its original definition, a killer app is a piece of software that someone would want so bad, they'd be willing to buy the hardware just to run it. But now, 'killer app' is used simply as a piece of software lots of people will use. I was curious about what people predicted.

I read all sorts of things; that mobile gaming, ringtones, web browsing were the killer apps. Others lauded that voice--being able to make calls--is the only killer app you need for mobile phones.

I beg to differ. I think with every new platform, people first make copies of what they could do in the old platform before really realizing what the new platform has to offer. From the paper platform to desktop platform, people first made spreadsheets and word processors before making web browsers. Same thing happened when we had the web platform.

Mobile devices has a unique set of characteristics. While other platforms may share some of the characteristics, they don't have all of them.
  • They are mobile (obvious)
  • They are always connected
  • They can get location-based information
  • They are almost always on a person, and considered personal by the owner
  • They are the gateway to other people all the time
Verizon and other carriers currently offer boring services, such as ringtones, wallpapers, video casting, and weather. They might take advantage of the first three attributes, but I feel the real power of the mobile platform is its decentralized nature, and ability to create social spaces based solely on the fact that they're always on a person. And in essence, other people, in whatever form, is what we like to interact with.

Dodgeball and Twttr are moving in the correct direction. But I think there can be much more done with it. Decentralized messaging that moves people to emergent actions would be something like a next step.

A more concrete example would be an application on your mobile device that tells you what everyone you care about is doing locally--either locally in time, in proximity, or in your social network. But this information would have to be presented in a way that creates a positive feedback, so that the more people are doing something, the more other people will do it.

I'm going to do some hand waving here, as I don't know exactly what would compel people to participant. It could be something as simple as showing how many other people are doing it. However, the point is, if this positive feedback mechanism was in place, you could have Digg and Slashdot effects happening in the real world.

Imagine that.

But if it got out of hand, it wouldn't be good. Mobbing is never good in real life, and I've warned about the tyranny of the masses in a previous post. But I think that's the potential power of mobile devices.

Something's a twttr-ing in the morning

I was chilling out, thinking about going to sleep when the secret mail sent me this link to Om's post on Twttr

There's lots of ways to describe twttr, but at its simplest, it is a service that notifies your friends (people that care) about your presence and status. Technically, it's very simple: it sends your SMS text messages to all your friends' phones. On the flipside, you will receive txt msgs from those friends that you want to get msgs from. You can view the stream of text messages on the web, from yourself or all your friends. While this has the potential to spam your phone, I think they're on the right track with development on mobile devices.

Thought of another way, it's a more fine-grained blog that encourages short, and otherwise ethereal thoughts to be sent. Where as IM is presence on a computer or sidekick, and blogging is presence in a world of ideas, twttr encourages the idea of presence as "what are you doing at this moment" to bleed into real life.

Mobile devices have certain chacteristics unique to the platform. I think this application takes advantage of the unique characteristics of a mobile platform, unlike the boring applications that Verizon comes up with, like directions and video casting.

Offline rdoc gem documentation in Ruby

I always forget how to do this one, even though it's really simple. (Make sure that you have rdoc installed first) To view all the API documentation in gems, simple run:

gem_server
gem server

from the command prompt. It will start a WEBrick server up on your local machine on port 8808. Therefore, if you browse to http://localhost:8808/, you'll see a list of documentation of the gems on your machine.

Updated:
It's incorporated into the gem command now, so just do "gem server"

A short Net::SFTP tutorial and freezing gems

FTP itself is not very secure, since it sends a user's login and password over cleartext. So while Net::FTP in Ruby is pretty handy, I'm hoping to wean off of it soon.

That's when, after poking around for a couple minutes that Net::SFTP exists under the Net::SSH project. Huzzah! Yet, shared hosts don't have the ability for you to just install anything though. So it was then I found:

gem list --remote net-sftp
gem install net-sftp

So that way, I can install it as a gem on shared hosts. Also, I had forgotten how to freeze gems in rails. After lots of futile searching, I did come across a more automatic way. I didn't like the way it copied everything in the ./lib, because ./lib is suppose to be for in-house libraries, and ./vendor is for 3rd party libraries. I'd like to keep them separate.

Update:
So I remembered there was a manual way to do it....Ends up is that all you have to do is copy your gems into the vendor directory. use:

gem unpack gem_name

And it'll copy the gem into the current directory for you. However, in order to be able to include it as if it were a library, you'll need to change the environment.rb file found in your config directory in your application root directory.

Under the Rails::Initializer.run do |config| block, you'll see "config.load_paths". Uncomment that line and add the various gems in the vendor directory. Note that you don't put commas inbetween every path.

config.load_paths += %W(#{RAILS_ROOT}/vendor/needle-1.3.0/lib/
#{RAILS_ROOT}/vendor/net-sftp-1.1.0/lib/
#{RAILS_ROOT}/vendor/net-ssh-1.0.9/lib/ )

So now, you'll be able to do "require "net/sftp" even if the gem isn't installed.
Update:
So how do you use the Net::SSH and Net::SFTP libraries? Just looking at the APIs, I thought I could piece it together, but it's not as simple as it sounds. It took a bit of poking around to find this manual for Net::SSH. There is no manual for Net::SFTP--only a Net::SFTP FAQ. And after looking at the manuals and FAQs, it is as simple as it looks. I wonder why I didn't get it...

Here's a little tutorial on how to start an SFTP session.

require 'net/sftp'

Net::SFTP.start(host, user, password) do |sftp|
sftp.put_file "/path/to/local.file", "/path/to/remote.file"
end

Albeit the SFTP library is complicated and kinda hard to use, the coolest thing that I found out about is that you can do is actually upload a file from memory. I wasn't able to figure out how to do this with the native Net::FTP library in Ruby.

require 'net/sftp'

data = "This is the contents of my file"

Net::SFTP.start(host, user, password) do |sftp|
sftp.open_handle("/path/to/remote.file", "w") do |file_handle|
contents = sftp.write(file_handle, data)
puts contents.code
end
end

I don't know exactly how this is done, but my naive guess is that since you already have an SSH session open through SFTP, you're able to perform native commands outside of the FTP protocol? Either way, it's just what I needed, so I wouldn't have to create local copies, upload them, and then delete them.

Making Debian packages from self-extracting installs

I usually just installed tarballs or self-extracting files, because that's what the instructions said. And it's also kinda cool to be able to run make and watch it compile. However, it makes for a mess when you have to keep track of what you installed where, especially if the install isn't all in the same directory in linux.

RPM was always hard for me to use...I dunno why. Maybe it's because of all the flags, I could never remember what they were. That's why yum and apt-get for fedora and ubuntu have been godsends lately.

This article describes how to convert the java 5.0 sdk from the self-extracting file into a debian package so that you can install it in ubuntu.

According to my roommate, this way, if other packages that are installed need java, they'll know that it's there, and won't ask for it.

Good plan.

So I think I turned over a new leaf. From now on, I will always make packages from tarballs.

Friday, July 14, 2006

S5 slideshowing

S5 has gotten less attention than it should have, once I realized what S5 stood for. To start, you can say S5 is powerpoint done through the web. As long as you have an internet connection, you can make, edit, and share powerpoint presentations very easily.

I didn't think much of it at first, since a lot of people are simply taking desktop applications and putting them on the web. Writely is a word processor on the web. There's someone else doing a spreadsheet that I can't remember the name of.

But S5 = "Simple Standards-based Slide Show System" It basically uses XHTML, CSS, and javascript to make slideshows. The advantage is that to make new themes, you can just change the CSS. And you can also write scripts to generate slideshows. I once had to put together 200 slides of graphs in MS powerpoint. It sucked, and wished I could script it, since it was a very mechanical procedure.

And presentations would transfer easily from place to place...given that the network was available. I think it'd be useful when wireless internet connection is ubiquitous.

Wednesday, July 12, 2006

Remember in Ruby it's raise/rescue, not throw/catch

Yesterday, I spent hours debugging a stupid exception construct in ruby. Why wasn't it rescuin the thrown exception? Ends up that it's because you RAISE exception, not throw them. Throw/catch mean completely different things in ruby.

Raise/rescue! And another thing I forget often is that I have to raise an instance of a class, not just the class itself!

Online communities were never meant to supplant real life

At least with this article, it sounds like she really uses these services as opposed to someone that just heard about them and rags on it without ever really trying it out.

Online communities were never meant to supplant ones in your in-person life. It just adds another dimension to it. Sure, you'll get people that go overboard and cut off their in-person relationships, but they're the outliers. For certain types of interaction you'll probably find that most people would prefer face to face interactions. These types of interactions include friends that you already know and for finding mates. It's for that reason that friends still get together when they're in town and that people on match.com still meet first before committing.

For other types of interactions, like Brad Pitt fan club forums, World of warcraft (online game), and scientific google groups, your only interest in the other people is only within the confines of those contexts. And while that's what I imagine rubs people like the author of the NYTimes article the wrong way (having a cafeteria tray attitude to getting to know people). The people we interact with no longer has to fill every aspect of our social needs. It is acceptable now to have friends you only hang out with, friends you only tell secrets to, and friends you only go on naked streaking parties with. The same goes with people you interact with online.

Cars and suburbs have probably done more to keep people apart from each other than the internet has. Think about it. You use to have to walk to the local store, passing people in your neighborhood that you knew along the way. Now, you just drive on the highway. Suburbs rarely have sidewalks, and things are further apart, so people use their cars to drive, and not interact with each other.

And even if there were people around, you wouldn't necessarily want to talk to them. Out of all the times you've ridden the subway, when was the last time you struck up a conversation with a stranger sitting next to you? I'd venture to say, very few. Now if you lived on the West Coast (except LA)...maybe things would be different.

In addition, I've often discovered that some people didn't keep friends in a certain part of their life because, "We just hung out together, and did stuff. We didn't really get to know each other." Just because a relationship is face to face doesn't mean that you will have a deeper connection with each other. No matter what the medium, it takes effort on both sides. Besides, just because there are people around doesn't mean you're not lonely. I had always taken Nighthawks to illustrate that, and Edward Hopper was way before the internet.

Presence doesn't have to be physical anymore. It can be across different spaces, and even asynchronously across different times. While these forms of communications like cell, IM, email, blogs, wikis, forums, VoIP, etc are just facsimilies of face to face interactions, they're good enough for what we need to get done or enjoy just a snippet of each other. Between friends that can't meet face to face all the time, it's better than nothing.

And some forms of communication and interaction, while more limited to face to face, actually are beneficial in other ways. There'd be no way you'd be able to produce an encyclopedia from a room full of hundreds of people, as you do with Wikipedia. Online forums leave a trail of solutions to questions and problems others have encountered. I can't tell you how many times I've gotten help with configuring my linux box or rails when I've hit upon a wall from the dregs of people helping each other.

The current body of social network web applications, however, do have a problem. While novel at first, you quickly realize that they don't actually DO anything. If it helped people connect to not only their friends, but also connected you to like-minded strangers, or MOVED people to action, then that would really be something. But the current incarnation of social networks have much to be desired. Like all revolutions, it always takes a bit of tweaking, yet it's not going away. Developers are experimenting with other types of social networks, such as the recent Twttr and Dodgeball.

Online communications are here to stay, and like all things, it's good in moderation. No matter the medium, it takes effort and attention from both parties. It's the dual act of giving and receiving that makes a relationship between humans worthwhile. Online communications only provide the conduit, even if it's a facsimilie of real life. But it's up to you to do the rest and fill it up with meaningful content.

Introduction to Bindings in Ruby

When it comes to programming languages, software developers really are zealots--everyone has their favorites. Like Paul Graham says about himself, you shouldn't just listen to a person just because they have notoriety. But I think his article about how some programming languages are more powerful than others is convincing (can't find the link right now).

What I liked about Ruby over Java or C++ most are the different types of programming ideas that I've had to wrap my head around. Just yesterday, I was looking at Ruby's ERB (Embedded RuBy) library. It executes ruby embedded in text (plain text or html). Most commonly, Rails uses ERB as a way to translate view templates into html to be displayed to the browser.

I had the problem of trying to render templates outside of controllers, which was why I was looking at ERB. I couldn't get the ERB to read the variables I had defined in the function. I mean...that's the way it worked in the controllers!

@title = "The web and all that jazz"
template = "<html><body><%= @title %></body></html>"
erb = ERB.new(template)
html = erb.result

It didn't take. It ends up that you'd have to pass ERB the current binding as well, because it assumes TOPLEVEL_BINDING. I think ERB uses eval() heavily, which in turn uses binding.

html = erb.result(binding)

binding() is a kernel method that returns the binding--essentially the scope which code is being executed. Not only that, binding() returns the binding as an object, so you can store it for future use, and even pass it around. That means that you can request the scope of a block of code (the variables that are available to it) at that time in execution, and use it at another time, when that scope might have already expired.

So in the erb example, result() was assuming scope at the very top level of the application, rather than the local scope. And that's why it couldn't find @title.

I only found one extensive article on binding. It has great examples on binding.

Being able to pass around bindings seems odd to me. It's like being able to pass scope around, and I wonder if it violates encapsulation...or maybe it's ok to violate it once in a while? But then again, I remembered that closures and blocks in ruby also have bindings. The scope in which a block is define is remembered, and can be passed around; and it's part of their power. So every time you do an array each() and pass it a block, you're passing around bindings as well. It's so much easier than messing around with function pointers.

Saturday, July 08, 2006

BlogShares - Fantasy Blog Share Market

I knew that people trade all sorts of stuff besides stocks. Fantasy Sports is a form of trading...you make educated guesses based on how well you think the players are going to do. And if you think the player's not going to do well in the future, you try to trade it for someone else that another player is willing to part with.

People also trade weather! So it seemed brilliant to me when I saw Blogshares, a place where you do can fantasy trading on blogs.

It seems like any complex system on the edge of chaos are systems that people like to trade. Because if something was completely predictable, it would be trivial. Everyone would know which the best pieces were, and wouldn't want to trade once they had it. If it was a system that was completely random, I argue that people wouldn't trade either, because the only heuristic that would work with minimal effort is to choose and trade randomly. I'm not sure why, but it's my experience that people don't like that, especially if something's at stake.

Wednesday, July 05, 2006

Cellophane as a cheap skin

This article from ZDNet via Smart Mobs talks about how cellophane is a pizoelectric. Pizos are materials that can bend if an electric field is applied to them.

Pizos are important as both sensors and actuators. If you apply an electric field to pizos, they bend, and hence they are actuators. If you bend a pizo, it should generate an electric field.

To make a pizo with cellophane and a thin layer of gold is a pretty shocking development, because they are cheap materials (a thin layer of gold is not too pricey). It opens up the door to lightweight and cheap pizos.

Rollable keyboards are now possible to be cheaper to make, in addition to surface skin tables for user interactive screens. Wouldn't it be possible to use something of the equivalent of Surface Acoustic Waves, to detect where something was touched?

Friday, June 30, 2006

Voting and the tyranny of the masses

College startup askes:

What if the New York Times let users vote on stories on their webpage the way Digg lets users vote? Wouldn’t it be more interesting to visit the website and see what real people found interesting? Wouldn’t that help the editors figure out which authors were most interesting to the public?


The internet has changed a lot in just the last two years. Despite social pundits predictions of saying that the internet separates people, we find that more and more internet applications are social, and brings them together in different ways. There isn't just IRC, homepages, newsgroups, forums, and eBay anymore; but now there are blogs, digg, and del.icio.us.

And where we find ourselves right now are social web applications--things that connect people to each other through some medium. I too am excited by the democratization of mediums, such as keyword tagging in flickr and del.icio.us, and the voting by members of digg. It allows fridges and innovations not normally seen in mainstream to rise meteorically to the attention of the masses.

The concept of decentralized thinking is alluring in that it is the anti-thesis of traditional centralized mediums, such as radio and TV. Also, it allows the individual more power, especially individuals on the outside of established paths.

The current political climate also allows such decentralizations, as opposed to the red-scare in America 40 some odd years ago.

However, despite the good movement towards democratization (used in the sense of giving more power to individuals not in established institutions), I don't believe it's applicable to all mediums.

There's a reason why the American founding fathers did NOT make a democracy; rather they deliberately made a republic. The distinction is that it respects the rights of minorities, and hence the existance of the electoral college.

Currently, Digg is a direct democracy--a dictatorship of the majority. While this is good for any type of fringe news, I don't think it is good for the type of news that the New York Times intends to deliver, which is informative in the public interest.

If the New York Times gave a direct democracy for all its news, then only the "fun" and "quirky" stories will rise to the top. You'd probably see more stories about Hollywood than about police corruption in the city.

There would need to be some type of segmentation for categories, so you can see the most voted for a particular category. Or, there would be a need for some type of electoral college for the New York Times.

Decentralization of new mediums is exciting and enables new things to happen, new innovations, and new ways to communicate. However, it would be a mistake to think that the new transplants everything old. The old is sometimes that way through intent, not by limitations.

Try Ruby in Second Life

Secondlife really amazes me more in the fact that the company had enough foresight to make secondlife a platform more than it is just a playground or game. The fact that you can try out ruby in-game is pretty amazing to me, and should draw more builders (developers) into the game. I should really try it out (been meaning to since college) to see what it's all about.

Oh, here we go. Teach your avatar Ruby and double the population of Rubyists at once. If you want to toy with it, contact Jesse Malthus.


I wish ther were more companies that would provide new platforms for developers to create on. The traditional car and home industries has been really slow on the uptake with this one.

Tuesday, June 27, 2006

Internet pizza ordering should make sense like everything else

My roommates and I ordered pizza over the web yesterday, just to try it out. It was not as easy as calling yet. Besides not being able to find a couple links as to how to pick up instead of deliver, there were two things that struck out at me.

One, when selecting toppings, the interface was a pulldown menu. If this was in beta, I'd forgive it. But I don't think they're going to improve on it any time soon. What they should have used was an ajax "shopping cart" where you can drag and drop. But instead of "items and cart", you'd call it "toppings and dough".

That interface would make much more sense.

Second, there was no time estimate as to when the pizza would be done. Even if it said in hardcoded text, "about 45 minutes", it would be better than nothing. But ideally, it would be able to communicate back and forth to the pizza place's oven, to know approximately how much time is left in making the pizza.

Monday, June 26, 2006

Basic concepts goes a long way with SVN

bash$ svn commit . -m "delete feed_tool tests"
Authentication realm: xxxxxx.com
Password for 'xxx':
Sending .
svn: Commit failed (details follow):
svn: Your file or directory '' is probably out-of-date
svn:
The version resource does not correspond to the resource within the transaction. Either the requested version resource is out of date (needs to be updated), orthe requested version resource is newer than the transaction root (restart the commit).

I was wondering why it wasn't committing, and honestly, it's pretty easy once you figure out what subversion's concept is...and I for one, had never read it.

Simply update your version with

svn update

And it should work. The version that the repository had just wasn't the version you had.

Friday, June 23, 2006

protect?() doesn't work for salted login generator

For rail's salted login generator, the protect?() method didn't work for me. So for those of you that can't get it to work, instead of messing around with it, use the other syntax instead.
before_filter :login_required, :except => ["login", "logout", "signup", "index",
"welcome", "change_password", "forgot_password"]

Friday, June 16, 2006

Medallia Blog: SmackBook Pro Archives

Medallia Blog: SmackBook Pro Archives

This is pretty cool. The guy took the accelerometer in hard drives and used it as a sensor to detect slaps on the laptop. Then, he hooked it up to a desktop manager so that he can change virtual desktops by slapping his laptop on the left or on the right.



This is pretty cool by the sheer fact that he combined things that weren't meant to be used together for something novel. And most of all, the user interface MAKES SENSE.

I too want the capability, but I'd have to build my own accelerometer from the USB drive. Do you think people will want them?

Thursday, June 08, 2006

Wired News: A Sixth Sense for a Wired World

Wired had an article on added a magnetic sense to your touch. It's interesting to see another way to add senses that isn't technologically prohibitive. However, getting surgery done, however small, for it is a little insane. I can't imagine a knife to my finger tips. That's gotta hurt.

It reminds me of the article in BBC that I read about using the tongue as an interface conduit for spatial information. They fed sonar information to a tongue actuator so that people can find their way through a maze with sonar information. It's actually kinda neat, though it's still in its preliminary phases.

I wonder if remote-sensing and remote-controlling augmentations of humans would combine as tools for specialized human workers.

I'm sure the military is interested in something like this, though I can imagine it being a fad or fashion.

Friday, June 02, 2006

Second Life and breaking out of the mold

Second Life - Wikipedia, the free encyclopedia

Second life is a MMORPG that's not so much focused on killing and owning, but creating and interacting with others and the environment created by others.

One of the things that was surprising to me was that people seemingly easily scripted complex behaviors into the objects that existed in the second life world. I had often thought that it would be neat to incorporate that into an MMORPG so that people can be blacksmiths or at least spellcrafters.

However, I would wonder if it was possible for people to use the in-game programming language to invoke computation and behaviors on the machine that's running the virtual world.

In every sense, it is very much like asking how secure is a virtual machine running virtual code on a machine? Is there a branch of computer science that studies this?

Thursday, June 01, 2006

Designing Flash mobs

Joi Ito's Web: Leadership in World of Warcraft

I had talked earlier about a new medium that intermixes reality and the internet.

What concerned me was the level of organization that was needed in order to 'get stuff done'. Even if you did get a bunch of people somewhere, would they be able to accomplish tasks without an inherent hierarchical organization, like most of our governments and companies?

Sure, a bunch of people can point to a rug, or stage pillow fights, but would they be able to fix a house or clean up the neighborhood?

I understand that not all complex behavior of a bunch of people necessarily need a 'leader'. Systems can be emergent in order to accomplish complex tasks. Ants and termites can build complex structures and societies with solely local interactions, rather than top-down hierarchical. But can these systems do everything a hierarchical system can do? And if so, how would you design them so that they evolve themselves?

Has any one done studies on how to design mob systems so that they can do things that companies can do? Are there ways to structure an organization so that people can be thrown together and something comes out of it?

It was that question that lead me to wonder how raids and groups work in the World of Warcraft. It was no coincidence that this article on leaderships in WoW got me thinking about it. According to the description, however, even the raids and groups there are hierarchical, and require quite a bit of planning and leadership.

Perhaps a little mix of both would be effective for flash mob organizations that want to be functional.

Before they can be designed or evolved, there needs to be a measure of how well a organization can accomplish a task, and a way to parameterize different characteristics of the organization. Then you can start exploring that parameter space to see which areas in this parameter space will be best at handling certain types of tasks at the system level.

UK firm to unveil wall-socket PC - ZDNet UK News

UK firm to unveil wall-socket PC - ZDNet UK News

The Jack PC would almost be considered by some to be embedded hardware, though it seems to be a fairly full fledged PC. Unused computation cycles will be more ubiqutous. Now, if only those cycles could be used for something...

A new medium for first adopters.

But back to the point: a long time ago I used to write online to a ton (like 30) of faceless, nameless people who used to laugh and possibly email me about how funny they thought it was. I was just goofing off, I wasn't too concerned about offending anyone if I could make something funny.
I think a lot of first adopters really rallied around blogs. It was like a second home to people. Everyone likes to have communities and places where everyone is respectful, interesting, and "where everyone knows your name." It was kinda like your own secret special place, and a twinge of 'coolness' because it was esoteric.

But inevitably, once a community gets so popular that there becomes an influx of newbies that have no respect for the painstaking community and culture for the medium that had built up over time. The general disrespectfulness of these newbies ends up chasing away the very people that made it special in the first place. Same thing happened on IRC and Usenet that happened in the blogosphere.
Vox is a return to that early time I don't think most people had a chance to experience. The commercialization of blogs has, I think, skewed people's perception of what they can be. To many, if you're not doing 50,000 unique visitors a day you should just throw in the towel, you're a failure. If your funny story about shopping at the Apple store can't be Digg'd or Boingboing'd then what good is it?
I wonder where the next playground of the first adopters will be? Somewhere where they can coalesce, create connections, and encourage each other to dream and to make. Likely, it will be through the introduction of a new media, as demonstrated by historical patterns.

First BBSes, then Usenet, and IRC. Then forums, and then blogs.

What will the new medium be like? I can imagine a couple things (though by no means accurate).

One might be the lowered barrier of making things, something like open source design. People with shared passion of making and creating things will be able to make connections and communicate with each other through making things.

Second might mix the internet and reality, where strangers gather for some cause, whether this cause is deliberate or emergent from the groups' decisions. These decisions might come from people that aren't even there, whose names they don't know.

I'm imagining something like people are able to view the positions of all those that are participating, on a map. Then they're able to vote and come to agree to where to gather, and what the goal is. Then those that are by the site get notified, and can spontaneously partcipate if they wish. Much like flashmobbing, but less deliberate.

Then, the ability for strangers to discuss or exchange what they did might build a community.

However, I can see how something like this could be used for evil, like sending a mob to various sections of streets in guise, where it is meant to block off roads to help a bank robbery or heist.

And yet, it's a neat idea. Emergent cooperation organized by the net that mixes with reality. It's another way for people to interact outside of their defined roles and places in society.

Monday, May 29, 2006

Evolving Design Patterns

I like the idea of cleaning up after yourself as you're coding. I find that I do that more and more, however, I get impatient if I spend most of my time, doing 'cleaning', rather than actual 'cooking'.

There's several tasks that I tend to be doing when I'm coding. Creating, designing, refactoring, debugging, and testing. I probably spend 70% of my time refactoring, debugging, and testing. But this is usually 10% of the fun. Where I find fun is in the creation, but I only get to do that 30% of the time.

Though I feel like refactoring, debugging, and testing (RDT) are necessary for good code, it's like cleaning your room...you have have to develop an OCD pride in having clean code to derive pleasure from it. However, you must always balance it with GETTING STUFF DONE.

It's hard to motivate yourself when nothing's actually being done for too long.

While testing has gotten easier and more automated with unit testing, and dare I say it...fun (to watch it say, you passed!), I feel like there isn't a good handbook yet on evolving design patterns.

Much of the time, I find the design patterns in the GoF book to be overkill. However, you do want to think about the future so you can extend it for flexibility later.

So the language that you're working in should allow the flexibility for you to sketch ideas, and then beef them up with ink later. The problem is, unlike drawing, you don't often know what's the best way to beef things up.

Certain types of solutions to problems have varying degrees of flexibility. For example, if I were to write a lexer/parser, I could just write a big loop line by line with a case statement inside it. But what if there are recursive elements? What about callbacks? There are more flexible architectures of lexers and parsers to handle that. However, no book I've ever seen delves into the topic of how to transform a bare bones lexer/parser into a full fledged lexer/parser.

Therefore, you can take the minimum level of complexity that you need, and be able to refactor it later if you need to.

Andrew Birkett's MethodFinder in Ruby

Found this via RedHanded, but he didn't explain it as well as the original page.

It is a method that lets you find the name of another method given its arguments. Pretty neat what you can do with Ruby.

Sunday, May 28, 2006

Beowulfs @ Home

Lately, I was wondering what to do with the four old computers that are sitting in my parent's basement. I looked online, only found one article from PC mag, and none of them seem very neat or enticing.

It was then that I went back to reading about beowulf clusters, but other than the experience of setting one up, I only have one problem I'd like to solve in parallel, which is the simulation of sexual selection on the genetic algorithm.

But yet, reading about cells yesterday, I'm wondering if it was possible to use parallel computers to take advantage of this dataflow programming paradigm. While I'm doing guesswork here with very little details, at the very least, it seems that one can assign a processor to a number of cells to update within a program. However, it might not be feasible, if the messaging system of cells has a lot of overhead.

This would be something neat to try.

Saturday, May 27, 2006

Rounded corners in CSS

Ahh, yes, the elusive rounded corners in CSS design. A number of people have come up with all sorts of hacks and solutions to rounding corners.

Presented is the 'sliding doors' method, where you segment the window into various divs and put an image in each for a more fluid layout.

However, I feel like ultimately, rendering this is the job of a CSS property and the browser. Isn't there a clipping property in CSS?
div#contents {
clip: rect(10px, 5px, 10px, 5px)
}


Now, I only know of shape being 'rect' in CSS2. Why can't there be other shapes, like, 'round_rect'?

Briefly looking through CSS3 spects on W3C, I didn't see anything at all. Does it make sense or no to implement this in the browser, instead of having CSS designers hack up designs?

PyCells and complex and emergent systems

Through this blog post on "BlueSky" about PyCells, I delved further into this seemingly new (to me) programming paradigm, called Cells, by Kenny Tilton.

It basically takes the concept of a cell in a spreadsheet that get updated automatically to programming where there are a lot of internal data states that are dependent on one another in a chain, or a complex graph of dependencies. Like, the color of a button depends on whether you selected a radio button or not. Or, shut down the motor if the sensor reads above 100 degrees (example given in text).

In only the brief one hour that I've been reading about it, it seems like you make declarative statements about WHAT is chained to what, and the cell system will be able to make deterministic and discrete updates to keeping data internals consistent, so that it eliminates race conditions and deadlocks.

A better explanation of it by a better informed Bill Clementson will help you understand it, in addition to this long explanation of cells by Phillip Eby. While it might sound academic, it's currently under the summer of code 2006 for google, under the python foundation. They're trying to make a port of it from Lisp's CLOS to Python. I wonder if anyone's doing it in Ruby?

However, even if it does really remove deadlocks and race conditions, I imagine other problems will crop up. It seems very analogous to cellular automata, except in this instance, the cells are heterogeneous, and there can be any number of neighbors. I expect that for even simple systems, you can get unintended and complex behavior from them, as most likely, they will be non-linear systems. How can we harness these unintended behaviors to design systems that are more than the sum of its parts? Of all the complex systems literature I've read, they've mostly been descriptive, rather than predictive. I'm not sure how to design emergent systems.