Craig Box's journeys, stories and notes...


Archive for May, 2007

Ways to get an upload progress bar in a Ruby on Rails application

Sunday, May 27th, 2007

Ready?

  • The "Sean Treadway method" Requires fcgid and Apache. Pretty much superseded by...
  • Mongrel's upload progress extension. Your upload form launches an AJAX updater that says "How far thru' the file am I, foo'?" every N seconds. However, because your upstream bandwidth is hosed (especially on 128Kbps DSL), it tends to take N+15 seconds to get a response. Can be notoriously hard to make go. (Hint, try sudo gem cleanup, and not running your code as root, or not being on a VPN to the server. Any combination of these might have helped.)
    • Mongrel tends to be run behind a load balancing proxy. These sometimes buffer requests so you end up sending 100% of the file before the server knows a file is coming. A solution appears to be to run another Mongrel instance on another port to accept uploads. This is a solution that lots of people suggest but no-one actually says "I do this, here's how".
    • Apache users might need to use mod_proxy_html to rewrite your links, if your JS doesn't have URLs generated with Rails' url_to helpers. This may or may not exist for Apache 2.2.
    • I have everything working up to this point, but the progress doesn't actually display for me using Apache 2.2 as my load balancer.
  • There is a Mongrel Upload Progress with Streaming extention, based on XUpload. The author sounds like he's been working on making it use JSON rather than Javascript, but there's not been a release since. May or may not work with Safari.
  • Use lighttpd and it's upload progress engine. I presume you'd just use it to proxy Mongrel. (Not really for me, as I'm somewhat tied to Apache on my SSL port.)
  • Merb, which seems to be Ruby off Rails. Again, it is used as a secondary server that just accepts uploads, but I have no idea how you'd run a merb and hand uploads to your Rails application. Comments to this welcome.
  • Shockwave Macromedia Adobe Flash, which does all the upload progress client-side. There's a nice degrades-to-Javascript engine called SWFUpload to try here.

Confused yet?

Greasemonkey helps the Internet get what it wants

Wednesday, May 23rd, 2007

Another great way that the Internet gets what it wants is with the Greasemonkey extension to Firefox. It lets you automatically add to the Javascript on pages of your choice.

I wrote a script to suffix "open new" onto RequestTracker searches, as version 3.6's quick search box seems to show you all the tickets, even the ones that have been resolved for three years. You will need to change the sites this applies to to match your own.

Today, a workmate asked for my Expert-Sex-Change login, to get around the ROT13 and blurring they now put on their answers if you're not signed up. (Cheatin' bastards want Google juice for it, be prepared to show it to everyone.) "I bet someone's written a Greasemonkey script for this", I exclaimed, and lo, they had. I reproduce it here with a nice little click-to-install as the author's WordPress eats the quotes.

