Building Bebo Apps. Part 1

by Tony Primerano on Apr.15, 2008, under bebo, tech

Last week I spent some time learning how to build Bebo applications. Their API is just like the Facebook API but it is not complete and the documentation has some holes in it. If you haven’t built a Facebook application the entire process can seem awkward.

The Bebo Developer Page makes it sound like a simple 3 step process

  • Get the library
  • Install the app
  • Start Creating.

If you don’t know how to write web applications in PHP, Java or Ruby stop now. You need to know at least one of these systems to continue.

I downloaded the PHP library and put it on my host. Next step was to install the developer application. Why? Why do I need to install an app to build apps? Seems weird at 1st but basically this application is used to manage the keys, locations and settings for your apps.

Once you have the app launch it and click “Create new app” (way off on the right) . Give your application a name and a URL and a callback URL.

What is the callback URL? It is the URL that is hit when a user goes to the Application URL. http://apps.bebo.com/yourappname is just a proxy that adds headers and parameters to the request before it hits your application file. The bebo library uses this information.

For example. I created an app called sample with a URL of http://apps.bebo.com/sample. My callback URL is http://bebo.tonycode.com/apps/sample

Hitting http://apps.bebo.com/sample results in a call to http://bebo.tonycode.com/apps/sample where I have the following index.php

http://tonycode.com/wiki/index.php?title=Bebo_Examples#Display_All_My_Friends

This application simply prints out all your friends.

Add the application to your page by going to the developer application, viewing the app and clicking the profile page for the app. Now go to your profile page a voila.. the app is there but not your friends.

Huh? How do I get the content to show up on my profile page? If I don’t show it on the profile page it seems pretty pointless. right?

To add content to the profile page you use profile_setFBML. Last I checked the return codes for this function are not defined. Seems to return a 1 when it works and an array when it fails. Nice. :-\

Here is the code updated to put friends on profile too.

http://tonycode.com/wiki/index.php?title=Bebo_Examples#Display_All_My_Friends_on_my_Profile

Weeks go by and you add new friends to your profile and you notice that the list of friends in your custom application aren’t changing. profile_setFBML is only called when you visit the application page. Well that stinks you say. How can I make it update each time I visit the profile? I’ll get to that in my next post.

Random Tips.

  • Documentation is at http://developer.bebo.com/documentation.html
  • The downloaded libraries have example code. Start there
  • You may need to look at 2 different sections to piece together how a function works. For example user.getInfo has a fields parameter
    • http://www.bebo.com/docs/api/UsersGetInfo.jsp
    • Look at the SNQL users table to find what is available
      • http://www.bebo.com/docs/snql/User.jsp
Leave a Comment : more...

Save a tree.. use PDFCreator

by Tony Primerano on Mar.24, 2008, under Life, green, tech

I always hated printing confirmation pages from web sites. Printing a piece of paper that’ll end up in the recycle bin in a few weeks is just silly. There are also times that I’m not connected to a printer and I really need to save a copy of something I’m viewing.

My answer for the past few years has been PDFCreator, install it and whenever you print, you can print to a pdf file instead of a printer. This month alone I think I’ve printed one paper page from my printer and about 90 pages to PDF form.

I also used PDF creator to email proof pages for our daughter’s yearbook to teachers. In the past printouts would be made for each teacher, they would mark them up and send them back. I’ve easily saved a ream of paper this year by doing this via email. Not to mention its easier to manage email than paper.

Once installed, just use it like a printer. It will show up as a printer in the print dialog.

print dialog

From there it will ask you for a title and then a name for your pdf. If you want to make a hardcopy later you can just print the pdf file you created.

2 Comments :, more...

Dumping Blockbuster online for Redbox

by Tony Primerano on Mar.12, 2008, under Life, tech

Over the past few years my Blockbuster subscription fee has increased and the number of in store exhanges allowed has decreased.   At the same time my queue is running on empty.   At 1st there were tons of movies I wanted to see but now I’m caught up and I don’t have the desire to rent more than 1 move a week.

What are 4 movies a month worth?   If I use Redbox those 4 movies will cost me $4 (if I return them in 24 hours).  With Blockbuster Online only the cost is $9 (no in store exhanges).
Sure  I can keep the blockbuster movies as long as I want but I only watch them once and why not just grab one when I know I have time to watch it.

