What HP could have done with WebOS

HP this last week or so announced that it had made a terrible decision to discontinue producing the Touchpad or other WebOS devices.  It came as a real shock to those of us that have been hoping they would simply fix the problems that WebOS has so that we can come back.  I don’t know about everyone who’s tried the WebOS, but it has by far the most potential of any i’ve seen for mobile applications.

The Good about WebOS

There are a lot of really excellent parts of WebOS.  First, although on day one things can feel a little confusing (the swipe isn’t natural, how to use the cards aren’t obvious, etc) after about 1 or 2 days of real use it starts to become not only natural, but something to be desired.  I moved to my ipod touch from my Palm Pre and keep trying to swipe to switch apps, and getting frustrated because such an awesome feature didn’t exist.  Opening the keyboard and just typing, again is wonderful.  Just type is indeed that, you simply open, type, and you have what you want.  It’s good, it’s very good.  Also, patches.  My biggest frustration with Apples iOS is that it seems to be written to be perfect for exactly 1 person - Steve Jobs.  Lots of fanboys decide that they also like turtle necks, but I don’t, I hate them.  iOS doesn’t work exactly like i’d like it to, but there’s little that can be done without jailbreaking it (which as far as I know doesn’t work on my ipad 2 yet).  WebOS on the other hand embraced the idea of patching the OS.  I can make the battery in the corner work the way I want instead (show as a %), I can make the vibration last exactly the amount of time that I want.  I can remove that stupid NFL app like I have any interest in that sort of thing.  Not by downloading some app, but by changing the OS code to run the way I want.  Very Excellent (though not fully condoned by Palm as far as I know).

The Bad

So with so much going for it, why am I now on android?  There are really 2 main reasons.  The first reason: The battery is absolutely ridiculous.  This is actually the reason I don’t use my Palm Pre any more.  If I completely charge my phone, and don’t use it all day, it’s dead by the next morning.  That’s ridiculous.  If i try and use it during a 3 hour meeting for notes, surfing, etc (not even 100% of the time) it’s dead by the end.  That’s completely unacceptable.  If nothing else is fixed, the battery life simply has to be fixed for WebOS will never make it out of HP’s doors with any form of following.  The second reason: Things are simply too slow to load.  When I tried to show people how cool my phone was, I’d try and open any app, and it sits and blinks for 5-10 seconds while it load.  This is, I imagine, because of the reliance on html and javascript, except webpages don’t take that long.  In web development we learn that if a page takes longer than 500ms to load, it’s not good yet, if it’s more than 2 seconds you just lost a customer.  So why does loading a small website, say a contacts app, take so long?  I can only guess it’s due to poor framework development on Palm’s part.  The framework obviously tries to do too much before the app loads, and this is killing them.  Also, 1 other problem, if you get people to go to a provider (Sprint), don’t switch on them when you come up with a cooler option.  I wanted the Pre 2 because I had hoped you’d fixed things (I later learn the battery was worse, you’re just screwing yourselves) but no, i’m on sprint now and you made some weird contract with Verizon.  Honestly?  It’s like you faked us all out on purpose.  I can just see someone laughing in their office; haha we totally tricked you into going with Sprint (which, btw, is still my favorite provider with their any mobile to mobile minutes, awesome :)) suckers.

The Potential

