64 Bytes

just a few characters short of a code base.

Making a “zoom to image” double click with Seadragon AJAX. (Part 1-The Problem)

clock December 21, 2008 04:05 by author josh

   Recently Microsoft released its deep zoom technology implemented in JavaScript using Ajax.  Using the Deep Zoom Composer I made a quick composition with it to test it out.  Part of this was random curiosity and part was because I was actually looking for something like this to build a High Res photo album.

   While things are very intuitive as you could click to zoom in, use your scroll wheel to zoom in or out, pan with a mouse drag etc.. A feature that seemed very obvious (especially for photo albums) was some kind of “Zoom to fit” feature.   My thought was, if I double click on  specific picture in my gallery then I want to zoom that image to fit the screen..  Double click again should zoom me back out.

While this idea seems simple there are actually a few challenges that must be dealt with Like:

  • Event wiring isn’t obvious at first (thank you Aseem Kishore at MS for pointing me in the right direction)
  • Seadragon doesn’t know there are multiple images. All it does is manage zooming and scrolling on a large canvas. 
  • There are event collisions due to single clicks firing with double clicks.
Before we dive into all of the issues let’s take a look at what we want things to look like when we are done.. The below example will allow you to do all the normal Sea dragon things (single click zoom, scroll zoom, pan, full screen, etc) and  it will let you zoom to fit any photo by double clicking on it.. And you can Zoom back out by double clicking again.


Now that we know the problem and we see how the solution works let’s talk about how we got here. Basically there are 4 steps..
  1. Compose a deep zoom composition and export it to Seadragon Ajax & update the export to use the current Seadragon API.
  2. Override Seadragon’s Mouse events in JavaScript
  3. Map all of the images using Seadragon’s coordinate system
  4. Build a way to detect and manage double clicks.
So in the next post  I’ll take you thru getting all setup and having a sample composition ready and running locally in your own web browser.



www.delphiquery.com - Because everyone should write at least one "toy" app :-)

clock November 24, 2008 05:10 by author josh

I'm pleased to announce this "toy" app a friend and I wrote.. www.delphiquery.com. The app is pretty strait forward. A person asks a question and its voted on for a few minutes. The results are then emailed back to them once the poll closes (currently 5 ~ 10 minutes).  

The REAL reason we wrote this little app was to play with MVC and LINQ to SQL. I have to say the experience was very pleasent.. the Jquery ajax calls worked easy to build, and it was so VERY nice to actually know my client IDs inside my HTML . Also With a little bit of routing voodoo we got it to do some interesting things routing wise for having all of our controller actions ALSO available via JSON or XML as API calls.

I'll post more about the whole Actions as API techniques later. But for now.. Here it is, as silly as they come.. 



Open Vote Framework... Brain candy that might be worth building.

clock November 3, 2008 02:34 by author josh

So in this election year I have spent a lot of time thinking about voting and technology.. I see a lot of purpose built and closed systems outthere, and there are a few open systems.. But in my limited research I haven'tseen talk of but no action on a truly open source voting framework.. What I amtalking about is a series of services that would create a secure votingsystem.. Here are the design goals I am considering for this project.

  • Distributed & Self healing data model :  The actual votes should be stored in multiple locations with enough parity between each location that N number of locations can be compromised and the results from the vote still be trusted and valid.
  • Self recounts: This is something I did in a Voting system for an NPO many moons ago.. No user vote was ever associated with a specific user BUT all user votes were given an ID.. The User (Voter) was given the ID and could look up their vote any time.. In these cases when the voting base doesn't trust the results, they can still validate that their vote WAS recorded correctly.. This would allow grass root organizations to do "pseudo" recounts on their own using information they gather from voters about the accuracy of their vote and some statistical analysis.. if things seem TOO far out of whack then actual recounts can be executed.
  • Scoped Voting: This is something that has bugged me for a LONG time.. If I am a voter who lives in a state but I go to the wrong polling place my entire VOTE is provisional or void.. I would suggest that disenfranchising these voters we scope the vote.  After all National concerns like President and Senatorial elections are still valid for you. The rest of the ballet could be marked provisional.. The same could be true if you move from one part of a county to another.. Perhaps you can't vote in the congressional seat but you can on county bonds or state initiatives. By scoping the vote we allow voters a chance for their voice to be heard accurately and give them the dynamics they need.
  • Vote Anywhere: The goal here is to allow voters the opportunity to vote their specific ballot (based on their registration) regardless of their physical location or the polling station they actually vote at.. This could also extend to the web. This, specifically, isn't pie in the sky tech; Travis County Texas already did this using Hart Intercivics voting system at all of their early voting centers.
  • Hardware (and UI agnostic) : By this I mean that the application should be service based.. Private hardware providers should be allowed to build hardware or software that integrates with the voting service.  This is especially important when dealing with special needs voters. And of course this could allow for online or web based voting.
  • Deep but anonymous Logs and Auditing trails: By this we mean that actions should (for privacy) be anonymised from the specific user that executed them BUT there should be deep logging so that should a node in the service become invalid (see Distributed and Self Healing) that it can be analyzed to determine the true cause of the issue.
  • Voter Identity validation without ID: Using a series of questions & answers based on the user the identity of that use should be able to be validate to a level of certainty that is equal to or greater than that of forced State ID regulations.. This system could be used as a backup in locations where a person is missing their ID or for Online voting.

