json_encode error “missing ] after element list” with jquery json plugin

If you’re using the excellent jquery json plugin you might run into problems trying to parse json returned from the php function json_encode.

Specifically, when you try to parse the returned json using $.evalJSON you get the javascript error

missing ] after element list

I also had this same problem with the cakephp json component (which I decided to use instead since it would be more portable across php versions than the php5.2+ only json_encode).

The simple fix is this.
Add slashes to your output and surround it with double quotes like this …

$status = json_encode($status);
echo '"'.addslashes($status).'"';

I figured this one out, by examining rails json output that worked just fine with the jquery json plugin.

Add comment February 8th, 2009

Using the zebra widget with jquery Tablesorter (styling alternate table rows)

I ran into this problem trying to figure out how to make sure that styling alternate rows in a table did not become messed up when tablesorter actually sorted the table.

In googling around I figured out that you had to use the zebra widget call in your initial tablesorter contructor. But no one said exactly how to get the zebra widget to apply the alternate row styling.

The simple answer is (more…)

Add comment December 10th, 2008

Why Google is the best in the business … and you could be too

I was trying to find out how the NY Giants did last night, so I could incorporate it into a nice little jibe I was going to hurl at a friend of mine, so I went in and typed “NY Giants” … into the search box, to start the ever familiar process of clicking on links and backing up until I found what I wanted.

Guess what came up?

Its like they read my mind! :D

Funny, but it illustrates *exactly* why Google is kicking everybody’s ass at search. 

They write software that anticipates the needs of its users. 

You should be asking yourself if your software, business, employees or personal service does the same.

Add comment December 8th, 2008

New version (2.0.4) of Phusion passenger/mod rails out

New release announced

Global queuing

We recently announced that we’ve developed a feature called global queuing. This feature was requested by 37signals. When global queuing is on, Phusion Passenger will load balance all incoming requests into the first available backend process. This is especially useful if you have long-running requests, e.g. requests that perform heavy calculations and can take several seconds to finish. 

Fixed compatibility with the latest Rake version and RubyGems version

When compiling Phusion Passenger using the latest Rake, compilation commands are not shown while various warnings are being shown. This has been fixed. Various RubyGems deprecation warnings have also been fixed.

Running background programs from within the Rails app won’t freeze the request

In previous versions of Phusion Passenger, if one executes

system(”sleep 10 &”)

from within the Rails app, then Phusion Passenger won’t finish the request until 10 seconds have gone by. In other words, Phusion Passenger would wait until the background program has finished. This issue is caused by file descriptor leaks, and has been fixed.

Fixed Mac OS X crash

A Mac OS X related crash has been fixed.

Various bug fixes

The title says it all. If you experienced any kind of problems with previous releases, please try this release as the bug may have been fixed.

Add comment December 2nd, 2008

How to import/export your Netbeans settings to a new version

I’m a big fan of the Netbeans IDE, because I love the support it provides for Ruby on Rails.

It means that I upgrade my IDE to the latest release (Milestones, Betas etc)  as soon as it comes out, but it also means that with every upgrade, I have to physically go and set every … single … option … again.

Sounds painful doesn’t it?
It is.

Luckily , I found a blog post that describes how to solve this problem and import your netbeans settings from version to version.

This is something that needs to be fixed in Netbeans … that and including a word wrap option … and cakephp support … oops … getting carried away there :D

1 comment November 30th, 2008

How to search with Google Chrome using the omni bar

I’m writing this post because there doesn’t seem to be much instruction about how to search effectively from the url bar or omni-bar as the google folks call it.

The way its supposed to work is that if you type in a keyword for the search engine then the search query and hit enter, the search will execute using the search engine you specified.

so if you type 

“amazon.com Art of Rails” 
(note the space between amazon.com and the query)

into the omni bar then hit enter, your search will execute on Amazon.com.

To know that you’re doing it right, after typing in the keyword (amazon.com) and space, the url should look something like this

(more…)

Add comment September 11th, 2008

Google releases new Browser … its sexy

Yesterday I awoke to news about Google Chrome … EVERYWHERE.

