August 25th, 2007 by bill · No Comments
»John Resig and the jQuery team have jQuery 1.1.4, addressing bugs, improving performance, and adding functionality while deprecating a bit in anticipation of jQuery the upcoming 1.2 release.
John Resig and the jQuery team have released jQuery 1.1.4.
This release addresses bugs, improves performance, adds some functionality, and deprecates some functionality in anticipation of changes upcoming in jQuery version 1.2.
Both standard and packed .js files are available at code.jquery.com.
jQuery Bugfixes
This latest release addresses 53 problem tickets (including those fixed in the 1.1.3.1 emergency release), improving computed styles in Safari, HTML script evaluation, and Ajax settings issues.
jQuery Library Improvements
Besides bugfixes, you can now rename jQuery. This allows multiple instances of jQuery to be included, side-by-side. Further, it allows you to use jQuery within the namespace of another library, such as the Yahoo! UI toolkit.
The new release also includes speed improvements over version 1.1.3 in id and element selectors, and with each() operations.
jQuery New Features
jQuery version 1.1.4 introduces some new functionality as well.
.slice() allows you to grab a “slice” of a selector result vector, and operates like the Javascript array slice method.
:has() allows you to further qualify a selector, as in $(“a:has(img)”) to select all anchors that contain an image element.
Deep .extend() allows objects to be merged without overwriting internal objects.
Deprecations
In preparation for jQuery 1.2, some items are deprecated in version 1.1.4.
Some XPath selectors are being dropped. An XPath plugin is being introduced with 1.2, and in the meantime CSS selector formats must suffice. For example, instead of using the XPath child selector $(“div/p”), you now use the CSS selector $(“div > p”).
The parameterized .clone() method is now deprecated.
DOM traversal methods .eq(), .lt(), and .gt() are deprecated, replaced by the new .slice() method.
Ajax methods .loadIfmodified() and .getIfModified() are deprecated and replaced by the long form .ajax() method. .ajaxTimeout() is deprecated as the long-form .ajaxSetup() will suffice. .evalScripts() is no longer needed since all scripts are evaluated are now automatically evaluated upon injection.
Tags: Javascript
August 3rd, 2007 by bill · 22 Comments
»Ajax programming with the jQuery Javascript library, covering load, get, post, and ajax methods. A PHP URL proxy is shown.
jQuery Ajax
jQuery, John Resig’s Javascript library, makes Ajax easy for beginners and professionals alike. This article dives into using the various jQuery Ajax methods.
Ajax Basics
Asynchronous JavaScript and XML, or Ajax, has become a catch-all term for client-initiated communications with a server. Specifically, Ajax usually refers to requests sent from a web browser to a server. It is even used to refer to non-XML communications, such as Asynchronous HTML and HTTP — AHAH. The rationale being that the first H in AHAH really means XHTML. I think someone just wanted another clever-sounding acronym; it really should be AJAH since it still uses Javascript. But I digress.
Simply put, Ajax allows you to execute a POST or GET request from the browser back to your server to fetch data, save data, execute a method, or what have you, without requiring a refresh of the web page.
jQuery Ajax Methods
jQuery provides several methods to assist with Ajax programming: load, get, post, and ajax.
load() takes a url, parameters, and a callback function. It executes a GET request of the URL and inserts the returned data into the DOM at a location you select. The parameters and callback function are optional. A typical usage would be something like $("address").load( url, {name:"John",id:"100"}, function(){ alert("Ajax call complete.");}).
get() takes a url, parameters, and a callback function. It executes a GET request of the URL and returns the XMLHttpRequest. The parameters and callback function are optional. A typical usage would be something like $.get( url, {name:"John",id:"100"}, function(data){ $("address").html( data ); alert("Ajax call complete.");}).
post() takes a url, parameters, and a callback function. It sends a POST request to the URL and returns the XMLHttpRequest. The parameters and callback function are optional. A typical usage would be something like $.post( url, {name:"John",id:"100"}, function(data){ $("address").html( data ); alert("Ajax call complete.");}).
ajax() takes a set of request properties specified in key-value pairs. It sends the specified request and returns the XMLHttpRequest. The ajax() method is complex but offers much more control over the request than any of the other methods. A typical usage would be something like $.ajax({ type:"GET", url:url, datatype:"html", data:{name:"John",id:"100"}, complete:function( data ) { $("address").html( data ); alert( "Ajax call complete.")}}).
Get Data From A URL
This example is taken from the jQuery Introduction posted here about a month ago. Technically, this is AJAH, since we’re not fetching XML, but the technique is the same.
We need a proxy to fetch data from another domain.
In the diagram below, you can see that the web page in your browser needs to fetch from the same domain from which it was loaded, in this case techrageo.us. From there it can go anywhere. In this example we’re fetching from Yahoo.com.