At thispoint its all just brain candy that I'm playing with. But I guess I have 4years to figure it out and get some of these ideas into code or architecture.  If your interested in these ideas or want to help let me know if there is enough backing I may start a formal project, otherwise I'll just tinker with it in my proverbial garage.

 

 



I still ♥ Ruby on Rails...

clock May 20, 2008 07:23 by author josh

Over the summer I finally dug into this whole "MVC" thing for web development. Naturally I began with the Mecca of them all Ruby on Rails.  This was a twofold learning experience for me..  First off it was Ruby a meta-language that bends like read in the wind.  And second was Rails, the darling framework that seems to have been sent by the demi-gods of software to help all suffering web developers.

But all of this joy was not without its flaws. Ruby is (as I mentioned before) all but un-deployable on a windows platform. After all Ruby is a single threaded/multi-process language (great for Unix where you don't actually have threads). But this limitation makes it an un-workable option on a windows box. Since then I have dug into Monorail, and now am neck deep in ASP.NET MVC. Heck I'm even a committer on the MVCContrib project. And while these projects are great they are still missing some magic. 

In short I still have stars in my eyes when I think of RoR.. This brings up the question, Why? (ya simple question).  I've been thinking about this a bit and I think (for me) the issue boils down to just a few issues.

First off is the RoR mantra "Convention over Configuration".  This mantra is actually quite deep; and while it can be a touch annoying at times (class naming can get silly) it's actually insanely smart. I have probably downloaded 15 different rails projects and had a working knowledge of the app and how to tweak each one in less than an hour. This is because the sites structure is described 1 way and 1 way only. More over I have been able to hand over projects in no time flat. In short, getting up to speed on a rails project is a no brainer.  ASP.NET MVC missed the mark on this in a big way in my book. MS, wisely from an OO perspective, laid everything out in a strong override-able and design. If you don't like routing, just implement a new router, don't like the view engine, just replace it. MVCContrib continued this with implantations of DI containers like Winsor, Structure Map, etc.. To muddy the situation further, MVCContrib implements multiple View Engines allowing developers to choose between ASPX, NHTML, NVolocity etc.. With all of that we diverge from Convention, and in doing so remove elegance for the privilege of flexibility (* Flexibility I am sure I will be thankful for when I migrate some of my Monorail apps to ASP.NET MVC over the summer).  Monorail is also bad about this (although not as much) with multiple view engines and a solid OO framework; but monorail has a community that has become kind of set in their ways. And so, while not set in stone, some conventions have settled in.  But going back to the rails mantra "Convention over Configuration"; nether ASP.NET MVC or Monorail prescribe to this philosophy more over they are the opposite "Here's a convention, but here are 108 tools to ignore it with " (I jest). 

    The second great feature of rails is the data model versioning and deployment methodology. You want a new data model, you add a new class to your data model describing the changes. Deploy the new version to your dev db, then code. Once your are done you run your deployment in test, evaluate your unit tests and push to prod; all very elegantly and with little effort. Linq for SQL has a great model but you design the app to the data (pulling your object structure from your tables) not the other way around.. So the same model change in Linq starts at the DB (with change scripts so you can manually run them in test and prod later) then re build your mode, code, test, run scripts in test, run unit tests, and deploy using your ant script that took 2 days to write. That's a lot of work and unfortunately Castle active record isn't much better.

    No don't get me wrong I really enjoy using Monorail and ASP.NET MVC has real promise. But when you take these three MVC frameworks and you look at developer efficiency and experience RoR is closest to my heart!



RoR now 2.0 (well 2.0.1).

clock December 13, 2007 02:53 by author Josh

Ruby on rails has now reached 2.0 (I guess late last week).. I guess its time to get my Ruby Dev VM up and running again and start the migration of PassVault to it. Info Here



System.Web.MVC + DLR + Linq = Rails killer?

clock October 11, 2007 16:33 by author josh

     Looks to me like Microsoft isn't taking the whole Rails movement lying down. First off they have IronRuby. But why stop there? I just read thru and watched the screencasts from the MVC demo at Alt.Net (click here to watch them, and yes you do want to read and watch them!) and I have to say I am quite impressed.

      It really does look like the boys at MS realized that RoR and Monorail and other MVC platforms brought a real value add for some (in my book many) web development scenarios and as such are moving to Microsoft the Web MVC development experience. Now add in the DLR (I do love what it can offer because I have become a big fan of Dynamic languages) and top it off with LINQ (or DLINQ) and you have a very compelling argument to develop your next RoR or Monorails app using all microsoft goodness.

   So the good and bad of it for me..

The good: Microsoft level of dependability, scaleability, performance, etc..

The bad: I want all my projects on one platform. I really don't want to mix and match my apps between MonoRail and System.Web.MVC and RoR! One MVC to rule them all Damnit!!!!! Its an in-determinit amount of time away (the Screencasts are of an internal experimental build).



Time to give Ruby another shot?

clock October 10, 2007 08:17 by author josh

The IIS team has finally released the new FastCGI module for IIS 6 and 7.. I won't know until I try to get it setup if it will work for me BUT (fingers crossed).. with any luck this will allow me to atleast have all of my work served out of one instance of IIS instead of IIS for my .NET work and Apache + Mongral Clusters for my Rails work.



Ktomics has a new site.

clock October 1, 2007 08:21 by author josh

In an effort to become more of a company and less of a "shop", we have developed and deployed a new site for Ktomics.. The new site also has our new logo and tag line :-).. Its pretty nice (if I do say so myself), so check it out :-).. www.ktomics.net.

