Ubiquity

What if I could tell Firefox to map what my Google calendar says I’m doing today, rasterize the image, and email it to my family.

What if it actually could understand me?

I’m so excited about this new Mozilla labs application that I’ve already created some commands for it.  They are an upgraded version of the check-calendar command (it replaces the default one), and a command to un-pack code from Dean Edwards’ packer.

You can get the commands by installing and going to my blog homepage.

VKitty-Part 3: Clothing and Collars

Sir Soybean with a red shirt

Ever since the start of , it has been the plan to make collars, litter boxes and food for VKitties, along with some less-house cat-ish , like armor, , and potions.  At the beginning of development, Kat made a list of that would be in the , and until now, it was just hypothetical.

I had programmed a way to add to the system, allowing data like Name, Price, Description, Type (, pet care, etc), and whether or not the item was for Premium users only (not yet implemented).  However, there was no way to use this system to make that do anything or are obtainable possible…

Until now.

With the new proposal for an item handling method, all that’s left is to make the item images and usage variables.

On the left, you can see my demonstration of what Sir Soybean would look like with a red shirt on.  This is only a preliminary , and it will probably be changed at some point.

Well, that’s all for today…  I’ll see you when the next development happens.

VKitty cats vectorized

’s architecture was wonderful, with all the security on the server side and the user interface on the client side.  There was only one big problem with the architecture: the cats were static images.

Now, I’ve redesigned the entire system, with the same cats still existing, but with better graphics, and more places to add on in the future.  Here’s a visual example: The images are scaled up to show more detail

Before

After

As you can clearly see, the before picture is very pixelated, not antialiased, and is not able to be changed by the server as easily.

On the after picture, it is not pixelated at all, it is antialiased, and best of all, it’s not actually an image—at least the real version here—it’s an , or vector, which means we can scale it up all we want, and it will still look good.

With the update to the cat graphics comes another addition to the options available: customizable patterns.  This means that not only can users select base colors for their cats, but they can also select colors for spots, stripes, or any other part of the cat’s body.

Unfortunately, with all good things, there are bad things, and with the new system, there are two downfalls.  The first is that the adoption system needs to be toally scrapped, the second is that I can no longer have a llama.

However, both of these problems can be fixed easily.  The first will be fixed with the new adoption system which will allow more customizability for each kitten adopted.  The second will be fixed by the new look of my VKitty.

Kat, the other team leader of VKitty, has posted a post about VKitty also.

If anyone who currently has a wants their kitten’s look changed, or doesn’t have one but wants one, you can still send me an email at nigh@.co.cc.

VKitty

An online friend of mine has tried to make a virtual cat several times and gave up each time.  But this time is different.  This time, she has the support of a programmer, and I won’t let her give up.

Sir Soybean... ?

The new is all ajaxified, so there is only one full pageload for each time you visit your virtual cat, and everything else is handled by XMLHttpRequests.  Being admin on does have its advantages, as I am allowed to do things nobody else can do—adopt a llama and have over nine million cat cash, for example.

There are currently five different adoptable cat types.  None of them require any food or play yet, because is not quite done.  But at a rate of one update or more per day, it’s getting closer and closer to being finished.

Already, stats refresh twice a minute directly from the server, dates update twice a second using the JSON-encoded responses the server gives, there’s a fully searchable memberlist, and much more.

Unfortunately, each adoption costs five thousand cat cash, and when you join , you are only supplied with 250.  If anyone needs help adopting, until the “free kitten for joining” offer is in place, I’ll be glad to help.  Just send me an email at nigh@.co.cc

If you have any suggestions for , you can suggest them here, and view the development here.

Without further ado, please join VKitty!

Unpacking /packer/

Ever since I started working on the mostly app “VKitty“, I’ve been looking into compression, and trying to figure out how it works.  Most compressors have very simple ways to compress , by simply removing whitespace, but Dean Edwards’s /packer/ defies the simplicity of most compressors by making an unreadable function that acts the same as the you feed it, also known as obfusication.

I’ve decided to find out how it works, and I’m starting with something very simple.  “alert(’STUFF GOES HERE’)“.

First, I packed it in /packer/.  I got back the code “eval(function(p,a,c,k,e,r){e=String;if(!”.replace(/^/,String)){while(c–)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return’\\w+’};c=1};while(c–)if(k[c])p=p.replace(new RegExp(’\\b’+e(c)+’\\b’,'g’),k[c]);return p}(’0(\’1 2 3\’)',4,4,’alert|STUFF|GOES|HERE’.split(’|'),0,{}))“, which is really unreadable.

Let’s unpack the /packer/.

I did a bit of formatting on the function returned by /packer/: (it’s an image because I couldn’t get syntax highlighting to work on my blog)

/packer/: Unpacked

/packer/: Unpacked (Click for a bigger view)

If you can’t already see what’s happening, I’ll walk you through it.  It basically creates a function, calls itself, and evaluates the result as .  Here it is, line by line:

Line 1: eval(
Evaluates the code that is created by the function.

Line 2: function (p, a, c, k, e, r) {
Starts the declaration of a function, via shameless plug.

Line 3: e=String;
Makes the variable e into a function that returns whatever it is given as a string.

Line 4: if (!”.replace(/^/, String)) {
This seems pointless to me, because evaluating the code inside the if statement would always return true.  I even removed the code, and it kept working!  The code is probably for compliance with less-up-to-date implementations.

Line 5: while(c–) r[c] = k[c] || c;
While the c variable is above zero, reducing c by 1 every time, the r variable (an empty object) gets a new variable inside it: one of the words contained in k, or ‘alert|STUFF|GOES|HERE’, split at the |’s.  If the variable doesn’t exist (which shouldn’t happen), it puts the key into the array so it will replace with itself.

Line 6: k = [function (e) {
The variable k is turned into an array with a function inside it.

Line 7: return r[e]
Return the xth word in r. (x is the variable e)

Line 8: }];
Closing the function-in-an-array statement.

Line 9: e = function () {
The variable e is now another function, not the String function, let’s see what it does:

Line 10: return ‘\\w+’
In regex, this means “find as many alphanumeric characters as possible”.

Line 11: };
Closing a function.

Line 12: c=1
We are no  longer looking for words 4 (in this case) times, but 1.  This is only possible because of the stuff inside the if statement.

Line 13: };
Ending an if statement.  Note the unnecessary semicolon.

Line 14: while (c–)
While the variable c is nonzero, reducing it by 1 after we test for nonzero-ness.

Line 15: if (k[c])
Make sure k has c as one of its keys.

Line 16: p = p.replace(new RegExp(’\\b’+e(c)+’\\b’,'g’), k[c]);
Replace the p variable with the k[c] variable instead of the c variable’s value.

Line 17: return p
Return the final value.

Line 18: } (’0(\’1 2 3\’)', 4, 4, ‘alert|STUFF|GOES|HERE’.split(’|'), 0, {})
Set the p, a, c, k, e, r variables.

Line 19: )
Close the eval statement.