Assuming that Palm fixes the Load times and most importantly the Battery life, there are still a few things they could do to revive their dying child.

  • Embrace patches.  Get a developer to look over the patch and make sure it’s good, and release it on your own website.  Offer tons of them, that do anything I could want.  Let me install them from the app store, and remember my decisions during an update.  Patches are your friend :) love them, protect them, make them available.  They let me use my phone the way I want, not the way you thought I wanted (or worse the way that your CEO wanted).
  • Offer the touchstone as part of the original phone.  I was disappointed when I heard there was this awesome piece of technology that you guys created, but that was an extra $50 right on top.  Almost as disappointed as I was with the HTC Flyer (which is an entire rant in itself, and has caused me to believe that HTC couldn’t care less about their customers, terrible move).  It’s like selling a car without the tires, or a kids toy batteries sold separately, or a cool phone without an awesome charger (except you taunt us with the possibilities).  It was too much money to spend to simply get the ability to set my phone on a magnet and let it charge.  Honestly $50 did someone eat lead paint chips as a kid?  But the touchstone is awesome, everyone with a Pre (or whatever) should have one that comes with their phone.  Extras can then be $30 if need be, but the original one should come in the packaging.  Then your phone has something none other does, true convenience.
  • Reprogram all the main apps directly in C instead of in JS.  Better yet, work on the framework so that it loads programs faster and cleaner.  The apps shouldn’t be very large, and they should be very fast.  But in the end, the built in main apps should be sooooo fast that I can blame the other developers when their apps aren’t as quick.  As is, of course other apps aren’t fast, the contacts app is slow.  How can I expect some other company to write in your framework if you can’t?  And, how can I expect to be able to develop something someone will truly like if no matter what I do it’s going to be terribly slow?  That’s not a good feeling for your developers.
  • Did I mention fix the battery life?  It really is totally unacceptable
Will HP/Palm hear my rants?  Almost assuredly not (if you know someone from HP please :) feel free to forward it on), but if they somehow do, don’t just by pass them as Ramblings of a Crazy Programmer, hear them as a genuine request from a customer that longs to come back.

What I hope the HP Hurricane comes with

To start with, i’m semi impressed with the IPAD.  The speed and fluidity (if that’s a word) of the OS is very nice, and makes me feel like i can pick it up and use it any time quickly.    There are a lot of apps, and more to come (though most of them right now seem a little rushed).  But this article is about a piece of technology i’m more excited about, the HP Hurricane (or whatever they choose to call it).

As a Palm Pre owner, there are several things that I really hope the HP Hurricane comes out with.  First, and very very foremost a PEN.  But please not a stylus, i want the pen for writing hand notes, I want a planner software that let’s me write down my notes by hand (it helps me remember better).  It needs to intelligently know if it’s the side of my hand or my finger so that I can write with one hand and move the canvas around with the other (stuff like that).

Cameras (front and rear would be cool).  At first i thought that i’d never in a million years use one :) and though i’d probably never use a front facing one i’m sure others would.  But a rear one, for me, would be awesome to be able to take pictures of whiteboard drawings.  Cooler than that would be the ability to pop the photos into a drawing app.   Allowing me to add tags and what not in my notes.

Did I mention a pen? Oh ya :) i did.

inputs - a non proprietary power plug, usb for jump drives, and sd cards.  The #1 thing I hate about Apples products is their complete and utter desire to keep everything inside their own little world.  Only use plugs we make, only use itunes to put things on our device, etc.  I like the fact that they do everything in their power to make things as good as possible, but don’t force it.  Make people use ur stuff because it’s the best alternative not the only.  And let people use their device in a way that fits them the best (did I mention i like writing with a pen :)).

Google docs :).  I want the ability to sync my google docs on my device for complete offline view.  And then, regularly sync if i’m looking at them while i’m in range of wifi (or 3g if i go with that model).

Please build the pen into the hardware :), in a way that looks nice.

Keep the battery life up above the 6 hour range, and build all the “built in” applications in C (using your cool framework).  That’s my #1 gripe with my palm pre is that the applications are really slow to launch, and sometimes are laggy.  Make everything fast.  You have a way more powerful CPU, use it :).

Build an onscreen keyboard that is as good as the Ipads.  Although the pen is good for some things, keyboards are the best for IMing and document creation.   (Please include it in the phone OS if you do in the hurricane).

That’s all.  These things, together with a nice app store will make me switch from my ipad to a webos tablet as soon as my ipad sells on craigslist.  Just know, that if you don’t include the pen :) i for sure won’t buy one.  You can’t possibly hope to be better than the Ipad unless you include the things that it refuses to include.  In my opinion above all else they dropped the ball with the incorrect assumption that if we see a pen then you’ve failed, it may be Steve Job’s opinion :) but he’s wrong.  If you do nothing else that I’ve said here, but do include a pen, i’ll be a little disappointed .. and I’ll still sell my ipad on craigslist to buy a hurricane.  Everything else would be cool too though :) not that you’re listening.

