by Thomas Beutel
...CONTEMPLATING CODE AND LIFE
...CONTEMPLATING CODE AND LIFE

Result of expression ‘document.forms[0].submit’ [[object HTMLInputElement]] is not a function.

September 15th, 2009 Posted in Programming, jQuery, javascript | Comments

I was trying to add a small delay into my form submission like so:

<form ... onsubmit="setTimeout('document.forms[0].submit()',2000);return false;">

but everytime I tried it, I got the following error:

Result of expression 'document.forms[0].submit' [[object HTMLInputElement]] is not a function.

This one had me stumped, until I realized what it was telling me… that my submit button was named “submit”.

<input type="submit" name="submit" id="Button1" />

I changed the name of the submit button and the problem went away.

<input type="submit" name="button1" id="Button1" />

Basically, Javascript provides a “convenience” by adding the names of the form inputs as children of the form. But this then clashes with preset function names, like the submit() function.

It’s like deviantART meets the App Store

September 11th, 2009 Posted in Apple Computer | Comments

mayhemJohn Fort over at the Big Tech Fortune blog writes about Tyrese Gibson’s Mayhem which is the first digital book for sale on iTunes 9. This strikes me as something that would interest the deviantART community of digital artists and writers. Imagine selling your artistic creations to millions of iTunes users for $0.99 a pop, just as iPhone app writers have been doing at the App Store. Good for artists. Good for Apple.

John mentions that the tools to create the e-book is based on standard web tech: HTML, CSS, and Javascript. My guess is that some day, not too long from now, we will see something like Pages (or maybe GarageBand) for iTunes where you can create your own digital creations and submit them to the iTunes store. It will probably dwarf the App Store in total volume.

Update: ReadWriteWeb has more to say about this.

iTunes 9: Option-click the green button to get the mini-player

September 11th, 2009 Posted in Apple Computer | Comments

The first thing I noticed when I upgraded to iTunes 9 was that clicking the minimize (green) button no longer selected the mini-player. A quick search revealed the answer: now you have to option-click the green button to get the mini-player. Thanks to Maclife for the answer.

miniplayer

RSSCloud: No need to adjust your firewall

September 8th, 2009 Posted in Blogging, Programming, rsscloud | Comments

I’ve been following the recent development of RSSCloud with interest… I think it has the potential to replace Twitter in the long term, although I suspect that Twitter might also evolve in the direction of RSSCloud.

One misconception about RSSCloud is the supposed need for the cloud to notify the desktop or mobile reader of an update. This would seem to mean that you would have to adjust your firewall to accept inbound connections to your computer/mobile device.

While the implementor’s guide shows that the cloud does notify the aggregator, the aggregator doesn’t have to be the same as the reader. As the guide suggests, the aggregator can also be in the cloud, with the reader opening an outbound connection to the aggregator, in the same way AIM or Skype or Jabber clients do, using protocols like XMPP. No need to adjust your firewall.

For that matter, Twitter clients do the same thing, using HTTP REST calls. The only difference is Twitter limits the number of API calls per hour (currently 150 requests per hour, or 2.5 requests per min–close enough to realtime for me), while there are no limits with XMPP. The tradeoff is arguably one of simplicity – is your client easier to implement with one or the other?

Hopefully the folks working on RSSCloud are developing an example of a cloud aggregator and an associated protocol. My vote would be for the protocol to be REST-based, but I could be convinced otherwise.

Using jQuery and Prototype together while avoiding the dreaded element.dispatchEvent error

August 28th, 2009 Posted in Google, Programming, jQuery | Comments

Here is what I do to avoid the dreaded “element.dispatchEvent is not a function” error. I load jQuery first, Prototype second, and then I use jQuery( ) instead of $( ) for all my jQuery calls.

 <!--  Set up jQuery and prototype together  -->
 <script src="http://www.google.com/jsapi"></script>
 <script>
 google.load("jquery", "1.3.2");
 google.load("prototype", "1.6.0.3");
 google.setOnLoadCallback(function() {
  jQuery('#helphide').hide();
  jQuery('#helpbutton').click( function(){
    jQuery('#helphide').toggle();
 });
 });
 </script>

