By CATcash advance

So, you’ve got your clever and fresh Facebook app running on rails with facebooker, and for sure you’ve got your exceptions being reported to you by exception_notifiable, but what about the user? All they see are gnarly, clunky default Facebook error messages saying “the such and such application returned a 404 error code” .. yuck.

Well, it turns out the exception_notifiable renders your 404.html and 500.html files with the corresponding status codes.. which facebook then goes on to interpret as “this application couldn’t do anything, so I’d better say something” about this error. Which is not what you want.

So, a simple change or two gives you:

def render_404
  respond_to do |type|
    type.fbml { render :file => "#{RAILS_ROOT}/public/404.fbml", :status => "200" }
    type.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" }
    type.all  { render :nothing => true, :status => "404 Not Found" }
  end
end

def render_500
  respond_to do |type|
    type.fbml { render :file => "#{RAILS_ROOT}/public/500.fbml", :status => "200" }
    type.html { render :file => "#{RAILS_ROOT}/public/500.html", :status => "500 Error" }
    type.all  { render :nothing => true, :status => "500 Error" }
  end
end

Note the :status => “200” ... This way the contents of your 404.fbml/500.fbml error message will actually be displayed to the user. And, because you’re hooking into the type fbml, if your app has any non-Facebook facing sections they’ll be unaffected by the change. Yee haw!

Unix Poem

March 4th, 2008