Dear IPAD - don’t take out the pen

Everyone has been checking out the brand new IPAD.  Granted, I don’t own one, and there’s 1 main reason.  Why of why did you make a pad without a pen?  I’ll tell you why, because “everything should be finger based”.  That’s true, almost.

Before you stop reading, I don’t mean a stylus, I mean a pen.  This wouldn’t be used for moving around the page, it’s not a stylus.  You can’t click on icons with it, you can’t flip pages with it.  You can’t click pause, fast foward, or even stop.  I repeat - IT’S NOT A STYLUS.  So what can you do with it?  WRITE.  It’s a PAD, meaning a replacement for things like paper.

My “dream”.  I pull out my ipad and am reading a book about SQL, and see something I really like, I slide the pen out and touch stops working (while using the pen), I write notes on what I like about it, and slide the pen back in and keep reading.  Or i’m in class, following the instructor, and the instructor mentions that the author wasn’t fully right in this part, but instead take note that such and such should be such and such.  I pull out my pen, take the note, and slide it back.  Everywhere where I’d want to write on the tablet would use the pen.  It could be precise (even pressure sensitive).  I should also be able to hook it to my computer and turn on a tablet application which turns it into a pen tablet / monitor for my computer.

The pen should not however be designed into the applications for any reason other than writing.  It’s ink, not a mouse pointer.  It’s not used for precision, instead it’s used for writing and drawing.  Every application should be designed so that the interface uses touch to control, and a pen to write if that makes sense.  Children draw with their fingers (and sometimes I do when my daughter wants to paint with me), adults draw with pens, pencils, brushes, etc.  Such a simple addon could have completed the ipad, but alas, they overlooked it.

Someday I may buy one, but to me $500 is too steep for a book reader and a movie player.  But add a study guide and a graphics tablet, now that’s different :).

How to fix the internet - Lesson 1 :)

The internet is an awesome place.  For me it was like opening the chocolate factory.  After some use though, i saw that it was full of crap :(.  I created my first website and proudly displayed my email so that people could tell me how cool it was.  I created a wiki with cool ideas and allowed everything to add to my ideas so that the ideas could improve and grow.  I did research and found solutions….. and a lot of crap I didn’t want to find.  Then some jerk kept posting on my wiki that had nothing to do with my wiki, he was advertising for his site on my wiki … the nerve.  So this article will go over several problems with the internet and my way of fixing them :).


I’ve recently found out just how annoying spam is.  It’s nearly impossible for a legitamate company to create an email server and get email working, because there are morons (that’s the best clean word I can think of) out there that send out lies and worthlessness in the promises of cash and glory (and larger body parts).  And it’s more annoying if you get the spam.   Companies like Google spend good money cleaning up all the crap.

SOLUTION 1 - Make spamming illegal

If I knew that when I got a spam email I could send it to the police and they would investigate it, contact the company responsible, send them a fine, and eventually put the owner in prison if they continued to break the law, then spam would stop.  If the spam came from another country, there’s a solution for that too (see the problem entitled Pornography)

PROBLEM 2 - http://www.gooogle.net/

Did you know that people make a living buying sites that are very close to the site that you wanted to type in?  Buying something like gooogle.net instead of google.com, or anazon.com (though amazon is cool, they own this one) instead of amazon.com.  They make a living off of lies, it’s not only lame, but very dishonest.  The problem with these sites is that they add no value to the internet.  They’re simply there to try and get you to click links that lead to google searches (which can end up just being large loops of frustration).

SOLUTION 2 - prove it or lose it

If google.com notices that gooogle.net is there simply to fill in a mistype, they should be able to go to register.com or some small government division and file a complaint.  This company should allow google to pay the $15 or whatever dollars for the site assuming the company responsible doesn’t come up with a valid honest use of the site in 15 days.  Or, they should be able to give a cease and desist letter that gives them the same 15 days before their registration becomes invalid (with them loosing whatever money it cost them to buy the site in the first place).  Users should also be able to file these complaints with the same results.


I think this one is evident.  Viruses and Spyware should be more heavily tracked down and should have more severe punishments.