Ajax is usually limited to connections back to the same domain from which the web page was loaded. To fetch data from another domain, such as from the Yahoo quote server, we need to create a simple URL proxy. The PHP code is below. Basically it takes a URL, fetches it with curl, and returns the output.
Note: due to server restrictions, the curl_exec string below had to be tweaked to get it into this article. Just remove the spaces and you’re good to go.
<?php
// don't cache this page
header("Cache-Control: no-cache");
function geturl($url){
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
// make this curl_exec, no spaces
$results = c u r l _ e x e c ($ch);
curl_close($ch);
return $results;
}
// get the specified url from the querystring
$theurl = $_GET["url"];
// decode it
$theurl = urldecode($theurl);
// decode forgets the ampersand
$theurl = str_replace( "&", "&", $theurl );
// fetch the url
$v = geturl( $theurl );
// spit out the results
echo $v;
?>
Enter a stock ticker symbol, such as IBM or SBUX, and click Submit. When you do the span with id=”lasttrade” is loaded with data returned from geturl.php?http://finance.yahoo.com/d/quotes.csv?f=l1&s=IBM (assuming you entered IBM).
Update: Yahoo has changed their quote URLs to something like this http://download.finance.yahoo.com/d/quotes.csv?f=l1&s=IBM
Last Trade:
We’re using .load() for this simple example.
The jQuery code is below. As you can see an anonymous function is attached to the submit handler of the form with an id of stockform. The function gets the value of the input field with an id of sym, then appends it to the URL of the Yahoo csv quote server with format specified to return the last trade price. That URL is then escaped and appended to geturl.php?url=, which is a simple PHP proxy that resides here at techrageo.us. The submit handler function then returns false to prevent the browser from trying to continue submitting the form.
// wait till the DOM is loaded
$(document).ready(function() {
// attach a submit handler to the form
$("form#stockform").submit(function(){
// get the ticker symbol and build URL
var sym = $("input#sym").val();
var yurl = "http://download.finance.yahoo.com/d/quotes.csv?f=l1&s="+sym;
//old: "http://finance.yahoo.com/d/quotes.csv?f=l1&s="+sym;
var furl = "geturl.php";
// load last trade price from Yahoo and
// stick it in the #lasttrade span
$("span#lasttrade").load( furl, {url:escape(yurl)} );
return false;
});
});
Now let’s modify the example to use $.get().
jQuery’s $.get() method can be used to send a GET request. For example, the example above can be written as follows.
// wait till the DOM is loaded
$(document).ready(function() {
// attach a submit handler to the form
$("form#stockform").submit(function(){
// get the ticker symbol and build URL
var sym = $("input#sym").val();
var yurl = "http://download.finance.yahoo.com/d/quotes.csv?f=l1&s="+sym;
//old: "http://finance.yahoo.com/d/quotes.csv?f=l1&s="+sym;
var furl = "/code/geturl.php";
$.get( furl,
{url:escape(yurl)},
function(data){
$("span#lasttrade").html( data );
});
return false;
});
});
Now let’s modify the example to use $.ajax() for more control.
jQuery’s $.ajax() method can also be used to send a GET request. For example, the example above can be written as follows.
// wait till the DOM is loaded
$(document).ready(function() {
// attach a submit handler to the form
$("form#stockform").submit(function(){
// get the ticker symbol and build URL
var sym = $("input#sym").val();
var yurl = "http://download.finance.yahoo.com/d/quotes.csv?f=l1&s="+sym;
//old: "http://finance.yahoo.com/d/quotes.csv?f=l1&s="+sym;
var furl = "/code/geturl.php";
$.ajax({
url:furl,
data:{ url:escape(yurl) },
dataType:"html",
success:function(data){ $("span#lasttrade").html( data );},
error:function(xhr,err,e){ alert( "Error: " + err ); }
}); // $.ajax()
return false;
}); // .submit()
});
In part 2 we’ll look at POST requests and other dataTypes.
Tags: Javascript · Programming
July 5th, 2007 by bill · 8 Comments
»An introduction to jQuery, a great lightweight Javascript library.
Javascript Frameworks Abound
Do we really need another Javascript framework?
There’s the Dojo Toolkit. It’s mature and includes the kitchen sink. Then there’s Prototype. It’s wildly popular and several popular UI layers are built on top of it, including script.aculo.us, Rico, and others. Of course, you can’t leave out mootools. It’s UI library, moo.fx, can also sit on top of Prototype if you so desire. There’s Y!UI, the Yahoo! User Interface library. And we’ve got ExtJs, a robust interface framework that can leverage Y!UI, Prototype, or jQuery.
jQuery
Which brings us to… jQuery. Yep, it is yet another Javascript framework (YAJF). jQuery, though, is arguably the fastest and the most elegant of the lot. It supports CSS3, browser detection, method chaining, plugins, Ajax (gotta have that to be cool), flexible selectors, and basic UI effects. All in under 20K.
Simple July 4th jQuery Demo
Okay, so by way of introduction, here’s a simple little jQuery demonstration.
Click this link to turn this article red white and blue and get the lyrics to “God Bless America,” then click again to return to normal.
God Bless America,
Land that I love.
Stand beside her, and guide her
Thru the night with a light from above.
From the mountains, to the prairies,
To the oceans, white with foam
God bless America, My home sweet home.
The code is below, and is doing this: to the anchor tag (“a”) with an id of “redwhiteblue”, toggle between two functions on each click event; the first function loops through all the paragraph elements within divs of class “entry” and assigns a css color style based on the index mod 3 (iteratively assign from an array of red, white, and blue); the second function simply assigns a css color style of black to all paragraphs within divs of class “entry”; both functions return false to short-circuit the link.
Update: The commented section below is replaced by the three lines that follow it, suggested by jQuery’s creator, John Resig (thanks, John). What I was doing with a clumsy for loop, iterating through each paragraph I selected with a cobbled-together XPath, is better done with the each method, applying a simple function along the selected vector. It goes to show just how slick the library really is.
var rwb=Array("#f00","#aaa","#00f");
$("a#redwhiteblue").toggle( function() {
$("p.Godblessamerica").slideDown(300);
// for(i=0;i<$("div#jqueryintro p").length;i++){
// $("div#jqueryintro p:nth(" + i + ")").css({color:rwb[i % 3]});
// } return false;
$("div#jqueryintro p").each(function(i){
$(this).css({color:rwb[i % 3]});
}); return false;
},
function(){
$("p.Godblessamerica").slideUp(300);
$("div#jqueryintro p").css({color:"#000"});
return false;
});
More jQuery Demos
Here are a few other little demos I fiddled up along the way.
Toggle Red Demo
Click this link to toggle the following paragraph between black and red text.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis adipiscing purus eu elit. Quisque feugiat malesuada lectus. Suspendisse potenti. Donec viverra, nisi et lobortis sollicitudin, erat quam condimentum sapien, at volutpat ipsum neque tristique lorem.
$("a.togglered").toggle(function(){
$("p.redtarget").css({color:"#AA0000"});
},function(){
$("p.redtarget").css({color:"#000"});
});
Toggle Visibility
Okay click this link to reveal a DIV with some text. Then, click again to re-hide the text.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis adipiscing purus eu elit. Quisque feugiat malesuada lectus. Suspendisse potenti. Donec viverra, nisi et lobortis sollicitudin, erat quam condimentum sapien, at volutpat ipsum neque tristique lorem.
That’s a toggle tacked onto the DIV. Here’s the code to make that happen.
$("a.intro").click( function() {
$("div.introtarget").toggle(100);return false;
});
Translated into English, that means “select A tags of class intro, then handle click events by executing a function that finds divs of class introtarget and attach a toggle of speed 100 to them; then return false.”
Get Stock Quote With Ajax
Of course, jQuery supports Ajax. Here’s a simple demo that calls a PHP file that merely takes the URL passed in, fetches it, then echos the results.
The jQuery Javascript code takes the output (in this case just a number), and sticks it into the lasttrade span.
Last Trade:
$("form#stockform").submit(function(){
var sym = $("input#sym").val();
var yurl = "http://finance.yahoo.com/d/quotes.csv?" +
"f=l1&s="+sym;
var furl = "geturl.php?url=" + escape(yurl);
$("span#lasttrade").load( furl );
return false;
});
Shortest jQuery Tutorial Ever
Hey! Learn jQuery now. Here’s what you do to get your feet wet with jQuery.
- Start with a basic HTML file.
<html>
<body>
<p>Here is <a href="#" id="clickme">a link</a>.</p>
<p class="lorem">Lorem ipsum dolor sit amet,
consectetuer adipiscing elit.</p>
<p>This text is here to stay.</p>
<p class="lorem">Phasellus luctus. Suspendisse nisi
neque, feugiat eget, ullamcorper at, feugiat ut,
tellus.</p>
</body>
</html>
- Link in the jQuery library. You can do this by referencing the code at code.jquery.com or by downloading jquery.js and linking to it.
Below I’m linking to the packed version of jQuery 1.1.3.1 (the latest at the time of this update).
<head>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.1.3.1.pack.js"/>
</head>
- Add the standard jQuery document ready state handler function. This is a pattern used for most jQuery work, wherein your jQuery code resides.
<script>
$(document).ready(function() {
// your code here
});
</script>
- Flesh it out with some jQuery scripting. See above for examples; the code snippets in the examples can be dropped into the ready function, provided you add the proper elements to the HTML as well.
<script>
$(document).ready(function() {
$("a#clickme").click( function() {
$("p.lorem").toggle(100);return false;
});
});
</script>
Update and Wrapping Up
Since publishing this article I’ve made a few updates. First was to incorporate John Resig’s suggestion for the July 4th demo. Using each had crossed my mind but I was looking at it wrong and ended up patching an XPath together to get what I wanted.
The second update was to add some additional comments to the Shortest jQuery Tutorial Ever section.
And last, I incorporated today’s update to jQuery itself, now at version 1.1.3.1. Interestingly enough, though the tutorial had you link in version 1.1.3, I had been loading an older (pre-1.1.3) version on this site and was a little disappointed that the demos were a little sluggish. Linking to 1.1.3.1 provided a significant and very noticeable boost to performance. They said 1.1.3 was 800% faster than 1.1.2, and I mostly believed them — but come on, everyone claims they’re latest release of whatever is 800% faster. It’s like marketing boilerplate. I think they make rubber stamps that say that. But I can vouch that the latest release of jQuery is at least, technically speaking, a whole bunch faster.
Tags: Javascript · Programming
June 19th, 2007 by grant · 23 Comments
»Using Adobe Flex to create charts and graphs.
Getting started
Creating graphs with Adobe’s Flex 2 is a pretty simple task, just throw together some short XML and you’re done. But like most “easy” technologies things get a little more difficult when you want to do more advanced things like making sections of the graphs stand out or keeping multiple graphs in sync with one another. In this tutorial I will take you through how to give your graphs a little more “flash” and how to make things happen in one graph when you click on another graph.
If you haven’t already you can download the free Flex 2 SDK from Adobe. And you can download a free trial of the Flex 2 charting library.
In your favorite text editor (Eclipse anyone?) start a new file and start with some basic code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
xmlns:local="*" xmlns:view="view.*">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var profitPeriods:ArrayCollection = new ArrayCollection( [
{ period: "Qtr1 2006", profit: 32 },
{ period: "Qtr2 2006", profit: 47 },
{ period: "Qtr3 2006", profit: 62 },
{ period: "Qtr4 2006", profit: 35 },
{ period: "Qtr1 2007", profit: 25 },
{ period: "Qtr2 2007", profit: 55 } ]);
]]>
</mx:Script>
<mx:Panel x="10" y="10" width="100%" height="100%" title="Profit By Period">
<mx:PieChart id="profitPie" dataProvider="{profitPeriods}" showDataTips="true" width="100%" height="100%">
<mx:series>
<mx:PieSeries field="profit" nameField="period" labelPosition="callout" showDataEffect="{interpolate}" />
</mx:series>
</mx:PieChart>
</mx:Panel>
</mx:Application>
Getting more advanced
This code basically creates a sample dataset and a pie chart to display it. Nothing fancy and if we were using an XML feed we wouldn’t have any need for ActionScript at all, since we are only using it to create the data in this example.
Now let’s say that your customer (or boss) wants to have the data shown in multiple ways. For our example let’s say that he wants to see a pie graph, a bar graph and a data grid. So he can see the data in whatever way he wants to. No problem there, throwing another chart and grid on the page is just a few more lines of xml, but what if they are to interact? Say your boss wants to be able to click on a piece of the pie chart and have the same record highlighted in the pie chart, the column chart and the data grid. Now we’re going to have to whip out the ActionScript.
We are going to need three methods, one to highlight the pie graph, one for the column chart and a final one for the data grid. Then we can call all three of these methods whenever a chart or grid is clicked on. We are using three methods instead of just one giant method in case we ever want to use them again, in a different circumstance.
import flash.display.DisplayObject; //The items in the column chart are DisplayObjects
private var prevSelectedColumn:DisplayObject;
/*
We want to be able to "unhighlight" whatever column we highlighted last time, so
we'll create a variable to keep it simple. If you are using a graph with
multiple datasets then you'll obviously want to loop through them and reset them
that way instead of using this method.
*/
/*
* This function will highlight a column/bar in a column/bar chart
* @param barName The name/id of the bar/column chart
* @param barIndex The position of the column you want to highlight
*/
private function barHighlight( barName:String, barIndex:int ):void
{
if (prevSelectedColumn) //If we selected something before, unselect it:
{
prevSelectedColumn.alpha = .8;
prevSelectedColumn.filters = []; //remove the filters
}
//This gets the individual column that we are looking for
prevSelectedColumn = this[barName].series[0].getChildAt( barIndex );
if (prevSelectedColumn) //highlight the new column:
{
prevSelectedColumn.alpha = 1;
prevSelectedColumn.filters = [new GlowFilter(), new DropShadowFilter()];
}
}
/*
* This function will highlight a row in a data grid
* @param dataGridName The name of the data grid that contains the row to highlight
* @param rowIndex The position of the row in the grid to highlight
*/
private function rowHighlight( dataGridName:String, rowIndex:int ): void
{
this[dataGridName].selectedIndex = rowIndex; //the easy one...
}
/*
* This function "explodes" a piece of pie from a pie chart
* @param pieName The name of the pie chart that is to be modified
* @param pieIndex The index of the pie piece that is to be modified
*/
private function pieHighlight( pieName:String, pieIndex:int ):void
{
var explodeData:Array = []; //create an empty array
explodeData[ pieIndex ] = 0.15; //Set the index of our pie piece to > 0
this[pieName].series[0].perWedgeExplodeRadius = explodeData;
/*
The pie's wedges can be "exploded" outward to highlight them. The amount is
controlled by an array, so we just create a empty array (which would set
everything to no padding) and add padding for the index that is to be
highlighted. This has the added bonus of un-highlighting the piece that was last
highlighted (if any). Sweet!
*/
}
Adding events
Of course, this is using inline ActionScript. If you want to separate it into another file you’ll have to use “Application.application” instead of “this” (see the downloadable GraphHighlighting.as file below). That should give us a snazzy little effect every time we click on an item in any of the charts or in the grid. But they won’t be doing any effects unless we add event handlers to our objects. Let’s do that now.
So change the xml for your pie chart and add this to the PieChart tag:
itemClick="pieChartClick(event, 'profitGrid', 'profitBar');"
And then you can add the ActionScript to handle that event (which, of course, will call our handy three functions):
/*
* This is run when the pie chart is clicked on
* @param event The click event
* @param dataGridName The string name of the data grid that should be highlighted
* @param barName The string name of the column chart that should be highlighted
*/
private function pieChartClick( event:ChartItemEvent, dataGridName:String, barName:String ):void
{
pieHighlight( event.currentTarget.id , event.hitData.chartItem.index );
rowHighlight( dataGridName, event.hitData.chartItem.index);
barHighlight( barName, event.hitData.chartItem.index );
}
Then do this for the other chart and the datagrid and you’ll be set.
Conclusion and downloads
So, if you did your calculations correctly, remembered to carry the one and crossed your fingers you probably ended up with something like this:
Actually, it probably won’t look like that, but the sample code download does (see below).
It is more likely that you’ll probably be making the charts communicate using different data (click on one part of a chart and get detailed information in another chart), but this should at least get you started in the right direction.
Download the complete inline ActionScript example: This file is the complete example and you should be able to save it and compile it with the mxml compiler that came with the Flex 2 SDK (assuming you have the charting library, or the charting trial library).
Download the “external” ActionScript methods: This file is what you can use if you want to keep these functions in your library for future use. I put this in the FlexAS.GraphHighlighting package, so if you don’t change the package name you should put this into a “FlexAS/GraphHighlighting/” subfolder off of your main flex directory.
Tags: Flex · Free · Programming · Software · Web design · XML
June 16th, 2007 by grant · 4 Comments
»How to use proxy.pac scripting to make your browser choose the right proxy settings to use. When you're at work it uses your work proxy; at home it doesn't.
The problem
If you have a company laptop and your company forces you to use a proxy server you probably know about the mild annoyance of bringing your laptop home and finding that the internet doesn’t work because your browsers are setup to use a proxy that it can no longer find. So you probably go into your preferences/options and force the browser to connect directly to the internet, then switch it back when you get back to work the next day. Rinse, repeat, annoy.
Well, as it turns out most major browsers like Internet Explorer, Firefox, and Opera all allow you to use a bit of javascript to automatically set the proxy server to different things under different circumstances. You save this javascript code into a “proxy.pac” file and then you just let your browser know where it is.
Creating a simple proxy.pac
So open up your favorite text editor and lets create a proxy.pac. The javascript in this file should just be one function, called FindProxyForURL. It always will give you two parameters to work with and it should always return a string with a proxy (or several) to use. Below is a very, very simple version that will always try to use the proxy server unless it cannot connect, the it will try a direct connection:
function FindProxyForURL(url, host)
{
return "PROXY proxy.myworplace.com:1080; DIRECT";
}
Using day and time features
If you generally work the same hours every day and have a pretty set schedule then your proxy.pac will be fairly simple. We want to use a direct connection whenever we are hitting the local machine, on weekends, and during certain hours on the weekdays. Otherwise it will try to use the named proxy as a starting point. Regardless of which method is picked, if no connection can be made the browser should try the other method, since we just ordered them differently in the if-else statment.
function FindProxyForURL(url, host)
{
if( host == "localhost" ||
host == "127.0.0.1" || //bypass for local hosts
weekdayRange("SAT","SUN") || //bypass on saturday or sunday
timeRange(18, 7) ) //bypass after 6pm and before 7am
{
return "DIRECT; PROXY proxy.mycompany.com:1080";
/*with both the DIRECT and the PROXY listed it will try the
first and then fall back on the second*/
} else {
return "PROXY proxy.mycompany.com:1080; DIRECT";
}
}
Proxy by IP address
If you have a different IP address at work than you do at home then you can use that to filter off of instead of the time. We’ll just split the IP and if the first number isn’t equal to the first number of your IP at work then you must be elsewhere. We’ll also make it a bit more elegant and define our proxy server at the top of the file.
function FindProxyForURL(url, host)
{
var myProxy = "proxy.mycompany.com:1080";
var ipSubs = myIpAddress().split(".");
if( host == "localhost" ||
host == "127.0.0.1" ||
ipSubs[0] != "172" ) {
return "DIRECT; PROXY " + myProxy;
} else {
return "PROXY " + myProxy + "; DIRECT";
}
}
Setting up the browser
So you’ve got your file, but now what? You need to find a place to put it (it doesn’t matter where, as long as you know where it is located at). For our example we’ll say that it is located at “C:\stuff\proxy.pac”.
To setup Internet Explorer:
- Go to Tools->Internet Options
- Go to the Connections Tab
- Click the LAN Settings button
- Check the box labeled “Use automatic configuration script”
- Type in the address using this format: file://c:/stuff/proxy.pac
- Keep clicking “OK” until you get back to the main screen
To setup Firefox (v2):
- Go to Tools->Options (Edit->Preferences on Linux)
- Go to the Network tab
- Click on the Settings button
- Click the radio button labeled “Automatic proxy configuration URL”
- Type in the address using this format: file:///c:/stuff/proxy.pac
- Keep clicking “OK” until you get back to the main screen
To setup Opera:
Just setup IE and Opera is smart enough to grab that file and use it.
Conclusion and Resources
You’ll probably have a little trial and error period, but you should be able to get something that works for you and will keep you from having to go into your preferences/options.
Tags: Browsers · Tips
May 29th, 2007 by bill · No Comments
»How to speed up Acrobat Reader 8 and make it load super fast.
For the last several years, Acrobat Reader has drifted between sluggish and mind-bogglingly slow, particularly when starting up. Acrobat is a great tool and PDF files widespread enough to make the reader software a requirement on any system. So why is it so dang slow?
There are tools to speed up Reader and articles describing methods to do this by hand.
The tip that worked for me was described at ArsGeek: remove or rename accessibility.api from %Program Files%\Adobe\Reader 8.0\reader\plug_ins.
Now Adobe Reader opens nice and fast. This is no slouch of an improvement, either; the gain is from about 10 or 20 seconds down to 1 or 2 seconds.
Tags: Software · Tips
May 23rd, 2007 by bill · No Comments
»techrageo.us is upgraded to WordPress 2.2 and a new look.

