Archive for February, 2007

Password Generator Widget Version 2

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.

password-generator-2.png

php countries array

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:
  1. $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");
  2. $select = "Australia";
  3. for($i=0;$i<$loop;$i++) {
  4.     if($select == $countries[$i]) {
  5.         echo '<option selected="selected">';
  6.     } else {
  7.         echo '<option>';
  8.     }
  9.     echo $countries[$i].'</option>';
  10. }

css table row background image

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:
  1. .header {
  2. background:url(gradient.jpg) repeat-y top left;
  3. }

HTML:
  1. <table border="0" cellpadding="5" cellspacing="0">
  2. <tr class="header">
  3. <th width="240">Heading</th>
  4. <th width="240">Another Heading</th>
  5. </tr>
  6. <td>row 1, cell 1</td>
  7. <td>row 1, cell 2</td>
  8. </tr>
  9. <td>row 2, cell 1</td>
  10. <td>row 2, cell 2</td>
  11. </tr>
  12. <td>row 3, cell 1</td>
  13. <td>row 3, cell 2</td>
  14. </tr>
  15. <td>row 4, cell 1</td>
  16. <td>row 4, cell 2</td>
  17. </tr>
  18. </table>

And as you can see from the following renderings it only worked in Firefox and safari correctly (isn't that a surprise).

firefox_opera.png

ie_safari.png

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:
  1. table {
  2. background:url(gradient.jpg) repeat-y top left;
  3. }
  4. table td{
  5. background-color:white;
  6. }

HTML:
  1. <table border="0" cellpadding="5" cellspacing="0">
  2. <th width="240">Heading</th>
  3. <th width="240">Another Heading</th>
  4. </tr>
  5. <td>row 1, cell 1</td>
  6. <td>row 1, cell 2</td>
  7. </tr>
  8. <td>row 2, cell 1</td>
  9. <td>row 2, cell 2</td>
  10. </tr>
  11. <th width="240">Heading</th>
  12. <th width="240">Another Heading</th>
  13. </tr>
  14. <td>row 3, cell 1</td>
  15. <td>row 3, cell 2</td>
  16. </tr>
  17. <td>row 4, cell 1</td>
  18. <td>row 4, cell 2</td>
  19. </tr>
  20. </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.

Macbook Pro 2

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: