Dan McKee posted a comment on this site asking if I could modify my byte calculator widget to allow decimal places. I managed to get it done fairly easily but in the end I kind of re-wrote so its better. This new version has the following new features:
- No need for a select box/input box - just type in the unit you want to convert from and the other fields will automatically convert.
- easily copy the converted value to the clipboard by focusing on the field (mouse click or tab)
- Decimal points allowed (only one) and a better mothod of number input validation is used.

Click on the screenshot to download.
I’m a bit excited about CS3 coming later this month. I’m so excited that I’ve scribbled down some of the features I’m dreaming of:
Dreamweaver:
- Faster, better FTP - no timeouts would be ideal!
- The ability to view ftp passwords or have an option so that passwords arn’t encrypted at all. I don’t know how many times I’ve lost my password for a site and my only copy in dreamweaver. The way firefox handles passwords would be ideal - one password that handles them all.
- Universal Version
- validate php/php debugger with breakpoints
- CVS support
- A Linux version
Flash:
- Some sort of bone system so that characters could be easily animated and distorted.
- A Universal version
- A Linux version
Sometimes when I'm developing a website I might have a string of id values that are comma delimited and want to extract related data from a database. What I could do is explode the string into an array and then run multiple queries by looping through the array. While this works find, its not ideal to query the database so many times. What you can do is loop through the array and create a single query. What I normally do is use the implode function to create the single query.
So anyway, here is some code:
CODE:
-
$ids = "1,2,3,4,5";
-
$idarray = explode(",",$ids);
-
$sql = "SELECT * FROM users WHERE id='".implode("' OR id='",$idarray)."'";
So thats fairly simple, saves having a 'while' loop or a 'for' loop and concatenating a string. Its also helpful if you have multiple queries that have an additional condition. For example you might want to test if each user is active. You example...
CODE:
-
$ids = "1,2,3,4,5";
-
$idarray = explode(",",$ids);
-
$sql = "SELECT * FROM users WHERE active='y' AND id='".implode("' OR active='y' AND id='",$idarray)."'";
After using my previous Password Generator widget for a few days I soon realised that the passwords wern't actually random. Aparently it is a known bug that using the Math.random() javascript function in dashboard doesn't generate random values. I finally got around to re-writing my password generator widget. Version 2 has a simplified interface and automatically copies the generated password to the clipboard. Click the screenshot to download.