If a dumb kid writes a virus in his basement and it gets out, then they should estimate that it cost x Billion $s and the kid should be sued for X billion $.  In the case that the kid can’t afford x billion $s :) then a short prison/juvy sentence should be served, and community service to the government should be served for possibly years of service.  This is a little kinder then the death penalty that I feel they should get :).  It wouldn’t take too many public cases of kids loosing everything they have, or adults serving bad prison sentences for this to end.  In the case that the virus comes from a different company, see below.

PROBLEM 4 - Pornography

Let’s face it, it’s everywhere on the internet.  Stupid ads from Evony, websites that pretend to give you valid information but actually end up having endless popups, viruses that constantly open crap on your desktop all day.  It’s everywhere, and it’s disgusting.  It ruins people, their jobs, their marriages, their friendships, and it’s getting worse.  It’s worse that it’s nearly impossible to block with a firewall, and it forces firewalls to be much more strict.


The real problem with pornography is that yes, it’s gross, degrating, and destructive, but it’s legal.  So you can’t make it illegal to offer it.  Instead, you enforce that every single pornographic image must come from a .xxx (as opposed to .com) extension.  If you want to enable it over P2P software, then it has to be flagged as such, and should probably go over a special port.  This makes it easy to block, but for those who want to wollow in it they still can.  The real difficulty however is in enforcing this.  There are a few ways to enforce this, and really it should be decided by a judge or someone similar.  Options: 1) If it’s a single person, give them a hefty fine, disable their website, short prison sentence, and look into their ISP; 2) With any site you must also target the ISP, it is their responsibility to not host pornographic material illegally, as such they must federate their sites, in the case that an ISP is a problem, disable them for 24 hours per incident beyond the first (so 24 for the 2nd, 48 for the 3rd, etc).  This becomes very detrimental to ISP’s who would lose a lot of business (if not all); Option 3) If it’s outside the states, then you have an agreement with other countries.  The agreement is: either you federate your sites, as you give us sites to fix or we give you sites to fix they get fixed quickly, or we block off all internet communication between your country and ours (like from every country that is in the agreement).  Generally countries will agree, it would suck to be without the major countries as far as internet access goes, and you lose a lot of profit in your endeavors without the major countries.  This enforcement should work with all the problems with the internet.  If a country is harboring “fugatives” so to speak, then that’s fine, but we don’t want anything to do with your internet traffic.  No emails, no anything to and from that country (except maybe some emails back and forth about fixing the problem.  This would be a very effective solution.

Anyway, there are a lot of problems with the internet, which is frustrating, because it’s so valuable to the way we live our lives.  So much shared information, tainted by dishonest and dirty people.  I hope that someday it will get cleaned up in some way.

Designers think “outside the div” why doesn’t CSS?

Somewhere someone decided that using tables for layout was bad.  Everyone who was doing it got slapped on the wrist, and everyone who agreed with the notion removed all tables and added div with CSS instead.  The result was html files that were clean, and a lot of really ugly websites.  You have 2 options.

Option 1 - use tables, where everything is a big grid, and you lay it out in the HTML the way you want it to look.  This option is very nice in the sense that no matter what people do your text doesn’t overlap.  No ugly websites, instead you get ugly html

Option 2 - use divs that are placed via CSS.  Boom - beautiful html, but unless you’re good at CSS it looks terrible in one of the 3 major browsers.  The problem, of course, is microsoft and their inability to program things to standards, but this problem exists and there’s nothing that web developers can do about that but work around it.

Option 2 has definately won the war, but still major companies like google choose to use tables (in programs like gmail) because “they just work”.  Of course they use divs and tables in a joint way, which seems to be “the best way” because of these issues.

My complaint: If you’ve ever worked with a designer before to build your websites, designers don’t know how to think inside the box.  They always want to design things that look nice, not things that are necessarily easy to program.  They want borders around divs that are made out of images, the border width = 2 thing just isn’t good enough.  They want rounded corners, or torn corners.  They want this image to be placed a little outside of the div, and they want this button to be gradient in just the right way.  They want scrollbars that look like the rest of their design.  They are soo picky.  And CSS, which should be tailored to fit their picky ways, doesn’t work like a designer.

CSS wants you to either place things in a flow or absolute.  I could (and most likely am) be wrong, but to me it’s difficult to get one div to just plain overlap another div.  It’s hard to make an image that becomes a border of a certain class of divs.  And it’s just plain impossible to overwrite the default scrollbar “because who would want to anyway” (ME!!! or at least my designer :)) unless you plan on using javascript, and even then the libraries are outdated.  CSS is almost powerful, so almost powerful that it hurts to use it.  It almost has the ability to position things the way I want.  It just needs a redesign.