By the way, if you do any web development at all (and I don't do very much - just tidying things up), install the Firebug extension. Right now. It's fantastic. We do everything through this. Everything.

ACT presents "Object reference: Not set to an instance of an object." when connecting via Citrix

Wednesday, May 23rd, 2007

The ACT! contact management application is a pig. There, I've said it. It's one of those programs that keeps changing owners - that's how much of a pig it is. Seems no-one really wants it.

They re-wrote it in .NET a couple of versions ago, and it ought to be better, but it isn't. ACT! throws "Object reference: Not set to an instance of an object." (a reasonably common .NET error) whenever it feels like it.

In my particular case, I could open it fine when using a Citrix desktop session, but as a published application, it would die all the time.

I tracked the problem to the seamless window. When you run seamlessly, you get Citrix's WFSHELL.EXE running, and not EXPLORER.EXE. You can force a published application to run at a certain screen size, which runs as if you were in a desktop. Hopefully the ACT! forums will give me a better answer.

Pimp my junk!

Tuesday, May 22nd, 2007

Note: this is all now sold. 

Compaq Proliant ML350 G3

Just because we don't need it any more, doesn't mean you don't!

The bottom three are servers we've used internally, and I'd be sad to see go if I was that kind of nerd. Especially the quirky one. Ever seen a 6GHz processor? That server has one, if you believe the BIOS. Or a 1.4GHz processor, if you believe the summary screen. Or a 3GHz processor, if you believe what it had when we bought it.

"The specified directory service attribute or value does not exist" connecting to Microsoft Exchange IMAP

Monday, May 21st, 2007

Are you getting "The specified directory service attribute or value does not exist." when connecting to Exchange IMAP? Wait a while. This error will go away - if you've just mail-enabled your account, Exchange will accept the username and password now, but it will take a few minutes for the mailbox to actually catch up.

Rid your life of sequential media

Sunday, May 20th, 2007

Got VHS tapes? Borrow a friend's DVD recorder and copy them to digital. Unless, of course, you borrow said DVD recorder, and find it dead.. then find it has magically come back to life a week later.

14 VHS tapes in the cupboard... net stuff worth saving: 10 minutes worth.

Interesting notes: programs I used to watch on TV before we got the DivX Channel: The Sopranos, Boston Public & Ed.

Here's the 7 minute piece that was worth keeping for posterity: an interview David Strassman did with Tim Finn.

[youtube]http://www.youtube.com/watch?v=UtS-PbcD8Dk[/youtube]

(Americans don't get quite as much Neil and Tim as we do down here, so they like when people like me put things like this online...)

Ruby "gem cleanup" returns "Unknown command cleanup"

Friday, May 18th, 2007
root@redhut:/usr/lib/ruby/gems/1.8# gem cleanup
ERROR:  While executing gem ... (RuntimeError)
    Unknown command cleanup

It's a bug in 0.9.3, and it will be fixed in an upcoming release.

Happy birthday

Wednesday, May 16th, 2007

Off The Record (ok, the name sucks) is 1 year old today.  Wow.

How did I find this out? Someone randomly suggested it might be Prof Eric's birthday today, and I mentioned it last year.  (On a different date however).  Pretty cool co-incidence though.

How did I confirm it? I was asked to enter my username and password to post this,  so I guess WordPress cookies have a 1 year lifetime.

Building NM-PPTP from source

Sunday, May 13th, 2007

I had to spend a lot of time today re-remembering how to take a CVS/SVN tree and make a distributable package of it. Here are my notes, for me next time, and for anyone interested, now.

sed -i -e "s/AC_INIT(NetworkManager-ppp_vpn, 0.7.0-beta, eemynotna@gmail.com, NetworkManager-ppp_vpn)/AC_INIT(NetworkManager-pptp, 0.6.5, eemynotna@gmail.com, NetworkManager-pptp)/" configure.in
sed -i -e "s/SUBDIRS = src auth-dialog auth-dialog-general properties po/SUBDIRS = src auth-dialog properties po/" Makefile.am
sed -i -e "s_auth-dialog-general/Makefile__" configure.in
ln -s /usr/include/pppd src/pppd
./autogen.sh --prefix=/usr --sysconfdir=/etc --localstatedir=/var
make dist

What's all that do, then?

  1. Downgrade the version number
  2. Remove the new auth-dialog-general, which isn't ready for primetime yet, from the Makefile
  3. (as above, but for the configure script)
  4. Link the system pppd dir - not actually packaged, but <tt>make dist</tt> fails if the PPP headers are missing
  5. Run the GNOME autogen script, which runs the autotools
  6. Builds a NetworkManager-pptp-0.6.5.tar.gz, with a configure script, ready for packaging.

It helps to remember things. Before re-reading the docs, and realising there was an autogen script, I was running all these commands (which of course required Perry to figure out, as I hate the autotools)

aclocal
autoheader
intltoolize --copy --force --automake
libtoolize --force
automake --copy --add-missing
autoconf
./configure --with-pppd=/usr/include/pppd
ln -s /usr/include/pppd src/pppd
make dist

New NetworkManager PPTP package (fixes AMD64 crashes)

Sunday, May 13th, 2007

(Updated updated update: historical information only; blog posts from 2007 are rarely relevant in 2011.)

I've built a new Ubuntu package of the PPTP plugin for NetworkManager, from a recent SVN checkout. It closes some bugs, and hopefully solves a number of other issues with the stability of the program.

Download links removed; if you're still running Edgy or Feisty, you should really upgrade.

I will rely on comments here to gauge the success of this version, and if it works well, I'll get it uploaded for Gutsy, and possibly push for an -updates release.

Thanks to Ed Schofield for pointing out I'd only linked to i386 packages, and compiling me an AMD64 package. He reports it clears up the segfault. Andrew Mitchell also contributed an AMD64 Edgy deb.

If you've come here from Launchpad, welcome, and please take the time to have a read around. I sometimes post about interesting stuff.