Occasionally I need an array of countries for webforms at work.
For a recent job I did I converted a list of countries from static html to php so that I could control the results a bit better. Hopefully this array will save someone some time.
PHP:
-
$countries =
array("Afghanistan",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola",
"Anguilla",
"Antarctica",
"Antigua and Barbuda",
"Argentina",
"Armenia",
"Aruba",
"Australia",
"Austria",
"Azerbaijan",
"Bahamas",
"Bahrain",
"Bangladesh",
"Barbados",
"Belarus",
"Belgium",
"Belize",
"Benin",
"Bermuda",
"Bhutan",
"Bolivia",
"Bosnia and Herzegovina",
"Botswana",
"Bouvet Island",
"Brazil",
"British Indian Ocean Territory",
"Brunei Darussalam",
"Bulgaria",
"Burkina Faso",
"Burundi",
"Cambodia",
"Cameroon",
"Canada",
"Cape Verde",
"Cayman Islands",
"Central African Republic",
"Chad",
"Chile",
"China",
"Christmas Island",
"Cocos Islands",
"Colombia",
"Comoros",
"Congo",
"Congo, Democratic Republic of the",
"Cook Islands",
"Costa Rica",
"Cote d'Ivoire",
"Croatia",
"Cuba",
"Cyprus",
"Czech Republic",
"Denmark",
"Djibouti",
"Dominica",
"Dominican Republic",
"Ecuador",
"Egypt",
"El Salvador",
"Equatorial Guinea",
"Eritrea",
"Estonia",
"Ethiopia",
"Falkland Islands",
"Faroe Islands",
"Fiji",
"Finland",
"France",
"French Guiana",
"French Polynesia",
"Gabon",
"Gambia",
"Georgia",
"Germany",
"Ghana",
"Gibraltar",
"Greece",
"Greenland",
"Grenada",
"Guadeloupe",
"Guam",
"Guatemala",
"Guinea",
"Guinea-Bissau",
"Guyana",
"Haiti",
"Heard Island and McDonald Islands",
"Honduras",
"Hong Kong",
"Hungary",
"Iceland",
"India",
"Indonesia",
"Iran",
"Iraq",
"Ireland",
"Israel",
"Italy",
"Jamaica",
"Japan",
"Jordan",
"Kazakhstan",
"Kenya",
"Kiribati",
"Kuwait",
"Kyrgyzstan",
"Laos",
"Latvia",
"Lebanon",
"Lesotho",
"Liberia",
"Libya",
"Liechtenstein",
"Lithuania",
"Luxembourg",
"Macao",
"Macedonia",
"Madagascar",
"Malawi",
"Malaysia",
"Maldives",
"Mali",
"Malta",
"Marshall Islands",
"Martinique",
"Mauritania",
"Mauritius",
"Mayotte",
"Mexico",
"Micronesia",
"Moldova",
"Monaco",
"Mongolia",
"Montserrat",
"Morocco",
"Mozambique",
"Myanmar",
"Namibia",
"Nauru",
"Nepal",
"Netherlands",
"Netherlands Antilles",
"New Caledonia",
"New Zealand",
"Nicaragua",
"Niger",
"Nigeria",
"Norfolk Island",
"North Korea",
"Norway",
"Oman",
"Pakistan",
"Palau",
"Palestinian Territory",
"Panama",
"Papua New Guinea",
"Paraguay",
"Peru",
"Philippines",
"Pitcairn",
"Poland",
"Portugal",
"Puerto Rico",
"Qatar",
"Romania",
"Russian Federation",
"Rwanda",
"Saint Helena",
"Saint Kitts and Nevis",
"Saint Lucia",
"Saint Pierre and Miquelon",
"Saint Vincent and the Grenadines",
"Samoa",
"San Marino",
"Sao Tome and Principe",
"Saudi Arabia",
"Senegal",
"Serbia and Montenegro",
"Seychelles",
"Sierra Leone",
"Singapore",
"Slovakia",
"Slovenia",
"Solomon Islands",
"Somalia",
"South Africa",
"South Georgia",
"South Korea",
"Spain",
"Sri Lanka",
"Sudan",
"Suriname",
"Svalbard and Jan Mayen",
"Swaziland",
"Sweden",
"Switzerland",
"Syrian Arab Republic",
"Taiwan",
"Tajikistan",
"Tanzania",
"Thailand",
"Timor-Leste",
"Togo",
"Tokelau",
"Tonga",
"Trinidad and Tobago",
"Tunisia",
"Turkey",
"Turkmenistan",
"Tuvalu",
"Uganda",
"Ukraine",
"United Arab Emirates",
"United Kingdom",
"United States",
"United States Minor Outlying Islands",
"Uruguay",
"Uzbekistan",
"Vanuatu",
"Vatican City",
"Venezuela",
"Vietnam",
"Virgin Islands, British",
"Virgin Islands, U.S.",
"Wallis and Futuna",
"Western Sahara",
"Yemen",
"Zambia",
"Zimbabwe");
-
$select = "Australia";
-
for($i=0;$i<$loop;$i++) {
-
if($select == $countries[$i]) {
-
echo '<option selected="selected">';
-
} else {
-
-
}
-
echo $countries[$i].
'</option>';
-
}
Published at February 8, 2007
in Web.
I had a little bit of a problem today where I couldn't get an image in a table header to span accross multiple cells. I wanted to span a gradient from one side of the It worked great in Firefox but failed in IE6/7 and safari. Infact I couldn't get an image to span accross multiple table rows. I've used colours before but this was different because I wanted a seemless gradient. The code I was trying was along the lines as:
CSS:
-
.header {
-
background:url(gradient.jpg) repeat-y top left;
-
}
HTML:
-
<table border="0" cellpadding="5" cellspacing="0">
-
-
<th width="240">Heading
</th>
-
<th width="240">Another Heading
</th>
-
</tr>
-
-
-
-
</tr>
-
-
-
-
</tr>
-
-
-
-
</tr>
-
-
-
-
</tr>
-
</table>
And as you can see from the following renderings it only worked in Firefox and safari correctly (isn't that a surprise).


I tried a few work arounds and searched the web for solutions but didn't really find any obvious solution. In the end I decided to make the table background the gradient and fill the table cells with a colour that sat on top of the gradient. This ended up working quite well and worked in all browsers. I would argue the code is cleaner as well as you don't need to add any class tags etc.
CSS:
-
table {
-
background:url(gradient.jpg) repeat-y top left;
-
}
-
table td{
-
background-color:white;
-
}
HTML:
-
<table border="0" cellpadding="5" cellspacing="0">
-
-
<th width="240">Heading
</th>
-
<th width="240">Another Heading
</th>
-
</tr>
-
-
-
-
</tr>
-
-
-
-
</tr>
-
-
<th width="240">Heading
</th>
-
<th width="240">Another Heading
</th>
-
</tr>
-
-
-
-
</tr>
-
-
-
-
</tr>
-
</table>
Feel free to point out that I'm completely wrong and there is a much better way to do this. At the moment tho its working quite well.
Published at February 3, 2007
in Mac.
In a follow up from my previous post about my PC-Mac switch I thought I would mention what else I like/dislike.
Firstly.. what I like:
- Spellcheck is everywhere.
- Networking is simple and painless with windows and mac's, although.. refresh (F5) in finder wouldn't go astray
- You can set desktop backgrounds to change at specific intervals and they have a nice fade transition when they do.
- Capturing HD video in Final Cut Pro works heaps better than Premiere and the playback is great as well.
- bootcamped vista/xp runs fine
- apple tilda switches between windows of current application... very handy
- two fingers on touchpad + click = right click (you have to enable this in prefs)
- Apple + Esc = Frontrow (for when you don't have your remote handy)
Here is some stuff that I don't like:
- Recycle bin doesn't have a restore feature.
- My hands get burnt resting on the front of the laptop.
- you need to click progam windows to enable it before you can use it.
- moving folders with same name overwrite folders... its actually possible to delete a complete folder of work with an empy folder!!!
- you can't access files in a folder when you are copying to it... you can in windows.
- The mouse cursor doesn't always behave. It sometimes stays a text selection tool when clicking to drag a window etc
And here is some differences that I've found:
- Pressing Shift when caps lock is on does nothing. In windows this toggles Caps lock even if caps lock is on.
Oh, and here is a few programs I recommend:
well, I rollerbladed to work today... Something I haven't done for about 5 or 6 years!! My legs feel a little strange as I used muscles I haven't used in a long time.
Its interesting tho.. I had no troubles picking it up again. I guess its like riding a bicycle.
*edit* an update on this.. I skated (skateboard) to work today... prob never again!!
Published at January 28, 2007
in Mac.
A few nights ago I was looking for a password generation widget but couldn't find a decent one that didn't phone home. I came accross the Dashcode beta a while ago and figured I would jump in and create one. My first widget (Byte Calculator) was made with all the seperate files that make up a widget and I thought it would be interesting to see how Dashcode does it.
I was impressed at how simple dashcode makes the widget making process. Infact I finished the widget in about an hour.
I just finished giving it some style tonight and thought I would share it with the world. Let me know what you thin.

(click on the image to download)