The trouble with Redbox in the past was that you never knew what was going to be in the box when you got there.  They recently made my local Redbox part of their online rental system so that problem is solved.

There is a remaining issue that I hope Redbox is working on.  There are frequently people browsing movies when you get to the box.   You need to wait for them to finish before you can return a movie or pick up your movie, that you ordered online.   They should have an online pickup and return slot on the side so those of us impatient people don’t need to pace around behind the people browsing titles.   :-)

Bye Bye Blockbuster.   I suspect next year I’ll be able to dump Comcast an use Antenna and the web for my television consumption.

Leave a Comment more...

My sitemap notes are in the Advanced Rails Recipes Book

by Tony Primerano on Mar.08, 2008, under rails, sitemap, tech

After I blogged about building a sitemap for Rails I contacted Mike Clark and asked him if he thought it would make a good Recipe for his upcoming book, Advanced Rails Recipes. He thought it was a good fit and it is currently in the Beta version of the book.

I wrote up my notes in the Recipe format, then Mike basically rewrote it for Rails 2.0 and added some additional content. Thanks Mike! I almost feel bad being cited as the author since after editing it is drastically different from the original. :-)

The core concepts are still there and some thoughts were dropped since Recipes should be short. So, Here are some elaborations..

The Ping Protocol

There is a warning in the book about excessively pinging to Google to have them read your sitemap. I would recommend letting search engines crawl your sitemaps at their own speed. The ping example in the book was a nice overview of when to use an Observer and also provided complete coverage on how to submit sitemaps. Please use ping sparingly, if at all. :-)

Sitemaps with over 50,000 entries

I work on sites where we use siteindex files because we submit well over 50,000 URLs to the search engines. I didn’t provide an example on how to build these in Rails because I’m not sure they provide any value to the typical site.

My theory is that if you build a sitemap with the 50,000 pages that were most recently updated you will give the search engines all they need. If a page isn’t updated for a while and it falls off the list is that really a problem? If the page was worth anything someone externally would be linking to it before it fell off the list. Now if your site is creating millions of pages a day this may not be the case.

If your pages are islands (no links to them) and you’re afraid they won’t be found unless they are all in the sitemap, I would suggest building the sitemap via a rake task that is kicked off via a cron job. This will also give you an opportunity to gzip the files. I’ll try to writeup some example code for the this when I find some free time.

Do I really need a sitemap?

If your site has navigation to all its pages, then a sitemap will probably not benefit you. I suggest checking what pages the search engines have in their index and if key content is missing then pursue a sitemap. Even if they are finding all your pages a sitemap certainly couldn’t hurt.

Just in case you didn’t know how to find the pages Google knows about on your site you can simply type site:youdomain.com in the Google or Yahoo search box.

Example results for my site are here

Leave a Comment : more...

Smarter Traffic Lights could save a lot of energy

by Tony Primerano on Feb.14, 2008, under Life, green

I hate traffic lights. I hate them even more when they have me stopped unnecessarily. I’m always thinking about the gas being wasted as cars are forced to stop and then idle. Sure, electric cars will recapture energy when you are breaking but there is still energy lost. I suspect 10% of the traffic lights in this country are unnecessary and of the remaining 90%, 50% of those are only useful for about 8 hours a day. Still more aren’t needed on weekends.

As a teenager I was visiting Utica NY and there were stoplights at almost every intersection, despite the fact that Utica was already a ghost town (population was in steady decline since the late 1960s). Was it cheaper to leave them up than to install some stop signs?

What we need is a place where people can report useless stop lights so they can be removed. We also need a way to report enhancements. On my way home I come to a light that I turn right at. There is a right turn lane but no arrow. This results in all cars stopping when the light is red even though the cross traffic runs one way at a time. A turn arrow would easily save 500 cars a day from needing to stop. How much gas would that save? I guess I should write my county government but I’m sure this will be a time consuming and painful process. If people stuck at intersections thought about issues with the intersection and were able to report them easily, think of all the energy (and time) we would save.

Besides removing lights, some municipalities need to work on making their lights facilitate the flow of traffic. You should never be driving down a main road and get stuck at over 50% of the lights. It kills me when I’m stuck at a light and I see the next light in sequence turn green only to be red by the time I get there.

I always loved driving late at night when most of the traffic lights were blinking yellow. I think most lights should do this much earlier and some should do it all weekend.