(oh a techical note on the products. Gift Scanner is about 90% complete with eval/alpha versions in field testing. Gift Scanner is written with a .NET client and .NET/MonoRail on the server side. Given my problems with RoR for Windows I have made the transition to MonoRail for projects moving forward. Passvault is running on a cluster of Mongrals and is still a Ruby on Rails application).



Rails Acillies heal (for me)

clock August 20, 2007 09:33 by author josh

Ok so I have fallen in love with RoR as a development enviroment, its easy, elegent, and for compatent developers it can increase productivity astronomicly.. BUT it has a huge problem for Windows enviroments; it has no solid deployment stratagy for windows ( and no mongrel clusters behind apache don't count). Below are the methods I have tried any my opinion of their results.

1) Fast CGI on IIS using the old Fast CGI ISAPI filter: Slow (10, 12 connections per second) and I couldn't find an elegent way for it to run multiple sites.

2) Fast CGI on IIS using the new Microsoft Fast CGI tech preview 2: Faster BUT it couldn't handle default routes (routes to the root of a site) and it crashed when I had more than 1 app (first app would run fine, second one would keep crashing). Oh and did I mention it was a Tech Preview :-P

3) Fast CGI on Apache: I tried, 2.0, 2.2, FastCGI, fcgid, and about 2 million other combinations. I never got it work work! (I followed 3 diffrent tutorials about 10 times each, even mixing and matching steps where I thought one may have had a typo.) This may be because I am on Windows Server 2003 x64. But thats about the only reason I could find that thse just  "wouldn't work"

4) X Mongral Services running with apache as the balancer: This works great until you consider scale. It takes about 40megs per mongral instance (instance + ruby). and you need one Mongral per connection you want to handle (simaltanious, not per/second). So if I want to handle 200 connections/second and my Mongrals can each handle 10 per second, then I need 20 mongrals running. Now multiply that by 40 megs, and you are burning 800 megs of ram just on my app. This is not so go.

5) Linux VM running inside my windows box: One major downside. I can only connect to my SQL server via ODBC. Enough said.

So what are my options.

1) Ditch windows: Ya sorry, not going to happen.

2) Ditch Sql Server: See above answer.

3) Live with it and wait for iron ruby to support rails: I would if I thought iron ruby on rails was just around the corner, but its my bet its atleast 18 months out before its solid and production ready (remember iron ruby is only pre-alpha).

4) Do [X] (where X is the suggestion you place in the comments below): I am all ears.

5) Bite the bullet now (before there is TO much development to turn back) and port to Monorail or another MVC style framework that places nice with IIS and Windows: This is high on my list.

5) Give up on the clean goodness of a forced MVC framework and go back to traditional ASP.NET: This may also happen; but I am not a fan of this.