Using Skype to control a model train

August 21st, 2009 Posted in Model Railroading, Programming, Skype | Comments

Small wireless spy cameras are widely available, and there are even a few available specifically for HO-scale trains.

This got me to thinking about letting my cousin in Germany run a train on my train layout, using Skype. Why not? Connecting the camera receiver to my laptop is easy and Skype allows you to select the camera source for video chats. For controlling the train, I can use the open source JMRI framework.

The only integration problem to solve is how to expose the throttle controls to my cousin. I could hack something together on a web page and have him work the controls there.

But is there a way to build this on top of Skype? After all, Skype supports instant messaging, so throttle commands could travel back and forth over IM. Skype offers an API, but I haven’t yet delved deeply enough to know what kind of applications I can build on top of Skype.

More soon.

A short blurb on using sfGuardPlugin credentials

August 20th, 2009 Posted in Symfony | Comments

(Here are a few notes I made to myself about the credential system.)

Credentials are part of the sfGuardPlugin security system for Symfony. For some reason, Symfony also refers to credentials as permissions. As far as I can tell, the two terms are used interchangeably.

sfGuardUser records are stored in the sf_guard_user table.

The tables in the sfGuard permission system are:

  • sf_guard_permission <- represents a permission (credential)
  • sf_guard_group <- represents a group.
  • sf_guard_group_permission <- associates permissions to groups
  • sf_guard_user_group <- associates users to groups

Typcially, users belong to one or more groups, and groups are associated to permissions. This is the preferred method, and the above 4 tables are all that is needed to associate permissions to users, via groups.

It is possible (but not usually advisable) to associate a user directly with a permission by using the following table:

  • sf_guard_user_permission <- associates users to permissions

Permissions

Permissions typically represent what a user can do, as opposed to representing a “type” of user. Examples of proper permissions are:

  • can_view_items
  • can_edit_items

The following are improper permissions because they represent user types:

  • paying_clients
  • non_paying_clients

Restricting actions via security.yml

For credentials to work, the user must be logged in. Since an application is divided into modules, it is conventional to divide modules into those that don’t require a logged-in user (i.e. fully public pages, such as main/aboutUs or main/termsAndConditions), and those modules that do require a logged-in user.

To require a login for a module, add the following into the module’s config/security.yml file:

 all:
   secure: on

For the most part, permissions are assigned to specific actions. For example:

 listItems:
   credential: can_view_items
 editItem:
   credential: can_edit_items

Using permissions within actions

 public function executeIndex( )
 {
   $user = $this->getUser();
   if($user->has_credential('can_view_items') )
   {
     // get the item list
     ...
   }
   ... and so forth
 }

Meta refresh in Symfony – use view.yml

August 19th, 2009 Posted in Symfony | Comments

The easiest way I’ve found to add meta refresh to a specific action in Symfony is to use the view.yml file. Note that I use http_metas, not regular metas.

indexSuccess:
  http_metas:
    refresh: 300

which results in adding the following, as you would expect:

<meta http-equiv="Refresh" content="300" />

U.P. 844 videos for April 20, 2009, Sacramento to Oakland

April 20th, 2009 Posted in Railroads | Comments

Newcastle Tunnel:
http://www.youtube.com/watch?v=4Z3Nd3CmJso

Yolo Causeway:
http://www.youtube.com/watch?v=W8LZDA5fUUw

Davis:
http://www.youtube.com/watch?v=KFcB4gPwLEg

Elmira Junction:
http://www.youtube.com/watch?v=SLiMwnFIgqY

Martinez:
http://www.youtube.com/watch?v=ysC4fZALNVg

Richmond:
http://www.youtube.com/watch?v=pXd71-Sr9pc

Emeryville:
http://www.youtube.com/watch?v=DFSD7cMUVm0

When Memes Collide – Apple is Expensive vs. Windows is Vulnerable

March 29th, 2009 Posted in Apple Computer, Windows | Comments

I always get a kick when the Apple is Expensive meme trotted out as a reason to consider less expensive alternatives. How ironic it is that on the very same day there is news of massive computer infiltration and document loss. The article doesn’t mention the operating system of the computers that were compromised, but I do have a guess.

memes-collide