Monday 29 December 2008

Chewing on Cookies

On vacation this week, but have been doing a little work here and there. Currently I'm figuring out how to work with cookies using Dojo and PHP. So here are a few quick examples if you are ever interested.



Set a Cookie in PHP



<?php
setcookie('CookieName', 'cookie value', time() + 3600 * 24);
?>

Just call the setcookie() function. Set the cookie name and and a value as shown. Notice how the time is set. Get the current time, then add the number of seconds you want the cookie to last. In this example, the cookie would be set to last 24 hours.



Get a Cookie with PHP



<?php
$cookieVar = $_COOKIE["CookieName"];
?>

To get a cookie, just access the global $_COOKIE variable.



Delete a Cookie with PHP



<?php
setcookie ("CookieName", "", time() - 3600);
?>

To delete a a cookie, set the cookie with an empty value and a time value in the pass. This should cause the browser to delete the cookie.



Get a Cookie with Dojo



// Initialize on Load
dojo.addOnLoad(function(){

var cookieVar = dojo.cookie("CookieName");

});

Call the dojo.cookie() function with the cookie name to get the value of the cookie.

Delete a Cookie with Dojo



function logOff(){
dojo.cookie("CookieName", "", {expires: -1});
}

To delete a cookie the approach is similar to PHP, set the cookie to an empty value and time, a day in the past.

Tuesday 23 December 2008

Google Gadgets for Linux 0.10.4

The 0.10.4 release of Google Gadgets for Linux is out, with optimized performance and memory consumption, as well as many bug fixes. To install or upgrade your copy of Google Gadgets for Linux, just download and install the binaries for your platform.

The new release supports more gadgets, including the recently released YouTube, Gmail, and Google Docs gadgets. Here's a picture of the YouTube gadget running on Linux.



The next picture shows the Gmail and Google Docs gadgets running on Linux. Note: If you've already unsuccessfully tried using the Gmail gadget, be sure to download the latest version of the Gmail gadget.



If you're a developer, try the dramatically improved Gadget Designer. It can now create new gadgets, and it runs as a separate application. Here's a picture.



As always, you can find the source code at the google-gadgets-for-linux project.

Friday 19 December 2008

The Docs gadget

We just released a neat little gadget that helps you find and open your Google Docs documents. And if you want to upload files to Google Docs, just drag them into the gadget. Please check out the announcement on the Google Docs blog.



This gadget has been well received among Googlers, and we hope you'll like it too. It runs on Linux and Windows and supports Google Apps accounts. Please try it out and let us know what you think.

We've released quite a few gadgets lately (Gmail, Google Docs, YouTube), but my favorite one is coming in January. Mark your calendar!

Thursday 18 December 2008

Summary of JavaScript Games

I have posted a few links to JavaScript games. I ran across this list of 25 amazing JavaScript games. Very cool stuff. And this is before the next next generation of optimized JavaScript engines. Probably a lot more to come.

Wednesday 17 December 2008

Winter Holiday Gadgets

'Tis the season for new Desktop gadgets to help you celebrate the winter holidays. Here's a guide to the some of the most recent additions.

SnowmanSnowman
by Benjamin Schirmer


Every desktop needs a snowman. To switch accessories, just click the part you want to change.
Hanukkah Menorah TwoHanukkah Menorah Two
by Glenn Rivkees


Use this gadget to help you keep track of when Hanukkah starts. Once the Festival of Lights begins, the gadget keeps each night's candle burning on your desktop.
The Dreidel GameThe Dreidel Game
by Glenn Rivkees


Whether or not you've ever spun a real dreidel, now you can play with your own e-dreidel.
Christmas Hat
by Lahiru Lakmal Priyadarhsana


If it's Christmas, it must be time for Christmas hats! Put a photo of your loved one into the special Christmas photo frame, and then adjust the hat for a perfect fit.

Click the snowflake in the bottom-right corner to show and hide the settings, or right-click for the context menu. You can even drag and drop a photo into the frame.
Countdown To New Year 2009
Countdown to New Year 2009
by Teodor Filimon


This multi-purpose gadget gives you snow, carols, gift shopping, calendar, the time left until Christmas, and finally a countdown to the New Year!

Want to see other seasonal gadgets? Check out the holiday gadget page.

Happy Holidays from the Google Desktop Team!

Thursday 11 December 2008

The YouTube gadget

The Google Desktop team is pleased to release a YouTube gadget for Google Desktop. It plays YouTube videos right inside the gadget and shows a feed of the day's most popular videos. Please check out the official announcement on the YouTube blog.