That’s my rant :)

What if CSS added (feel free to comment on what you’d like to see it add):

border-image(url(../images/tornborder.png) 13px 8px 120px 270px) - the syntax obviously is made by me, but the idea is that tornborder.png is a sprite that can be cut up to corners and sides using the px as the grid to split it up (my thoughts are that the top is the top 13px, the top left corner is from 0 to 8 px in and 0 to 13 px down, the left is from 0 to 8px in, the bottom left is from 0 to 8 and from 120 to height, etc.




scrollbar-arrows(url(../images/scrollbararrows.png) 5px (basically a 10px by 10px picture that is a grid of 4 5px arrows)

stack: true - makes everything inside this element “stack”

align: center - who was the moron that forgot to add this?  gaahhh.  And if someone purposely left this out, then who’s up for a good old tar and feathering? margin-auto is a cop out, doesn’t always work, and isn’t align: center :).  Align: left .. align: right … margin-left: auto margin-right: auto, which one of these aint like the other?

The Future of Touchscreen Computing

The other day I was looking around for some touchscreen ideas for a project I want to do and came across this: http://www.youtube.com/watch?v=UcKqyn-gUbY&feature=related (if you can’t view it, just do a search for TED multitouch desk).  Wow was I amazed, how cool.  After the this is awesome effect wore off I got to thinking.  How would someone really use this?  I mean it’s cool to zoom around google earth, and to play with fake wax, but how do you bring this to real world use?  So I decided to think about it, actually my mind decided that I would think about it as much as possible  even though I didn’t want to :) as it often likes too.

A warning to the reader.  I’m still thinking about this idea, it’s a work in progress.  Assuming my mind doesn’t move on to something else expect this article to change :).  And, if you make comments, i’ll look them over, if they change my mindset i’ll change the article accordingly and give you credit :).  If you build this solution I’ll link to you (As many times as you want :)) and be your friend :), assuming you let me critique your implementation (I’ve very picky).

Let’s jump in, starting with the basic interface.  We no longer have “windows” per say, but we have application workspaces.  This enables you to specify how much space a given application has to work with.  It appears as a wireframe outline with an X in one corner, and a small Nickel Sized circle in the other corner (the minimize button).  Hitting the minimize just pulls the wireframe and everything into the circle, which can then be left there, moved, or flicked into a minimized apps area.  Everything zooms, rotates, and drags around as expected.  You can flick things over to the edges of the screen, etc.  Applications then can deside if they want to take up the full area of their application or be mostly transparent and allow you to have cards, or whatever inside their application.

Alternative desktop feel more like current.  You have 1 giant wireframe, each window has small inner cards/shapes/whatever so if you have a todo app open that uses cards for each todo item, they are just sitting on your desktop, if you then open a website it’s just another thing on your desktop possibly stacked above or below other cards.  Each application has a small circle at the bottom of the screen to minimize it to the coin, or you can throw the window off the screen to close it (or flick it in that direction).  In this way different applications can interact with one another.  (Some thought needs to go into how to minimze/bring to front/close).

Keyboards become a combination of keyboard and cursor.  You do a gesture and a keyboard opens with a small dime sized circle above it where the cursor is.  If you drag the cursor, or keyboard to put the cursor into a place that can have input, then you can type.  This allows for multiple people to work on the same interface with their own keyboard working on the same or different documents.  Clicking on a place to type then without dragging a cursor would just open a quick keyboard there for typing.

With the idea, Full screen would be very rare.  Some items, such as websites might be, and movies generally would be, but most applications wouldn’t need it.  They have their optimal size (which is decided first by the programmer but then by the user) and reopen at this size after closing.  But applications should be designed to work within an area defined by the user completely changeable by the user as windows are now.