More traffic circles would also save energy, if only American’s knew how to use them. People are too timid resulting in less than efficient operation. Also you have the confusion made by differing rules. Most states use the same rules as Europe (traffic in circle has right of way) but New Jersey made up their own rules.  Even with US circle inefficiencies I suspect traffic circles are a big energy saver.

As an experiment I’m going to see if I can get a right turn arrow put in at that intersection I mentioned.  I suspect it won’t happen because there is no incentive.  It will cost money to install and will provide the county no benefit.  In fact they’ll lose a little tax revenue from gas sales since we’ll be using less.  ;-)

Of course if everyone was reporting light change suggestions the county could prioritize them by impact.   How many cars per day can you stop from stopping would be one measure and idle time reductions would be another.    That’s all for now.  Let me figure out how to request a light!

3 Comments : more...

Free Heat.. from your clothes dryer

by Tony Primerano on Feb.12, 2008, under Life, green, tech

Electric clothes dryers are not an efficient way to heat your home, but if you’re using it anyway, you might as well use that heat to warm and humidify your home in the winter. Not only is your dryer heating air and sending it outside, it is constantly pulling warm air out of your house when it is running. What is coming into your house is cold dry air to replace the air the dryer is expelling. There is also the issue of air coming into your dryer vent when the dryer isn’t running. If your outside vent cap doesn’t seal well this can make your laundry room very drafty.

Here’s what I do every fall to help warm my home, increase humidity and lower drafts in my laundry room.

1) I disconnect my dryer hose from the outside and stuff the hole with plastic grocery bags. These make great insulation, just don’t forget to take them out in the spring when you reconnect.
2) I connect a longer dryer hose to my dryer and run it to a lint trap. Try to get the trap as far as possible from the dryer as you want the humid air to dissipate. Depending on your existing setup you may be able to use your existing hose.

Here is my lint trap. Under the sink, next to the washer

lint trap

Here is the dryer hose running from my dryer and past the washer.
dryer hose

Since I have kids we do a lot of laundry, which in turn results in me never having static electricity issues in the winter as my home is never too dry. These lint traps are pretty common. If you Google “lint trap” you’ll find plenty of places selling them. They are filled with water and they catch most of the lint. Warning, If you let the trap run dry you’ll end up with a linty home.

I know some people use nylon stockings over the end of the hose instead of a trap but if you didn’t clean it often you could damage your dryer or cause a fire. I also have friends who have created larger boxes to capture more lint. Please leave comments or other ideas below.

Warning #1: Only do this in the winter months as you may end up with a mildew problem from excessive humidity and this will work against your air conditioning. We want to expel heat in the summer. Also, the dryer will not be able to dry clothes as fast if it is pulling in excessively humid air. I find this to be a non-issue in the winter because the humid exhaust is quickly evaporated into the relatively dry house air. The further you can get the lint trap from the dryer the better.

Warning #2: Don’t do this if you have a natural gas dryer.  You must vent this outside to prevent carbon monoxide buildup in your home.

Warning #3: If you use fabric softeners or home dry clean kits you should probably not do this as you may end up with unhealthy air.

i find that switching over from internal to external venting gives me an excuse to clean lint out of the lines and dryer twice a year. When was the last time you cleaned your vent hose?

2 Comments :, more...

Why are there so many Craigslist Flakeouts?

by Tony Primerano on Jan.24, 2008, under Life

I love buying and selling things on craigslist but I’m amazed at how many people email you about an item and never respond back. Are they just gathering email addresses for spammers? That seems like too much effort to build a spam list but I would say about 50% of the people I respond to never follow up. Maybe they found a better price but if so why not offer me less?

I feel like adding a note to my postings saying that if you inquire about an item and then don’t follow up I will post your email address on my blog. :-) The flakeout list.