And being the non-conformist I like to think I am (like everybody else in the universe), I wasn’t even going to give it a look until I stumbled onto this brilliant marketing tool that they had put together. Its a 40 page comic book walking you through the thought process behind why Google Chrome came about, and how it is different from everything on the market already.

What makes this puppy different?
The main philosophical difference between this browser and others is that fact that, instead of running the browser in one memory space, each tab in the browser has its own process.

(more…)

Add comment September 3rd, 2008

andlinux = Fail (rant)

Its admirable what they’re trying to do, but I installed the software and couldn’t get it to run. (Strange “could not connect” errors)

After screwing around with their rather unhelpful help thread and losing 2 hours of my life I gave up and uninstalled it. Don’t waste your time like I did, until they at least figure out how to make the darned thing work right out the box.

Thats probably why I hadn’t heard about them until a few days ago, and then, entirely by accident.

1 comment August 22nd, 2008

Use BREAD not CRUD

From Paul m. Jones

“I don’t recall where I first heard the term BREAD; it stands for “browse, read, edit, add, delete”. That covers more of what common web apps do, including the record listings. It even sounds nicer: “crud” is something icky, but “bread” is warm and fulfilling. That’s why I tend to use the term BREAD instead of CRUD …”

I like BREAD.
:)

Add comment August 20th, 2008

Ginormous external hard drive storage with drobo

Had to write a blog post on this …

Drobo allows you hotswap SATA hard drives in and out of it.
Just pop it open (yes … while its plugged in) and switch out hard drives as you wish. (more…)

Add comment August 20th, 2008

gem install error – ‘cl’ is not recognized as an internal or external command

If you’re here,  you are probably getting an error like this during a gem install on a windows box.

cl -c  -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAV
E_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX -
O1 -MD -Zi -DNDEBUG    -DVERSION=\”6.4\”  -DXS_VERSION=\”6.4\”  -IC:\Perl\lib\CO
RE  BitVector.c
‘cl’ is not recognized as an internal or external command,
operable program or batch file.
NMAKE :  U1077:
Stop.

The fix is easy if you have visual studio or the .NET SDK installed.

If you don’t then either go download Visual Studio Express or the .NET SDK (anyone out of 1.1, 2.0 or 3.5 should do)

Now, do a search on your local machine for ‘cl.exe’ (more…)

Add comment August 18th, 2008

Zed Shaw is a fan of Phusion Passenger (modrails)

Its old but I stumbled onto this just today. Zed Shaw (the creator of that ol’ faithful Ruby server mongrel) is a fan of the Apache Passenger (modrails) guys

I also met the Phusion Passenger guys and holy fucking crap are they on to something. If anyone is going to actually take on Mongrel in the hosting area it’s Passenger. The developers are super cool nice guys (unlike me) and even DHH likes their stuff. He really never liked anything I built, so hopefully those guys get more support. About the only thing keeping them from taking over is that they use forking so a few libraries that keep resources open will have serious problems. They’ll probably have to think up some kind of thing for that soon, but I think most Rails deployments could get pretty far with Passenger. (more…)

Add comment August 16th, 2008

New mod_rails/passenger memory tools and cool tutorial

I’ve been mucking around with passenger quite a bit these days. I’ve got two staging servers running it for two different projects and another running a production version of one of those projects.

In digging through the documentation I discovered two new command line tools that come included with the 2.0 version of Passenger.

From the documentation
passenger-status

One can inspect Phusion Passenger’s internal status with the tool passenger-status. This tool must typically be run as root. For example:

(more…)

Add comment August 15th, 2008

Quote of the day – nothing wrong with doing nothing

There is absolutely nothing wrong with doing nothing as long as it is done in moderation.

— From Freelance Switch
Become More Efficient By Simplifying Your Life

Add comment August 15th, 2008

Frameworks vs. Libraries in PHP (why I choose frameworks)

David Otton (who I’ve never met) has an interesting take on the old Framework vs. libraries debate, that I identify with.

I went through the same struggle (in my head) months ago. However, after having that internal struggle that David went through, I came out on the side of frameworks.

Why? (more…)

Add comment August 12th, 2008

Next Posts Previous Posts


Feeds

Calendar

July 2010
S M T W T F S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031