Suggestions are (of course) very welcome.



Dynamic Record proxy for RoR webservices.

clock June 11, 2007 22:49 by author josh
So I have taken the plunge and spent quite a bit of time playing with RoR (Ruby on Rails), in fact I decided to port my current projects serverside over to ruby to make the Ajax work easier and for the Experience. Along the way I had to write about 15 webservices to use for client server sync. Now if you don't know Ruby on Rails then the rest of this won't make much since so go of and learn a little rails and specifically ActionWebServices, then come back and you will think this is pretty cool :-) For the rest of you read on :-).

For security reasons Ruby on Rails doesn't support passing ActiveRecord objects to and from the client (not by default anyways). The fear is that someone will blindly pass in bad data, and the developer will just save it (without validation) therefore causing all kinds of issues. Now you can get around that by setting a parameter at the top of your ActionWebService::Base. But (at least for me) all that did was trade one problem (security) for another (exceptions being thrown because I don't use Integer ID's).  I thought about it a bit and I realized I would need ActiveWebService::Struct proxies for all of my objects. I looked at my 20 tables and realized that while that would be a pain , it wouldn't be "so" bad.. But hand writing a Struct for each of my objects, then one by one writing a "to" and "from" converter just didn't sound fun. Not to mention that it wasn' a long term solution. I mean what if the next project has 300 tables?

Deep in thought considering the problem I decided what I really needed to do was harness what it means to be a dynamic language. I wanted a module or base class, that would take a ActionWebService::Struct and a ActiveRecord, and dynamically do the translation for me.. Put a ActiveRecord in and get a specific ActionWebService::Struct out, put a Stuct in and get the "right" ActiveRecord back. To that end I wrote WsBase  
module WsBase 
@basedOnType = Class 
def map_from_class (type) 
   if (!type.base_class == (ActiveRecord::Base)) 
       raise(ActionWebServiceError, "ActiveRecord model classes is expected") 
   end 
   @basedOnType = type 
   type.columns.each do |prop| 
      member prop.name, prop.type 
   end 
end 
def fill_base(me) 
   mydata = me.dup 
   #raise @returnval.to_yaml 
   hashVal = Hash.new 
   @basedOnType.columns.each do |attrib| 
      hashVal[attrib.name] = mydata[attrib.name] 
   end 
   returnval = @basedOnType.find(:first, :conditions => ["id = ?", mydata["id"]]) 
   if (returnval == nil) 
      returnval = @basedOnType.new(hashVal) 
      returnval.id = mydata["id"] 
   else 
      hashVal.each do |field, val| 
       eval "returnval." + field + " = val" 
     end 
   end 
   return returnval 
end 
def fill_me(myRec,me) 
   myval = me.dup 
    myRec.attributes.each do |attrib,val| 
     eval "myval." + attrib + " = val" 
   end 
   myval.id = myRec.id 
   return myval 
end 
end 

The idea behind this module is that I create a 3 line proxy class that inherits from ActionWebService::Struct. I then extend it with this module and then add the line map_from_class ActiveRecordClassName.. Thats it. If I want to populate the Struct I pass in my ActiveRecord, If I want to get back my ActiveRecord, I pass in my populated Struct. The class files look something like this

class WsContact < ActionWebService::Struct 
   extend WsBase 
   map_from_class Contact 
end 

And a "read method" in my Webservice controller would look like this

def get_contact(contactId) 
   wcontact = WsContact.new 
   arcontact = Contact.find(:first, :conditions => ["id = ?",contactId]) 
   if (arcontact != nil) 
      returnval = WsContact.fill_me(arcontact, wcontact) 
     return returnval 
   end 
   return nil 
end 

and finally my write method would only need to be this

def save_contact(contact) 
   record = WsContact.fill_base(record) 
   if (record.save) 
      return "Good" 
    end 
   return "Bad" 
end

Now isn't that elegent. And best of all maintance for my model doesn't mean I have to update these classes, they automaticly change because they take on the properties of their ActiveRecord :-).. I even made the code cleaner by making the write function take a param of type, so instead of having 15 write methods I have 1 write method that gets called 15 diffrent ways.. and the write method doesn't change, again taking advantage of rubys dynamic nature, you can call static methods of a parameter :-P..

Anyways, this all qualified as TOO cool not to share in my book.. If anyone has any updates or suggestions on how to write this dynamic code I am all ears, I am a Ruby Neophite so I am sure my fill_base and fill_me functions could be optimized or follow do a better job of following Ruby best practices.




Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Add to Technorati Favorites

Sign in