techrageo.us has been upgraded to WordPress 2.2 and the look has been changed a bit with the switch to a slightly-customized CutLine theme.
Though the WordPress upgrade went okay, it had to be done manually since techrageo.us was originally installed manually. If you notice oddities around here, please let us know in a comment. Thanks!
Automation Is Good
Use one-click installs wherever possible! It is not always feasible, but Dreamhost‘s one-click install and upgrade processes, for example, are very convenient. In the case of this website, it was originally installed by hand, which left it out of the running for one-click upgrades.
Another benefit to using one-click installs, at least with Dreamhost, is that some additional plugins and wide array of themes are installed as well.
Tags: Site News · Wordpress
April 23rd, 2007 by bill · No Comments
»Gmail Super Clean is a Greasemonkey script that renders a snazzy clean Gmail interface.
Customize Gmail
Gmail Super Clean is a Greasemonkey script that renders a cleaner Gmail experience. Aside from the snazzy white interface, it removes the Gmail bookmark links, AdSense ads, tweaks the fonts, and slaps a groovy icon up top.
Gmail Super Clean Options
What’s more, under Tools->Greasemonkey->UserScript Commands, there are options to enable and disable the custom logo, the ads, the Google account bookmarks, change the font and font size. It even gives you the option to use a custom logo image.

