SOLUTION: gemcutter "gem migrate" gives "Too many authentication failures"

Gary McGhee - Thursday, December 03, 2009
When trying to migrate my gems from rubyforge to gemcutter I got the following error :
GarysMac:yore gary$ gem migrate yore
Starting migration of yore from RubyForge...
A migration token has been created.
Uploading the migration token to buzzware.rubyforge.org.
There was a problem uploading your token: disconnected: Too many authentication failures for buzzware (2)
Asking Gemcutter to verify the upload...
Gemcutter is still looking for your migration token.
GarysMac:yore gary$
I've seen this before with ssh on my Mac - it seems I have too many hosts set up in ~/.ssh/config, and unless it has a host setup that matches perfectly (or something) it gives up before trying all possibilities. I also seem to remember "IdentitiesOnly yes" to help in reducing the number of configurations tried.

Anyway, I debugged it by doing "rdebug gem migrate yore" and then "b migrate.rb:66" to debug the upload_token method.
When it got to the point of uploading the token, I used the token string it was going to upload, and by fiddling with ~/.ssh/config, eventually uploaded it myself. Then when I let the debugger continue, it succeeded. The following setting in ~/.ssh/config also succeeded with my other gems :
Host buzzware.rubyforge.org
        IdentitiesOnly yes
        User buzzware
        PreferredAuthentications password
Hooray!

SOLUTION: svn: Can't open file '.svn/text-base/somefile.ext.svn-base': No such file or directory

Gary McGhee - Tuesday, October 06, 2009

I was getting this error and it seemed my working copy was corrupt. A sure fire way to fix this, if you can afford to, is to remove or move the folder with the error and update to get a clean copy. But just now I had this with a folder of 300MB of images.

The following quick hack worked though :

  1. copy some other file like .svn/text-base/somefile.ext.svn-base in the same folder to .svn/text-base/somefile.ext.svn-base
  2. update to a version of the repo before somefile.ext existed (or maybe changed - not sure) like this "svn update -r XXX"
  3. update to the current version "svn update"

The above should get past the error by having a correct-looking file in the expected place. We then cause that file to be replaced with its correct content by causing svn to overwrite it

My core libraries on GitHub

Gary McGhee - Friday, September 18, 2009
I finally got my core libraries up on GitHub

Flex child components that don't interfere with mouse events

Gary McGhee - Tuesday, May 19, 2009

I have a bitmap that I want to act as a button, complete with the standard mouse hover cursor (hand).  I also have a label I want overlaid over the bitmap. 

Firstly, there are various posts out there about custom mouse cursors, but it surprisingly hard to find anything on the standard hand pointer that appears when the mouse is over a link. "buttonMode = true" is the answer to that one, but it doesn't work for everything.

Secondly, the label must be in front of the bitmap, but not interefere with the mouse. The answer to this was to make the label a child of the image, and then to set "imgCart.mouseChildren = false". This makes the label ignore mouse events, which fall through to its parent.

Some actionscript in creationComplete that makes the label a child of the image control, then centers its position within the image :

var lbl: Label = lblCartCount;
lbl.parent.removeChild(lbl)
imgCart.addChild(lbl);
lbl.x = (imgCart.width - lbl.width) / 2 - 5
lbl.y = (imgCart.height - lbl.height) / 2

Pure Actionscript HTML Parser (with thanks to John Resig)

Gary McGhee - Thursday, May 14, 2009
I am writing a Flex ecommerce store that needs to work with Mals Ecommerce. I am posting values to Mals to add to the cart, and the result is a HTML 4.0 page of the shopping cart, which I need to extract some information from. Parsing HTML would be much easier if it could be converted to XML for use with Flex's built in XML parser. At first I tried quoting unquoted attributes, but then found unclosed tags and it all seemed too hard, so I went looking for a HTML parser in ActionScript, with no success. Then i remembered that ActionScript is supposed to be a superset of Javascript, and the amount of serious code being written in Javascript these days continues to surprise me. This led to this Javascript HTML Parser whipped up by Javascript guru and JQuery creator John Resig.

With some quick hacking, here is my version.

"svn: No repository found" error with svn+ssh on the same host

Gary McGhee - Sunday, March 01, 2009

I had a strange problem where a SVN working copy was working fine on one machine, but after file copying it to the same machine that the svn server lives on, any server accesses would fail with "no repository found". The breakthrough came when I tried to ssh in as the svn user, which should connect directly to svnserve and give some gibberish back, but instead was logging in with a waiting shell prompt. 

Why was this happening from the same machine and not another machine ?

The problem turned out to be how sshd authenticates. Somehow it wasn't trying the correct key in the .ssh directory, and defaulting to a password login.

The solution was to specify which key to use on the client side when connecting as the svn user for the svn server.

eg. in ~/.ssh/config :

Host your-svn-server.com
    IdentityFile ~/.ssh/your-svn-key.ppk
    User svn

Don't underestimate Radiant CMS

Gary McGhee - Monday, January 19, 2009