Menu’s become circular, so you click on an option and sub options fan out from there as needed.

You should be able to define your own Gestures, per App or global to do certain actions.  Each application should know this and provide as many “hooks” as possible to make this easier to do.

Just as the keyboard can be “brought back” a mouse can also be gestured in.  This would provide a touchpad like area for playing games in which moving the mouse around provides for an easier interface.  Programs would be able to define what their keyboard and mouse feel like and look like (games could have a set of buttons layed out the way that are best for them).

It should also be possible to have a plastic pen (not really a stylus because some people think that stylus’s are evil) that allows you to do sketching, writing, image manipulation etc.  Even these applications though should use the pen only in places where it makes more sense then a finger.  This should be as pressure sensative as possible, and should be setup to ignore the rest of that hand while drawing (so that u can still rest ur hand on the “paper”).  The other hand, should still be free to make selections, resize things, etc.  The trick is to use the interface that is the most natural.

Example Applications:

Reminder Cards - Basically a bunch of cards that you can write on and give different attributes to.  Such as remind me every monday to do the laundry, or every January remind me to do my taxes :), then, you open the program each morning and see the cards that you have to work on.  They just sit on your desk and can be skattered, gathered, or whatever.  Special cards can be put in different spots to remind you.

Shopping Lists - allow you to look through foods and drag them into ur shopping list, then when you’re ready, view ur list and print it out.

Browser - No more tabs, instead the browser is just a set of windows in the same applications, with different gestures to bring one to the front or not, tile 2 or more of them next to eachother, etc. Zoom ability and everything to change the size of pages for easier links etc.  Browsers would be heavily gesture based, but obviously everything would have to be menuable as well so that it can all be done without knowing the gesture yet.

Login - Login would be possible at any time.  You simply put your entire hand down.  Then it looks through the users and picks the person that matches that hand.  Wouldn’t be 100% secure, but would quickly be able to use preferences and whatnot for your user.  If another user is logged in then it adds you to the session.  Your documents can now be openned, and you get your own “bar” of applications, etc.  This allows you to resize your keyboard and save the settings, then when you come in you can use your own keyboard size.  Your application menu would also be the same.

The Windows Start Menu - This could simply be a coin somewhere on the screen.  Moveable to be whereever you want it to be.  Then allows you to open it and view your menu (which is circular of course :)).  When multiple people are on they would each have their own menu.

Google Chrome OS is a cop out

Some one at google must have read thousands or even tens of thousands of emails from users pleading with Google to make an Operating System.  Google did wonderful things to the search engine world.  They seemed to do everything right.  Kept things simple and fast, exactly what search engines needed.  Then made ads that weren’t “in your face”.  Again beautiful.  Then they came out with email, which I personally love.  It works just the way that I want (some people would disagree).  So, with this track record, people requested an OS (I always theorized “the perfect OS” and knew that only google could ever make it).

Then, to everyones enjoyment Google announced that they would indeed be making an OS.  I couldn’t wait.  I wanted it to come out the day they announced it :( but sadly had to wait.  Then, it came.   And …. ARE YOU KIDDING ME.  What a piece of crap.  You already made Google Chrome (the browser), and it’s pretty cool (still hasn’t replaced firefox in my book, but it’s close), but come on, this OS is a cop out.  It’s like someone at google said “We already have chrome, let’s not spend much on the OS, just push something out that only has chrome, people will use it because it says Google on it”.  But come on, people use stuff that says Google on it because it’s always “the answer”.  If it’s not, then people don’t use it.  This isn’t a “game changer”, it doesn’t do anything.  In fact, it does less than a windows box with chrome on it because at least a windows box let’s me install other things.

Someone needs to be slapped :).

The answer.  I’ll be the first to admit that i’m not 100% qualified to come up with the actual answer, but here’s my opinion on what google could have done:

1) Create an application browser.  One that’s built to make application programming easier, and faster for the user.  Not one that helps make pages that work in todays current browsers, but one that replaces those browsers with one that’s made to build applications, client server, or just client, with cool syncing, and a new version of HTML/CSS that’s not for displaying new articles but for displaying applications.  Completely rethink the browser from an applications point of view.  This is the OS, and it should work fast.

