Thursday, June 30, 2005

Google Maps API

Add the power of Google Maps to your website with the Google Maps API. Announced on the Google Blog: The world is your JavaScript-enabled oyster. I wonder how many sites will start using this?


Tags: , ,

Firefox Search Plugins

I have been following the progress of bug 123315 for Firefox/Mozilla. This bug is a request for search plugins to be installed in the user profile directory. They have finally made a patch for this bug so in future versions of Firefox (hopefully 1.1 too) plugins should be installed to the users directory.

Why is this important? Well, if you run under a limited user you cannot add search engines to Firefox without write access to the Firefox folder. Users who try to are not given an error message when they try to add one, it simply is not added. Also at the moment, search engines are added for all users, which may not be desirable (some users may want different search engines to others).

If you want to know how to do a basic search plugin, here is a mini tutorial:

Search plugins are actually very easy to do. If you look in the <Firefox Install>\searchplugins\ folder (by default C:\Program Files\Mozilla Firefox\searchplugins\) you will see all the search plugins used by Firefox. All search plugins comprise of two files - myplugin.src and myplugin.gif (myplugin can be anything as long as it does not conflict with any other files). The .src file contains the details for Firefox to know what website to search and the .gif file (which can also be a png) is the image that is displayed in the Firefox search box and is 16x16 in size.

To create you own, first create a blank text file called mysearch.src in the searchplugins folder. Then add the following:

<search 
   name="My Search"
   description="Search My Website"
   method="GET"
   action="http://www.mysite.com/search.php"
>

name refers to the text you want to see when you click the icon in the search box, description is the description of the search (not used in Firefox at the moment, but may be used by extensions or Firefox in future releases). method is what HTTP method to use (GET is normally used - i.e. when you post any input is passed to the query string). action refers to the page that will do the actual search.