I hereby confess that I underestimated Radiant CMS. I was looking at the website some years ago, and without digging in too far, concluded that it was a small project to create a CMS in Ruby on Rails, and hadn't really got a lot of traction. I'd be better off with one of the big name CMS's, probably one written in PHP I thought. Well now I'm freelancing and trying to consolidate my favoured technologies to increase re-use, reduce learning time and increase productivity. Choosing a CMS however hasn't been easy, there are so many out there its bewildering, and so many people seem disgruntled with them.

I know enough languages to pick up PHP if I have to, and I already know enough to modify existing code, but like most languages, or even more than most, it hurts my eyes after a few years with Ruby. Now from playing with Magento, I've decided the Zend Framework is where I'll focus when I have to do PHP, so I looked for a Zend based CMS, and the only serious contender seems to be http://www.digitalus.nl. It may well be good, but its in its early stages.

So the other night I stayed up trying to answer the question "Can I seriously use a Ruby-based CMS ie Radiant as my CMS of choice ?", and I came to the conclusion that yes, Radiant is something worth making that kind of investment in. The kicker was the slides from this presentation Pragmatic Content Management with Radiant from Sean Cribbs. It succinctly explains the pages, parts, snippets and layouts. In particular, the idea that a page should have more than one location to be filled by dynamic content is something I implemented in a Flex templating system I wrote. It seem so obvious, yet many systems apparently don't allow it.

Also the extension system, in typical Ruby style seems extremely powerful and useable even on jobs with a tight deadline. And of course, you have the full power of Ruby available as required.

Hello Magento

Gary McGhee - Thursday, December 04, 2008

Magento seems to be the rising star Open Source of shopping carts. I'm excited about it because :

  • Although it is PHP (I'm not a fan), it uses the Zend Framework, which at least has learnt from Rails. ie it has MVC
  • Zend and Adobe have been talking, and Zend now includes AMF support, which Flex can consume with greater speed (about 25%), less bandwidth than XML ( about 35%) and server load was reduced to 4% of the XML equivalent in this test. There is even an Open Source project Matsiya to integrate Flex and Magento.
  • It aims to be the main platform for up to very large sites. That means it will cope with all sorts of wacky promotional rules and product types
  • It has a nice looking UI that I would be proud to demonstrate to shop owner/operators, and I'm printing over 100 pages of nice looking user manual.
  • It aims to provide full API access to its functionality. This means easy integration with Flex, Rails and those scripts you sometimes have to write for some bizarre requirement, or even quite sensible requirements that the vendor has overlooked.
  • It has basic CMS ability, so for sites that consist of shop + simple static content (surely a large percentage of the market) it should be possible to develop a whole site in Magento.
  • I'm hoping I can treat it like a black box, not needing to get into the source code - just providing templates, CSS and Flex SWFs and Ruby scripts if necessary.

There is only one book for Magento (others are in the works they say) that is expensive and doesn't have good reviews, so I went to print out the User Guide, but it wasn't in PDF form, so I've converted it, with the Designers guide, thanks to OS Xs wonderful PDF manipulation features in Preview and you can get them here:

Magento User Guide 081205.pdf

Magento Designers Guide 081205.pdf

Closet JRubists article

Gary McGhee - Friday, November 28, 2008

This article The Closet JRubyists is exactly what I hoped to hear about JRuby, and I might even point to the future of Ruby and Rails. Consider what Sun now has to offer Rubyists, all for free :

  1. Solaris OS, with its builtin virtualisation
  2. GlassFish, their JVM
  3. MySQL, now their database
  4. JRuby, with its access to the universe of Java class libraries, performance now faster, more memory and database connection efficient than MRI
  5. NetBeans - highly underrated IDE with possibly the best Ruby support.
What more could we ask for ? Of course there are many other alternatives outside to most of these items, but its interesting to note this full stack offering from a company like Sun for the Ruby community, and when the whole stack comes from one vendor, they are more likely to take responsibility for integration issues.

Flash on the iPhone hypothetical solution

Gary McGhee - Sunday, November 09, 2008
It seems to me it would be possible to get Flash applications working on the iPhone now, without Adobe or Apple's cooperation.
Flash and Air apps are distributed as swf or air files containing bytecode for the Adobe Virtual Machine 2 (AVM2) (documented here) calling its APIs for graphics, window management, file system etc, and so the challenge is to execute that bytecode andimplement those libraries. iPhone apps are written in Objective C with some subset of the MacOS X libraries, and some new ones.
So my proposal is :
  1. write a translator from AVM2 bytecode to Objective C. This kind of thing has been done many times before. HotRuby takes Ruby bytecode output from the Ruby interpreter and translates to AVM2 to run a Ruby program on the Flash player.
  2. Implement the Flash and/or Air system calls (eg. play a sound, create a window, open a file) in Objective C and OS X libraries.
  3. Write a compiler to take a .air or .swf file and convert its code and assets into a form useable in Objective C/OS X.
  4. Output a fully native iPhone app, ready for upload to Apple. They don't even need to know it was written in Flash/Flex!
Issues :
  1. Apple wouldn't like it. You might even find your name blacklisted in the OS X EULA !
  2. Adobe might be OK with it. They get more Flex customers, and you become the bad guy (not them) in Apple's eyes.
If an investor wants to make this happen, I'm available !