>> ! * ' ' #
^ " ` $ $ -
! * = @ $ _
% * < > ~ # 4
& [ ] . . /
| { , , SYSTEM HALTED

The poem can only be appreciated by reading it aloud, to wit:

Waka waka bang splat tick tick hash,
Caret quote back-tick dollar dollar dash,
Bang splat equal at dollar under-score,
Percent splat waka waka tilde number four,
Ampersand bracket bracket dot dot slash,
Vertical-bar curly-bracket comma comma CRASH.

Sorry, Verizon

February 14th, 2008

Introducting new Verizon service with 8 times less bandwidth than marketing says:

Now part of a major internet campaign.

methinks they mean “megabits” per second..

Extreme (non-surgical) Makeover

February 12th, 2008

Enjoy longer load times

January 30th, 2008

seanoc321: oops. did someone hire some of the penis improvement ad people?

drdist0rt: it’s a short hop and a skip from “enjoy bigger loads” to “longer load times”...

ActivEdit 5 / IE Fix

May 11th, 2007

So this weird thing was happening with Internet Explorer and ActivEdit – the content wasn’t showing up in the editing area. I was able to correct this by keeping the ActivEdit form at the root level of the document body, but as soon as it was a child of any other element besides html, no go.

After jumping through some ridiculous hoops to install the Microsoft Script Debugger, I was able to find that the problem lay with the DOM object with id ae_tx_content1 – the textarea that contains the actual content.

Fortunately a Google search led me here: http://www.mail-archive.com/plum@mail.productivityenhancement.com/msg02323.html, and with this handy fix in place, everything is hunky-dory. Thanks tonyFelice!

undulations

April 23rd, 2007

fractal undulations

deeper and deeper

seahorse spiral

April 23rd, 2007

It sure is fun to write desktop apps again.

<!--- <input type=image src="images/glupek2.gif" border="0" >
YES, I WASN'T SMOKE ANY STUFF
<input type=image src="images/ganja.gif" border="0" >
NO, LeT mE SmOOkE LiTTle BIT mOOOOOre<br> --->

daily non-sequitir

April 11th, 2007

Obviously.

left by other people in code you’re maintaining:

<!---     ????????? FOR WHAT IS ThIS QUERY ????????    

ColdFusion strikes again

March 21st, 2007

In what must only be possible through the sins of backwards-compatibility, ColdFusion has what must be the most bizarre “trinary operator” of any language I’ve used.


IIf(condition, expr1, expr2)

<cfset a = 1>
<cfset b = 2>
<cfoutput>#IIf(a > b, a, b)#</cfoutput>
--> "2" 

That seems reasonable. What happens if 1 and 2 are strings?

<cfset a = '1'>
<cfset b = '2'>
<cfoutput>#IIf(a GT b, a, b)#</cfoutput>
--> "2" 

Also reasonable – ColdFusion is a weakly dynamically typed language, so 1 is ‘1’. What if the strings aren’t numbers, but text?

<cfset a = 'coolio'>
<cfset b = 'freshmonkey'>
<cfoutput>#IIf(a GT b, a, b)#</cfoutput>
--> Error: variable freshmonkey is undefined (!)

WTF Mate? Diving in a bit more deeply, this is because IIf doesn’t just return the value of expr1 or expr2, it evaluates them. So, of course, there is a solution: the even more bizarre function, DE();

<cfset a = 'coolio'>
<cfset b = 'freshmonkey'>
<cfoutput>#IIf(a GT b, DE(a), DE(b))#</cfoutput>
--> "freshmonkey" 

So how is DE() working it’s magic? Of course, I had to find out:

<cfoutput>#DE('freshmonkey')#</cfoutput>
--> "\"freshmonkey\"" 

Sorry about the escaping.. But yes, that’s right! All DE() does is wrap the expression in double-quotes. Sigh.

unhelpful error messages

February 7th, 2007

So, in ColdFusion, you can specify that you would like arguments to a method to be of a particular “type” – the word is used loosely here because ColdFusion doesn’t distinguish between different types of variables per se. For instance, a number, a string, and a boolean all are considered “Simple Values”, but I can’t query a variable to see if it is actually a string of text or an integer (useless!).

Well that’s all well and good, we like to enforce type checking where appropriate. So what happens, you wonder, when you do not pass the correct type to a method? The ultimately, incredibly, here’s a big fuck you… “The argument X passed to function Y is not of type Z”. That’s great, I mean really, kudos. But what would be really useful to me, as a programmer, trying to fix this problem? How about what type of object it actually is?

So one of the most obnoxious things about ColdFusion (in my experience) has been the drudgery of

<cfinclude template="../../../header.cfm">
etc etc. Really, not any fun at all. THEN, I get ColdFusion Web Application Construction Kit (CFWACK) by Ben Forta et. al, and I read about application.cfc. This has fun stuff like onRequestStart and onRequestEnd methods, which allow you to automagically include header and footer files. Great!

Well, it wasn’t so great, because including these files was more like a static server-side include. Scope wasn’t being shared between my header, footer, and page body. Cue silly googling of “coldfusion sucks” for a momentary bitchfest. Ok, that was fun, but SURELY there has to be some way around this, right?

Thankfully, the answer was not far from hand. Googling “coldfusion scope application.cfc” (no quotes) led me to this LiveDocs page:

Er, god dammit, LiveDocs just went down. My point, though, is this:

If you don’t have an onRequest method declared in your application.cfc, then onRequestStart and onRequestEnd will NOT share their variables scope with any included templates. So as long as you have an onRequest method like this:

    <cffunction name="onRequest">
        <cfargument name = "targetPage" type="String" required="true"/>

        <cfinclude template = "#Arguments.targetPage#">
    </cffunction>

Then, anything you set in variables will be shared, AS WELL as any any other templates you may have to include in your pages, such as UDF libraries, etc.

Anyway, I feel a little bit better about ColdFusion than I did when I woke up this morning.

Hardened-Steel Man Parts

February 2nd, 2007

Tog is hilarious:

iPhone is revolutionary, not a big surprise coming from Steve Jobs. He knows how to gather a tiny team of brilliant young minds and work them half to death until they innovate beyond any reasonable expectations. He has the common sense to know what will ultimately find favor. And he has the hardened-steel man parts to take a chance and roll with it. What’s a pity is that so few others in this industry share those triple strengths.