Of course, Firefox only, and you must have Greasemonkey installed.
Tags: Free · Google · Web design
April 7th, 2007 by bill · 4 Comments
»Basic HTML and PHP SVG intro with very simple example of embedding an SVG drawing in HTML (or a WordPress post).
Scalable Vector Graphics, or SVG, is an XML standard for vector graphics (of course). That means that it contains descriptions of shapes, such as rectangles, lines, circles, and text, in an XML format.
SVG provides a robust definition language for drawings. The drawing at the right was a sample SVG drawing included in Jasc’s WebDraw. There are many other examples on the web of complex SVG drawings.
I’ve been playing around with SVG just a bit and thought I’d record the basics of getting simple shapes embedded in a page and how to do it with PHP and in WordPress.
Grant posted an article here a couple years ago on creating SVG Graphs With PHP, so check that out too if you want a more complicated example.
SVG in HTML
The simplest way to get SVG vector drawings in an HTML file is to embed an .svg file. The HTML and SVG source will look something like the following
HTML Code
<html>
<body>
Circle In A Square<br/>
<embed width="100" height="100" src="/wp-content/code/phpsvg1.svg"/>
</body>
</html>
SVG Code
<?xml version="1.0"?>
<svg width="100px" height="100px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<rect x="10" y="10" width="50" height="50"
fill="#777" stroke="red" stroke-width="3" />
<circle cx="16" cy="16" r="8" fill="black" stroke="yellow" stroke-width="3"/>
</svg>
Output
Circle In A Square
WordPress and SVG
To include an SVG drawing in a WordPress post, simply create and upload an SVG file then put the HTML EMBED tag in your WordPress post.
<embed width="100" height="100" src="/wp-content/code/phpsvg1.svg"/>
Basic SVG Tags
There are plenty of exhaustive SVG references on the web, so let’s look at just the tags used above.
svg – This tag indicates the beginning of an SVG drawing. The attibutes used above are width and height, both self-
describing, viewBox which describes a clipping rectangle for the drawing, and xmlns which simply defines the default namespace for
the XML tags used in the drawing.
rect – Here we define the rectangle, with x and y being the upper-left corner, width and height again are obvious, fill
is the rectangle’s color in hex digits, stroke is the color of the line used to draw the outside boundary of the rectangle, and
stroke-width is the width of that line.
circle – This defines the circle. cx and cy determine the center point of the circle, while r is the radius; fill,
stroke, and stroke-width have the same meanings as was used for the rectangle.
PHP SVG
Of course, outputting SVG from PHP requires that you output the SVG source back to the browser. However, PHP output will normally be marked as being of Content-Type: text/html, so you have to do two things to send back SVG:
- First, set the Content-Type header to image/svg+xml
- Second, make sure your php file does not contain any text outside the script tags.
So, the following PHP generates the above SVG drawing.
<?php
$svg = <<<END
<?xml version="1.0" standalone="no"?>
<svg width="100px" height="100px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<rect x="10" y="10" width="50" height="50"
fill="navy" stroke="red" stroke-width="3" />
<circle cx="16" cy="16" r="8" fill="black" stroke="yellow" stroke-width="3"/>
</svg>
END;
header("Content-Type: image/svg+xml");
echo $svg;
?>
Tags: PHP · Programming · SVG · Web design · Wordpress · XML
February 13th, 2007 by bill · No Comments
»Taking a look at Ultraedit text and code editor Version 13 beta.
Right on the heals of upgrading to version 12.20, we’re testing the beta for UltraEdit Version 13.00.
UltraEdit Beats the Competition
In January, we compared text editors for Windows, actually hoping to avoid paying for another upgrade to UltraEdit. The comparison included PSPad, Notepad++, EditPlus, UltraEdit, e, inType, TextPad, Crimson, jEdit, Vim, and some others. PSPad looked very good (especially for free), but ultimately the robust feature set and quality of UltraEdit set it apart from the others. The upgrade to version 12 was easily worth the minor cost.
Version 13 Beta
The UltraEdit 13.00 Beta is looking pretty snazzy. It has many new features, including
- Integrated scripting support – by integrating the JavaScript engine, UltraEdit supports user-written scripts. The UE application object allows interaction with the editor and documents.
- Spell check while typing – as you type, UltraEdit optionally indicates words that it thinks are misspelled and (after right-clicking the word) offers replacement suggestions. Normal spell-check is also available.
- Search in Favorite Files
- Search and Replace will step through all open files
- Search in Files for any files not containing search string
- User customizable format of Search in Files result
- Integrated IE browser support to show active HTML file
- Ability to define a persistent selection
- Cursor word-right or word-left to optionally stop at an underscore
- Syntax highlighting support of verbatim string literals
- Nested comments for languages
- Prompt before UE is set as View Source Editor during install
- and more
UltraEdit Scripting
Users can now create scripts (written in Javascript) that use the UltraEdit application object to access the editor and documents (along with normal Javascript features). According to the help file, the following is supported.

Spell Checking While You Type
As-you-type spell checking is now part of UltraEdit. Right-clicking the misspelled word (indicated by a dashed underline) displays possible correct spellings.

Built-in IE HTML Preview
A welcome addition is a built-in browser control to view HTML as you edit it.

XML Preview
A handy side effect of the IE integration is that if a document begins with an XML declaration (<?xml version="1.0"?>) the preview uses IE’s built-in stylesheet for XML.

Conclusion
There are, of course, still some bugs in the beta. A few fields in new dialogs have odd behavior. Strangely enough, given the addition of a Javascript scripting engine, syntax highlighting for JavaScript is not automatically enabled (nor was it immediately apparent how to enable it).
Overall, however, the new features are important and working well. Things are looking good for the next version of UltraEdit and it should be another worthy upgrade.
Tags: Beta · Software · Windows