These flakeouts make everyone’s life miserable. I always give an item to the 1st person who inquires and tell other people that someone else responded 1st but I will let them know if they don’t follow through. Anyway here are my craiglist tips after selling about 8 things on craiglist.

  1. Post items around lunch time on a weekday. People browse craigslist from work. I get much better responses on weekday posts than weekend.
  2. If you get multiple responses let the 1st responder know that the item is theirs but they need to pick it up soon or you will give it to the next person. This will get them to commit or bail quicker so you won’t wait a week for them to make up their mind. Respond to other interested parties letting them know someone else is ahead of them but you will contact them if the other person does not follow through.
  3. Google the person who emailed you. On a few occasions I have found that someone lived near my work and I met them at lunch. Saving them a long drive to my house. You might also find some scary information on a person. Remember, you’re inviting these people to your house for a pickup, so do a little research. ;-)
  4. Always include a picture of the item.
  5. Don’t host the pictures on craiglist. If you upload pictures to craigslist they are deleted when the entry expires. There is a nice repost option but you need to upload the pictures again. If you put the pictures on a photo sharing site and type the html by hand the reposting process is much easier. for example
    • <img src=“http://tonycode.com/craigslist/jacks.jpg” />
Leave a Comment more...

Ruby on Rails SEO tips

by Tony Primerano on Jan.10, 2008, under tech

Recently I implemented a Rails application sitemap but once the search engines started hitting my site, I realized that I wasn’t giving them all the information they desired.

  • Yahoo was doing simple HTTP head requests on my sitemap and going away
    • 206.190.57.45 – - [11/Dec/2007:08:35:49 -0800] “HEAD /sitemap.xml HTTP/1.0″ 200 334 “-” “Yahoo! Slurp/Site Explorer”
  • Google read my sitemap infrequently but loved to do HEAD requests on my index page
    • 66.249.70.196 – - [17/Dec/2007:07:11:24 -0800] “HEAD / HTTP/1.1″ 200 372 “-” “Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)”

For those of you unfamiliar with HEAD requests, they are requests for a page that don’t actually return the page. Just information like size and date. Its a nice way for search engines and caches to decide if there are any changes they need to pull. For some examples of HTTP requests check out the wiki page I wrote on making HTTP requests via telnet.

Now what do you think Google and Yahoo were looking for? My assumption is they are looking for the Last-Modified header in the response to see if they should bother requesting the sitemap. They could compare the size of the response since they last visited but I doubt they want track this information.

The Last-Modified date is the ideal field to check.

This is all fine and good but guess what. Rails doesn’t set that header for you.

telnet ficlets.com 80
Trying 64.12.150.213...
Connected to www.ficlets.com.
Escape character is '^]'.
HEAD / HTTP/1.0
Host: www.ficlets.com

HTTP/1.1 200 OK
Date: Wed, 09 Jan 2008 20:22:31 GMT
Server: Mongrel 1.0.1
Status: 200 OK
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
Content-Length: 16355
Set-Cookie: _session_id=s322clipped; path=/
Vary: Accept-Encoding
Connection: close

The good news is this is easy to add! If you look at my wiki example you’ll see that I set the header with the time of the latest entry in the sitemap.

headers["Last-Modified"] = @entries[0].updated_at.httpdate

Now it isn’t rails job to add this header for you but it would be nice if the scaffolding added this header. The standard show/1 actions are pulling a record from a database and the action knows the updated_at value.

I have added this header to my show actions as I am just pulling a record from a database and I have the modified time!

headers["Last-Modified"] = @business.updated_at.httpdate

That’s all. I’m looking forward to any comments and suggestions people may have.

1 Comment : more...

Converting Ceiling Fan light from Intermediate(E17) to Medium base so you can use CFLs

by Tony Primerano on Jan.07, 2008, under Life, green, tech

Up until a few months ago, all of my bedroom ceiling fans used Compact Florescent bulbs (CFLs). Back in October I bought a Hampton Bay Ceiling fan for Dani’s room and when I installed the light fixture I noticed it had a different socket type. It used Intermediate base bulbs (also known as E17). These bulbs are rare and there is no CFL option. So I went back to Home Depot and sure enough all the manufacturers were starting to use these things. The Home Depot guy suspected it was a conspiracy between the ceiling fan companies and the bulb manufacturer. There is only a single brand of intermediate base bulbs at Home Depot so this made a little sense. They also cost as much as a CFL!
I had no desire to use these bulbs so I started looking into converting my base to use the standard medium base socket. I saw a medium base for a ceiling fan display model at Home Depot but they wouldn’t sell it to me and it was no longer going to be carried. The plot thickened. So I looked on the Lowes website and I found a medium base socket that I figured I could retrofit onto my base. While I was looking for the item at Lowes, I asked a representative of one of the lighting companies (who was restocking) about the intermediate bases and he said it was all part of the 2007 Energy Bill. Huh? How can using a base that doesn’t support CFLs be part of an energy bill? I googled around and it appears this was a loophole to get around the Bill. The bill required ceiling fan manufacturers to ship with CFLs, UNLESS they used candelabra or intermediate base bulbs.