Watching YouTube videos is a favorite pastime of mine while waiting for code to compile or team meetings to conclude. Now with this gadget, I am able to waste time more productively, as I can bring up the gadget in an instant and search for videos (hint: pressing the shift key twice brings up all your hidden Desktop gadgets).

Please give it a try and stay tuned for more new gadgets ...

Wednesday 10 December 2008

App Server Log Reports [object HTMLInputElement] Instead of Text

Ran into this last week, chalk up another bone headed mistake for Mike. :) Once again, I'm hoping this note will help someone else if they run across this problem.


Problem: I'm using dojo.xhrPost to submit a form to an application server. However, when the data shows up on the application server, instead of text, I am getting [object HTMLInputElement]. Perplexing. If I submit the form without Dojo I seem to get text. What's the deal?


Solution: I was updating someone else's code to use a form for submission. The long and the short of it was, the old code uses "content:" to submit the data. The content attribute is used for creating an object literal list of values to submit data. For example:



myVar = {
param1:"some value",
param2:"another value"
}

Fine and dandy when you are using something other than a form.



...
content:myVar,
...

So I had changed the code to this, not noticing the slight change in syntax.



...
content:myForm,
...


However, since a form does not submit its data in this way, mayhem ensues. lol. To fix the problem, replace the above with:



form:myForm,


This results in happiness and joy for all.

Rounded Corners with CSS

Creating rounded corners with CSS is typically achieved with images. While working on my current project, I ran across this tip. CSS3 offers a border-radius property which is unfortunately not implemented in many browsers yet. Firefox does provide an extension for this as described in the article. Consider it a glimpse of the future. :)

Friday 5 December 2008

Free Network Attached Storage - FreeNAS

I recently installed FreeNAS 0.69RC2 (Kralizec) on an HP Pavillion 7915. The install was the easiest server product I ever installed and worked flawlessly right out of the box. Here is what I did to add extra network attached storage for zero dollars.

Server specifications for the HP Pavillion 7915 are:
  • 1.1GHz Celeron processor
  • Intel 810 chipset
  • 128 Mb SDRAM
  • 40 GB HD

I burned the 0.69RC2 (Kralizec) ISO onto a CD and started the Pavillion. The boot and install is very similar to a FreeBSD install (no surprise since FreeNAS is built on FreeBSD) so for those familiar with the FreeBSD installer this is a simple task. Follow the prompts to install the minimal OS and network services. Rebooting yields a server that boots in less than 16Mb of RAM. Detailed installation instructions are here.

Why FreeNAS?
Well, as the name implies it is free. Since the HP was donated to me by a coworker the server was free also (a real bonus). Secondly the ability to repurpose old hardware and create a new use for it is always a plus. Lastly the reasons to install FreeNAS include its ease of use and rock solid reliability and many more listed below.

What ships with FreeNAS?
FreeNAS is a free NAS (Network-Attached Storage) server, supporting: CIFS (samba), FTP, NFS, AFP, RSYNC, iSCSI protocols, S.M.A.R.T., local user authentication, Software RAID (0,1,5) with a Full WEB configuration interface. FreeNAS takes less than 32MB once installed on Compact Flash, hard drive or USB key. The minimal FreeBSD distribution, Web interface, PHP scripts and documentation are based on M0n0wall.

















Will FreeNAS work with Windows based clients?
Absolutely! FreeNAS ships with Samba server so Windows clients have no problem connecting, storing and retrieving data. See the snapshot below.

















Other Solutions:
To be fair, there are other NAS solutions, for a price, but why pay when that old family computer is begging for a second life. There are other open source based NAS solutions (NASLite, Openfiler, and a host of others), but for the ease of install, web-based interface and works out of the box simplicity of FreeNAS, you owe it to yourself to download and install the very stable and full functioning NAS from FreeNAS.org (FreeNAS blog).

Thursday 4 December 2008

Open Source iTunes Player?

Check out this story on ars technica on Songbird. Its an open source MP3 player with some extras. It doesn't rip CDs yet, but that's coming. Worth checking out.

Tuesday 2 December 2008

The Gmail gadget

Google offers a free, search-based webmail service called Gmail. Yes it's completely free, vanquishes spam, and includes over 7 GB (and growing) of space so you'll never have to delete another message. Not convinced? Just search Google for "i love gmail" and behold the many positive testimonials and reviews.

We like this Gmail so much, we developed and released a Desktop gadget that you can use to monitor your Inbox, read messages, and compose new emails. Check out the announcement on the Gmail blog.



Please give Gmail and the gadget a try, spread the word to all your friends, and let us know what you think about the gadget.

More information | Download gadget | Gmail