You then need to tell the browser what parameter to pass the query on to (so if you use 'q' and search for 'firefox plugin' then resulting URL will be http://www.mysite.com/search.php?q=firefox+plugin and the user will be directed to it):

<input name="q" user>

You can also pass any other parameters you want to the page:

<input name="sourceid" value="mozilla-search">

You then close of the search tag:

</search>

Finally you provide any information for the browser to update the plugin:

<browser
    update="http://www.mysite.com/plugins/mysearch.src"
    updateIcon="http://www.mysite.com/plugins/mysearch.gif"
    updateCheckDays="7"
>

update is the location of where you will store this plugin on your site, updateIcon is the icon to use and updateCheckDays tells the browser how often to check for any updates.

The resulting contents of mysearch.src should then end up as:

<search 
   name="My Search"
   description="Search My Website"
   method="GET"
   action="http://www.mysite.com/search.php"
>
<input name="q" user>
<input name="sourceid" value="mozilla-search">
</search>
<browser
    update="http://www.mysite.com/plugins/mysearch.src"
    updateIcon="http://www.mysite.com/plugins/mysearch.gif"
    updateCheckDays="7"
>

Then create the image to go along with mysearch.src (i.e. mysearch.gif).


Tags: , ,

Thursday, June 23, 2005

Updated Text Clips for Programmers Notepad 2

Updated text clips for Programmers Notepad 2.


Tags: , , , ,

Monday, June 20, 2005

FixWordAutoFormat (C#)

Text pasted from Word into an ASP.NET Web Form can cause issues when posting to a database (the characters are replaced with '?' when the page content-type is not windows-1252). This function helps to fix the issue, by replacing those characters with ISO-8859-1 / UTF-8 friendly alternatives.

/// <summary>
/// Fixes text auto formatted by Word (em/en dashes, smart quotes, bullet, ellipses)
/// </summary>
/// <param name="input">String containing auto formatted text</param>
/// <returns>String without auto formatting</returns>
public static string FixWordAutoFormat(string input)
{
 // replace en-dash
 input = input.Replace("&#8211;", "-");
 // replace em-dash
 input = input.Replace("&#8212;", "-");
 // replace open single quote
 input = input.Replace("&#8216;", "'");
 // replace close single quote
 input = input.Replace("&#8217;", "'");
 // replace open double quote
 input = input.Replace("&#8220;", "\"");
 // replace close double quote
 input = input.Replace("&#8221;", "\"");
 // replace bullets
 input = input.Replace("&#8226;", "*");
 // replace ellipses
 input = input.Replace("&#8230;", "...");
 return input;
}

Tags: , ,

Tuesday, June 14, 2005

Date conversion examples (SQL Server)

Some examples of converting dates within SQL Server: Fun with Dates (Date Conversion examples). Includes, but is not limited to - finding month when you only have week and year, last day of month, get date portion of datetime value, counting days between two dates (while excluding holidays and weekends) and get first and last day of week.

Monday, June 13, 2005

MyGeneration Templates

MyGeneration is a quality freeware tool that can reduce coding time by generating code against your database. It comes with dOOdads, which is a high quality .NET framework for accessing your database tables and adding/updaiting deleting records via code. Very lightweight and written in both C# and VB.NET. I use the C# version, but it doesn't really matter which one you use as they are almost identical and when you compile to an assembly, you can use it with any language for .NET. There is also a forum at the site (registration required to post). The authors of MyGeneration (Mike Griffin and Justin Greenwood) regularly participate there.

It has a templating system, which allows you to output into any language (as it outputs to plain text files, so C#, VB.NET, SQL, PHP, Perl, Python - i.e. anything is possible). Templates are very powerful and simple to do, and you can write it with the following languages - C#, VB.NET, VBScript and JScript. With C# and VB.NET, you can embed Windows Forms controls in the input UI, or even create your own UI and run it instead of the built-in one.

You can also create several templates and group them together - i.e. you can have one template where you fill in the UI with the details you want and then run several templates after clicking OK. But an even better feature is the concept of projects. You can create a project that can consist of several modules, and each module can have a template instance (or more than one). When you add a template instance to a module you assign it a name, then record template input. When you save (i.e. click OK) it remembers your settings. So you could have one module that generates your stored procedures and business objects, another one to generate SQL to populate it with sample data and one to generate your input forms.

What is possibly even better is the Template Library. Users can create their own templates (plus assign them to archives that comprise of several) and upload them to the site. You can also submit articles/tutorials - in rich text (html) format, images are not hosted, so you have to point to your own site to include them. You can download templates from the library from within MyGeneration (unfortunately you cannot upload templates via it at the moment). While there aren't as many templates as there could be, there is still a good selection. Mostly for .NET, so it could do with some more for Java, PHP, JSP etc.

The few templates archives I have done are mostly for .NET:

But there are some for other things:

Also there are some templates that are not part of an archive:

All templates are under the 'SBC' namespace in the MyGeneration Template Browser.


Tags: , ,

Friday, June 03, 2005

Google Sitemaps

Google Blog : Webmaster-friendly

Google Sitemaps is an experiment by Google to improve the web for webmasters and users. First of all you create a sitemap - either manually (Sitemap Protocol), or via a tool you install on your server (Sitemap Generator).

Sitemap Generator requires Python 2.2 or higher installed on the server. If you cannot get Python installed on the server (i.e. using hosting solution with Windows and/or host unwilling to install extra software), you could always install/run it on you local development machine, then upload the generated sitemap. Since Sitemap Generator is open source, anyone can improve it - SourceForge Project: Sitemap Generator.

This is also open to other search engine developer as it is under the Attribution/Share Alike Creative Commons license (i.e. can be used commercially, but must give author credit and share any changes you make). Sitemap Generator uses the BSD license (the Creative Commons license refers to the protocol, not the tool).


Tags: , , ,

CSS Cheat Sheet

CSS Cheat Sheet is a useful reference sheet of CSS 2.1 selectors and properties, media types and unit references. Also includes an illustration on how the box model works (in standards compliant browsers, and IE6 when it is in standards mode). No specifics about browsers and how they implement the standards - but it wouldn't be a cheat sheet then, rather a 'cheat book'.


Tags: ,