2) Work offline or online, and sync when online.  Let me install applications and let them work completely offline.  Let me install Google Docs (which really should jsut come with the OS) and let it work lightning fast.  Let me save documents locally or in the cloud.  Or let me work on my “cloud” documents when i’m offline

3) Make it free and open source.  Rewrite the kernel, rewrite everything and make it awesome :).  Sit down at the table with all of your geniuses (or just a set of them) and come up with something that actually changes the world.  You’re the only ones that are able to, and once you do no one will use Apple or Microsoft ever again (ok that’s not true, but I wish it was).

Anyway, I know i’m just ranting, and google will never listen, but they could, and they could repent of their faulty attempt at something nice, and do what worked for them day 1 when they came out with something that actually changed the way we used the internet.

Simple PHP debugging with a log file

One of the biggest troubles with debugging in php (at least for me) is finding the error.  This brings me to the yell function.

The idea behind this function was first given to me by “Rob” at http://blog.tupleshop.com/2007/4/1/stupid-simple-logging (this link has since died)

His example is in rails, and I use it heavily

Here’s my example in php:

public function yell($string){
file_put_contents('yell.log', date("D M j G:i:s T Y") . " - " . $string . "\n", FILE_APPEND);

Looking through the code, all this yell function does is throws text into a file (with a quick timestamp before it).  That way you can see what values different variables have, etc.  It’s quick and dirty, but it brings a much greater view into your php at runtime.

The beauty of such a simplistic approach is that it’s easy to modify to do exactly what you need.

Here’s a good example, what if we wanted semi perminent logging, that is easy to turn on and off, with different levels:

public function yell($string, $importance = 1){
file_put_contents('yell.log', date("D M j G:i:s T Y") . " - " . $string . "\n", FILE_APPEND);

This way depending on what we set the $CURRENT_IMPORTANCE_LEVEL_CONSTANT to, only certain lines will be shown, or you can set the constant very high, and not see any logs at all, etc.

Rails Ajax for non javascript users

I’ve been adding Ajax to my site lately, and decided to see how my site worked without javascript.  I figure there are still some people somewhere who decide not to use (or don’t have access too, shutter the thought) javascript.  Dang, my site was broken.  Keep in mind that most of my javascript stuff is convenience only, but I was missing a major step to make sure that things worked even though javascript didn’t.

How did I make it work:

Here’s my first code:

<%= link_to_remote "#{image_tag "less.jpg", :border => 0} #{anchor.name}"
,                        :url => { :action => "hide_whole_anchor", :controller => "memory", :id => anchor }
,                        :loading => "Element.show('spinner')"
,                        :complete => "Element.hide('spinner')"

Doesn’t look so bad right?  Here’s the problem, the action of the form is just #, meaning when you click on it come right back to this page.  This doesn’t work for me :(.  Instead I had to add:

,                        :html => {:href => url_for(:action => "view_all", :controller => "memory", :id => anchor.id)}

after the :url line.  Then I setup view_all to listen for an id and open or close an anchor based on the anchor id (don’t worry if you have no idea what an anchor is).

This line should be found in each and every link_to_remote and form_remote_tag etc.  This way when all those non javascripters come to your page, things still work.

Ruby on Rails - Ajax not working on production, but is on dev

So I decided that I had to write on this, because it was sooooo annoying.

I’m currently writing a rails website (www.memorysketch.com).  I’ve been adding Ajax to it to make it cool.  Everyone loves ajax right?  The problem is that Ajax problems are harder to diagnose.  Nothing happens, and nothing tells you why.

The problem is that on my development box everything worked perfectly, but on my production box the ajax stuff just didn’t work.  No error, or anything, it just didn’t update the div properly.  Ends up that I forgot to delete the rhtml file :(. I had a create.rjs file that updated the div, and a create.rhtml file still sitting there on the production server but not on the dev box.  Very annoying.

So, if ajax just isn’t working, and you’re not getting any errors, make sure that you don’t have an rhtml file with the same action name.