Bastards.

Here is the conversion that I did tonight in about 15 minutes.

DISCLAIMER: Please do no do this unless you are experienced with electrical wiring. Follow these steps at your own risk. There may be typos so use common sense if you do this.

1) Unscrew the existing sockets and cut the wires. Keep track of the original wiring. Save the screws.

2) Remove the mount from the Lowes socket and attach it to the base with the screw from the intermediate base. Twist and bend to get it as close to center.
3) You’ll need to strip the existing wires that were not part of the intermediate bases.
4) Combine your whites and blacks and attach with a twist on electrical wire connector.

5) Reinstall

Since these sockets are bigger I needed to bend the socket a little before the light covers fit but overall the fixture looks great.

Pictures. yeah close ups are out of focus but hopefully helpful. ;-)
This is the bottom of the intermediate bulb base. poor focus. This is where you will find the screw to remove it.

intermediate base

Here is how the medium base (lleft) compares to the intermediate base (right).

medium to intermediate comparison

The new base had 2 screws. I removed them and used the screw from the intermediate base since I knew it fit the fixture.

medium base

Old Wiring.

original wiring

New Wiring

new wiring

And now I have CFL joy.

finished product

56 Comments :, more...

The New Car – 2008 Honda Fit

by Tony Primerano on Jan.04, 2008, under Life

I bought a Honda Fit on New Years Eve. What was I thinking?

I drove my 1996 VW GTI for 11 years and over 120,000 miles. I bought it back in December of 1996 after the oil pump on my 1988 Jeep Comanche died while I was at my mom’s house for Christmas. Before the Comanche I drove a 1977 Mercury Cougar XR7 that I bought from my mom when I was 16.

  • Cougar had a 351M 5.8L V8 (173HP) 4000 lbs (23.1 lbs per horse)
  • Comanche had a 2.5L 4 cylinder (117HP) 3000 lbs (25.6 lbs per horse)
  • GTI had a 2.0L 4 cylinder (115 HP) 2557 lbs (22.2 lbs per horse)
  • Fit has a 1.5L 4 cylinder (109 HP) 2551 lbs (23.4 lbs per horse)

There seems to be a trend in engine displacement and weight. ;-)

I’m pushing 40 and I’m on my 4th car. I had a friend in high school who had bought over 10 cars before he was 20. ;-)

Why the Fit? Honestly I did not expect to like this car. Before I drove it I drove

  • Mini Cooper. This car is really cramped inside and there were some interior design flaws that I would not have expected from a BMW.
  • VW Rabbit — I loved my GTI but I can’t spend another 10 years in the same car
  • Mazda 3 — I liked this car but I didn’t love it. And it was a bit heavy
  • Scion XD — I wasn’t impressed and the front end is really high. it looks a little goofy

The fit looks tiny but it is well designed inside and has more interior space than the other cars. It also only weighs 2551 lbs which is about the same as my 1996 GTI. Cars keep getting heavier and I love light car for city and rush hour traffic. Yeah, I know some people prefer to drive tanks for safety but I also own a 1986 Kawasaki Ninja 250 that I stopped driving when I had kids. I gave up the motorcycle for safety but you won’t find me in a Hummer anytime soon. :-P

There were a few things that I didn’t like about the Fit that were being addressed in the 2009 model but I became convinced that my GTI was not going to live to see November 2009 (New Fit Launch date) so I headed to the dealership on New Years Eve. I figured I would have more negotiation power on the last day of the year. They only offered my $500 for my trade in and I asked them if they would match an offer from CarMax. They said they would, so I came back an hour later with my $1200 trade in offer from CarMax and they matched it. They also matched a price I was quoted over the internet.

So my car buying tips of the day are

  • Always get a CarMax trade in offer 1st
  • Always get an offer from the dealer via their internet department 1st as this is better than what you get when you just show up.

That’s the story. I hope the Fit gets better gas mileage than my VW. The Golf was advertised at 23/30 but I got 30/34. The Fit advertises 27/33. Lets see what I get out of it. My notes will be here.

4 Comments more...