Tuesday, December 18, 2012

How to cater for Internet Exploder...

I found (yet another) a very handy article that will be of help to anyone that has to support Internet Exploder.



ps: Comments and/or links to this article are most welcome!

Sunday, November 4, 2012

List of JS/CSS loaders

Here is a handy feature-comparison list of JS/CSS loaders that helped me
when I was searching for just such a loader.



ps: Comments and/or links to this article are most welcome!

Wednesday, September 19, 2012

PHP, LESS CSS and css/js minify

UPDATE: Link and source updated on 19-apr-2013. See bottom of page


LESS CSS is a pre-processor for CSS that provides lots of added functionality to plain ol' CSS. For more info visit the LESS website.
Here is a brief description of what it does:
LESS extends CSS with dynamic behavior such as variablesmixinsoperations and functions. LESS runs on both the client-side (Chrome, Safari, Firefox) and server-side, with Node.js and Rhino
There is also a LESS plugin for Netbeans.


CSS and JS minify is the process of compacting CSS and JS files, in order to speed up page loads.

While there are lots of different ways of minifying CSS and JS files, I needed one that was simple to use and that was available on my dev PC.

I have combined a number of tools and have come up with the following solution that:
  • compiles LESS files into CSS, if the LESS files are newer than the corresponding CSS.
  • minifies the CSS files into .min.css if the CSS files are newer than the .min.css files.
  • minifies the JS files into .min.js if the JS files are newer than the .min.js files
The above is achieved by simply visiting a page on the local development PC. Every time the page is visited it executes all of the above.

For PHP projects, the dir structure could be as follows:
- <project root>
- - styles
- - scripts
- - LESS
- - etc

A LESS.INI file specifies which directories to process for JS and whcich for LESS and CSS.

The LESS directory contains the compile.phplessc.inc.phpcssmin-v3.0.1.php, Minifier.php and LESS.ini files. See download links inside the compile.php  sourcef file.

Compile.php is the one that does all the work.

While developing an app, I have a browser window open that points to
<project root>/LESS/compile.php.
Whenever I refresh it, all of the above actions are executed.
Magic!


Here is a link to the complete source of the version that I use.

Updates

Link and source updated on 19apr2013:
It also checks inside LESS files for @import statements and uses that to determine if the main LESS file needs to be recompiled.
- The LESS compiler emits more info in error messages


ps: Comments and/or links to this article are most welcome!

Thursday, August 30, 2012

How to use PostgreSQL with WAMP server

Assuming you have installed PostgreSQL and your WAMP installation is on c:\wamp, you will need to copy
c:\wamp\bin\php\php5.3.9\libpq.dll   to   c:\wamp\bin\apache\Apache2.2.11\bin

Make sure you also have the following files
C:\wamp\bin\php\php5.3.9\ext\php_pdo_pgsql.dll   and
C:\wamp\bin\php\php5.3.9\ext\php_pgsql.dll

Also, make sure you have enabled the above 2 files as extensions, either via the WAMP menu (click on WAMP icon on taskbar, PHP, PHPExtensions, find the above 2 and 'check' them)

Please note that php5.3.9 and Apache2.2.11 refer to my specific PHP and Apache versions.
Adjust those to suit your installation.  

That's it!


ps: Comments and/or links to this article are most welcome!

Thursday, August 9, 2012

Save any web page as PDF, without plugins... in Chrome

(I have only tested this in Chrome)

When viewing the page you want to save as PDF, simply press Ctrl-P and, from the printer list (Destination) select 'Save as PDF'.

That's it!


ps: Comments and/or links to this article are most welcome!

Wednesday, July 25, 2012

More IE6 info

This site has some great info on IE6 hacks, as well as links to yet more info!


[It would be a pity to find one day that the above link no longer works and all that info is gone.
I have thought about it and have decided to copy/paste the contents of that page below, in case that happens.
Wikidot.com has released this content under the following licence, which allows sharing.
]


IE
<!--[if lt IE 7]>
    <style type="text/css">
    </style>
<![endif]-->
IE, up to and including version 7, always use the nearest positioned ancestor to determine the stacking context for the element in question (what happen if a parent element has position:static explicitly?). IE7 treats the value 'auto' as 0 (zero) (a new stacking context is established?).

The 'select' element always appear above all other content by default, regardless of z-index. Their stack level can't be changed. Use iframe shim


Flash content will display above all other content by default, regardless of z-index. To work around this, explicitly set the flash window-mode to the default option of 'opaque', or use the iframe shim


The iframe shim works for the 'select' element, and most kind of embedded media content (flash)


IE (without a doctype), the declared height and width does include padding and border.


Avoid CSS expression if possible. CSS-expression is only available in IE 5 - 7. Microsoft removed it from some version of IE8. It can be used to emulate some CSS properties that IE does not support: position:fixed, max-width, max-height, min-width, and min-height. Here is the basic usage:
p {
    width:expression(some javascript code);
}

To use CSS-expression to emulate position:fixed in IE6:
#fixed {
  position:absolute;
  left: 10px;
  top: expression(body.scrollTop + 50 + 'px');
}

CSS expressions allow a web author to hook script expressions into the dynamic nature of HTML elements. The natural events of the page (onresize, onclick, onmouseover and so on) causing these expressions to be re-evaluated whenever content could possibly reflow. Once IE encounters the expression construct it binds the code directly to the object. If you use any fancy DOM work to disable either the entire stylesheet (stylesheet switching) or just to kill a single element, it won’t work as the expression is already bound to the actual elements.

If you try to apply the max-width to an element whose own width is dependent on the elements contained within. Reflowing content causes the onresize event to fire, which in turn may cause an infinite loop.

IE8 supports CSS expressions only if run in "compatibility" mode, but it does not support them in "standards" mode. If you do not need to maintain backwards compatibility with older versions of IE, you should convert any instances of expressions used in place of standard CSS properties to their CSS standard counterparts. For a complete list of CSS properties and IE versions that support them, see the MSDN CSS Attributes Index. If you do need to support older versions of IE in which the desired CSS properties are not available, use JavaScript to achieve the equivalent functionality.

If you are using CSS expressions for dynamic styling, it makes sense to rewrite them as pure JavaScript to both improve performance in IE and get the benefit of supporting the same functionality in other browsers at the same time.

IE support something called CSS expression. A lot of time, people use it to address CSS incompatibilities across browsers. An expression is just a javascript expression that IE will execute and the result is set as the CSS style. In this case, here is a way to get around the lack of support for CSS min-width in IE. You can say that when this expression is evaluated, look at the body width, if it is less than 600 pixels, set it to 600 pixel, otherwise set it to "auto". They problem is that CSS expressions are executed many more time than you expects. They are execute everytime you move the mouse around the page. If you have this expression, during the typical user interaction with the page, the expression is executed between 10 to 50 thousand times, so if you aren't aware of that and you've done a little heavy in your javascript, it can really impact the load time of the page. There are way to get around it. If we have a one time expression, it only has to be evaluated once during the lifetime of the page, we can do a one time expression where the evaluation of the expression overwrite itself. Or we can write an event handler. As in the case of min-width, rather than using an expression, add an event handler to the resize event. That what make CSS expression easy. They are tie to events automatically so that you don't have to worry about that. But that is what is bad about them. They are tied to all the events, so they are executed all the time. So do the heavy lifting yourself, figure out which event you need those expression to be evaluated against, and tie it to those events.


A div with position:absolute acquires display:inline. To get around this issue, always explicitly set the position of the div using either (top, left), or (bottom, right), or try adding zoom:1


Use conditional comment to fix these IE-specific issues. Use conditional comment so that your CSS can be validated. Also readTarget every version of IE from a single stylesheet (before using this technique, we need to see what Google Page Speed says about descendent selectors)


The box model bug: Explorer 5 for Windows does not support the W3C box model. Explorer 6 does,
but only in Strict mode. In W3C box model, when we declare the width of an element, we are declaring the width for its content area. This does not include border, and padding.** In IE box model, when we declare the width of an element, we are declaring the width of the entire element. This include the width of the content area, border and padding. The fix (most of the time) is to include proper DOCTYPE. If that does not work (for example, you have to support IE 5.5), then use the simplified box model hack (the Tan hack, named after Edwardson Tan):
* html div {  /* This is the Tan hack */
  width: 130px;
  w\idth: 100px;
}

The star at the beginning of the selector is the universal selector, which applies to all elements. "html" is supposed to be the root element. All versions of Internet Explorer seem to believe that there is a mysterious "wrapper" element surrounding "html". The selector in question (* html div { }) picks out any div that is enclosed (however deeply) inside "html", if "html" is enclosed in any element whatsoever. IE thinks that the star refers to this "wrapper", and then sees that yes indeed, "html" is enclosed inside it. Only IE believes this condition exists.

However, all other browsers see "html" as the true "root" element, and so the star can't refer to any real element. This causes all non-IE browsers to ignore all rules following that selector. Thus, the entire Tan hack is totally invisible to all browsers except Internet Explorer.

In the hack selector, the star and "html" parts are required, but the div I gave as an example would, in practice, be replaced by the element to be targeted. Instead of "div", it could be "p", "ul", ".myclass", or whatever you need. It is best to be as specific as possible in order to target only those elements that require different values.

The w\idth: 100px; is for IE6 and IE5.5 on mac. It turns out that IE5.x/win cannot handle any property name having such an escape within it, but IE6 and IE5/mac correctly ignore the escape.

The escape character must be inside the property name (whatever that may be), and it must not come just before any of the first six alphabetical characters, meaning: a, b, c, d, e, or f. If this is done it will be interpreted as a "hex" character, messing up the hack. Luckily, all property names have at least one suitably "escapable" character.

The Tan hack does its job well and won't cause trouble for with version 5 and above browsers, but IE4.5/mac may have trouble with it. You will need to test to be sure.

If IE6 is in quirks mode it will be using the old box model, and will need the same "width" value that IE5.x/win does. However, IE6 will still not be fooled by the escape, and will read the escaped value, thus defeating the hack, and rendering a smaller than desired box. Make sure the doctype you use puts IE6 in "standards" mode.

Using an <?xml…?> declaration at the top of the document, while recommended for some doctypes, will wrongly throw IE6 into "quirks" mode. It is not required, so be careful if you use the declaration, and test thoroughly! (See the Rendering Mode and Doctype Switching article at CMX for more on this topic.)

If your page must be in "quirks" mode for some reason, doing something different with the Tan hack may be necessary. First, the Tan hack is modified by removing the second value (the one with the escape in it). That way IE6 gets the same value as IE5.x/win. But now IE5/mac (which does not go into "quirks" mode) will also use that value, and get it wrong. So, to hide the Tan hack from IE5/mac, do the following:
div {
    width: 100px;
    padding: 10px;
    border: 5px solid black;
    margin: 10px;
}

/* A CSS comment before the hack \*/
* html div {
    width: 130px; 
}
/* Another CSS comment after the hack */

Look at the top comment. See that escape just before the closing tag? Because of that escape, IE5/mac fails to recognize the closing tag, and so fails to read the entire Tan hack. The second comment below the hack provides a closing tag for IE5/mac's benefit. In this way, IE5/mac reads only the value in the normal code block before the hack. This Mac hack, called the Commented Backslash hack, was discovered by Sam Foster. Version 2, the one we're using here, was suggested by James Craig.

For detail explanation of the Tan hack, refer to The Box Model Problem


The double margin bug. Let’s say we need that floated to the right, IE 6 will double its margin. The commonly thrown-around “fix” for this is to add “display: inline;” to the div. Side-step this bug whenever possible. If you really need to push that box away from the right side of it’s parent element, you can likely do so by adding padding to the parent element. This bug does not affect padding, so you can offen get away with adding padding to the side you need an achieve the same result. "display:inline" only causes IE6 to not double the margins, the elements are still rendered as blocks – it’s a bug to fix a bug. "display: inline-block" also works. It basically combines both inline and block displays, meaning the element is still inline, while allowing the block level style of padding, fixed width, and such. “display: inline;” works to eliminate the double-margin bug because floated elements, by their nature, are block-level elements. doesn’t matter if “display: inline” is applied to that element. modern browsers simply ignore such non-sense, but ie 6 understands it. Also, all floated elements should have a declared width.


Some elements disappears when you interact with something on the page (we cannot position something over certain elements). I was using the coolframe menu system. When I mouseover a menu, my select elements disappear. The coolframe menu hide the select elements because the select element is special. Later version of the coolframe menu use the iframe hack(put an iframe on top of the select element), but it still appears as though the select element somehow disappeared. Better solution may be:
  • make sure that the select elements are not in the way of the menu
  • do not use the normal select element (use a jQuery plugin or another javascript library / plugins that simulate the select element)
  • only use the iframe shim if we need to hide the select element (we need to determine which select elements need to be hidden based on their position)
Explorer for Windows does not support the child selector (>), the adjacent sibling selector (+) and the attribute selector (p[class]).


Explorer for Windows does not support the :focus and :first-child pseudo-classes.


Explorer for Windows does not support the W3C definition of background-attachment: fixed on elements other than the <body>.


IE does not support min-height and min-width. IE6 does support min-height declaration on <td>s in tables with table-layout: fixed (which, in turn, is not supported by any other browser).

IE 6 does not support min-height and min-width. Fortunately, IE 6 treats the regular height property like modern browsers treat min-height.

Min-height is incredibly useful for something like a footer. Say your footer needs to be at least 100px tall because you are using a background image down there, but you don’t want to set a static height because you want it to grow nicely if, say, the text size is bumped up significantly. Min-height is perfect for this, but using it alone will get you no height whatsoever from IE 6. In a bizarre twist of luck, IE 6 treats the regular height property like modern browsers treat min-height. See also Maximum and Minimum Width Solution for All Browsers


IE 6 does not support max-height and max-width. See max-width in Internet Explorer and Maximum and Minimum Width Solution for All Browsers


IE 6 involuntarily cause "stepdown" on floated block element. Normally when floating objects you can count on them lining up vertically until they run out of horizontal space, at which point, the floated elements will wrap / stepdown. IE 6, however, appends a line break effect after each floated block element which will cause involuntarily “stepdown”. The fix is to make sure the line-height in the parent element is set to zero (0), or that the elements being floated are inline elements. See preventing stepdown. If this does not work, try setting zoom:1 on the parent element


No hover state. IE 6 only support the hover pseudo-class on anchor (<a>) elements, and even then you don’t get them if your anchor doesn’t have a href attribute. The solution here is to wrap the element in an anchor (<a>) tag, use a proprietary fix, or just deal with not having hover states on everything you want.


No alpha-transparent PNG support. Regular non-alpha transparent PNG files work fine without any fix in IE 6, and are often better than their GIF sisters. See different t echniques for applying the PNG hack. Consider using PNG8. IE6 can't deal with alpha transparency in PNG 24


No support for position:fixed. IE6 does not have support for position:fixed.

Simulate position:fixed using javascript. Instead of using CSS expression, use some sort of onscroll
handler. Instead of using position:fixed, change it to position:absolute. Register these elements in an array, and then the onscroll handler move these elements as the page is scrolled. We may need to remember the position of each elements, or the previous scroll position. The onscroll handler remembers the previous scroll position, compute the delta, and apply the delta to these elements.

Eric Bednarz has found a pure CSS solution to this problem, but technically it can be tricky. For instance, when you use his fix you cannot use position: absolute normally. Read his page well if you want to implement his solution.


IE6 incorrectly trigger the onresize event handler. See http://blog.stchur.com/2006/09/06/the-ie-resize-bug-revisited/


IE6 has an issue with Flash and HTTPS (no-cache headers are used):
http://kb2.adobe.com/cps/000/fdc7b5c.html


IE6 cannot deal with compress content
DOCTYPE does not work with document.body.clientHeight. See Get viewport size (width and height) with javascript, and Why DOCTYPE affects document.body.clientHeight


DOCTYPE does not work with document.body.scrollTop or element.scrollTop. This is the same issue with document.body.clientHeight. Use document.documentElement.scrollTop instead. Also, scrollTop only seem to work on elements for which overflow is declared.


Problem with floated inline element. Floated elements, by their nature, are block-level elements. Therefore, this is not a problem with IE. This is a problem with your code. Either change the element to block-level elements, or consider using absolute positioning.


Problem with in-ability to have very small height. (I ran into this problem when I was trying to create a line going across the page using a DIV. This did not work for IE6, and so I had to use the <hr> element which looks thicker than I wanted.) IE simply refuses to size an element smaller than the set font size. Simply setting the font size to 0 lets you have an element as small and short as you like:
  #element{  
     border: solid 1px #36F;  
     height: 1px;  
     font-size: 0;  
 }

Another way to deal with this problem is to set overflow:hidden so it collapses to the intended height.


Problem with checkboxes displayed out-of-place when they are inside a ul element. This is specific to IE-7. To work around this issue, assign position:relative on the ul element.


Problem with text-indent. Do not use text-ident. Use margin, padding, or border to achieve the same effect.


Problem with xml prolog: Avoid the unnecessary ?xml prolog. 20020404 Prerit Bhakta noted that if you include the ?xml prolog:
<?xml version="1.0"?>

then IE6/Windows uses the quirky box model. Since the ?xml prolog is unnecessary, omit it.


Problem with position:relative elements overflowing its container. This bug rears its ugly head when in a layout you set the parent container’s overflow property to auto and place a relatively positioned item inside it. The relatively positioned item violates its parent element’s boundaries and overflows outside. The easiest way to fix this annoying bug is to just position the parent element relatively too.


Problem with space between list items. IE 6 adds vertical spacing even none is specified. See the last bug on 9 Most Common IE Bugs and How to Fix Them for detail. An easy solution is to float the list items left, and clear left:
float:left;
clear:left;


Problem with floated elements and overflowed content. If you've got two floated elements and the content from the left container overflows then, in IE, the container grows and inevitably pushes the right container below it. This is usually a sign that you've messed up your margins, widths, or padding on one of these containers but Firefox (et al) won't reveal this. Using something like overflow:hidden or overflow:scroll on a container can help prevent IE from allowing the content to push the width of the container but you're better off trying to fix the issue in the design.http://www.snook.ca/archives/html_and_css/top_css_tips/


Problem with IE6 displaying blank page if the page specify a character set UTF8:

If a page specify a character set UTF8 via a meta tag (the page has a valid DOCTYPE), IE6 will display a blank page. This problem may also be caused by the no-cache meta tag.


IE6 collapse block level element if we do not define height, but we define overflow (either auto or hidden or whatever). Use "zoom: 1" in your ie6.css


IE triggers HTTPS warning if we have an iframe or an img tag that we forget to specify the src attribute.


IE triggers HTTPS warning if we have CSS background null


IE6 does not understand attribute selector. And if we combine selectors, the attribute selector break other selectors as well.

**IE6 and 7 only support inline-block for elements that are natively inline. Luckily, in IE, elements that have layout and are inline behave as inline-block elements. The initial value for vertical-align is baseline. If you want your blocks to be vertically aligned on their center, use vertical-align:middle.


Missing borders. Sometimes, the solution will consist of adding a margin, just for IE, around the box that has the border, or around the parent element, or making the element behave like an inline-block:
*display: inline;
*zoom: 1;


Invalid argument. Here are the known cause of this frustrating error:
  1. If a DOM attribute is of type number, say colspan, then setting colspan="something" (or more exactly myTd.colSpan = "something") cause this error.


Problem with JSON: Given a JSON object:
{
    name1: value1,
    name2: value2,
    name3: value3,
}

IE will results in a javascript error. This JSON object works fine Firefox. If you use SpiderMonkey to check the syntax, SpiderMonkey does not detect this as error.


The best way to deal with these incompatibilities is to make sure that the correct layout of your page doesn't depend on them. If you use these problematical selectors and declarations not for fundamental CSS declarations but only for nice extras, you can ignore Explorer for Windows' incompatibilities. For instance, the :focus pseudo-class allows you to define a style for a focused form field. Although this extra style is nice to have, your page can do without it. Therefore you can safely use :focus and ignore Explorer Windows' lack of support.

You could use the famous Box Model Hack, or you could decide the minor differences aren't worth the trouble. Fluid thinking can solve many problems, not by hacking your way through browser incompatibilities, but by embracing a different, more web-like way of thinking.


Sites that document IE-specific bugs:
JavaScript in Internet Explorer 8
Simulating fixed positioning in IE6
Defining Document Compatibility
PIE makes Internet Explorer 6-8 capable of rendering several of the most useful CSS3 decoration features
Internet Explorer In A Web Designer’s Life – Problems And Solutions
HTML5 elements in Internet Explorer without Javascript.
Cross-Browser Compatibility with CSS3
CSS3 selectors for IE
Modernizr
HTML5 Cross browser Polyfills
CSS3 Compatabilty Tools, Resources and References for Internet Explorer
http://www.catswhocode.com/blog/10-ways-to-make-internet-explorer-act-like-a-modern-browser
CSS Enhancements in Internet Explorer 6
How Internet Explorer 8 document mode affects JavaScript
How To Attack An Internet Explorer (Win) Display Bug
http://www.communitymx.com/content/article.cfm?page=2&cid=C37E0
Boxpunch
CSS Enhancements in Internet Explorer 6
About Conditional Comments
Recap of Compatibility View
The IE/Win Disappearing List-Background Bug
Explorer 6 Duplicate Characters Bug
Browser-compatibility Issues
Min-Height Fast Hack
Space between list items in IE
Cross-Browser Transparency via CSS
Cross-Browser Variable Opacity with PNG: A Real Solution
Clearing floated images in body text
Ultimate IE6 Cheatsheet: How To Fix 25+ Internet Explorer 6 Bugs
Quirksmode
How to resolve browser compatibility issues while working with JavaScript, AJAX and XML
IE6 Peekaboo Bug
Internet Explorer vs. the Standards
Explorer Exposed!
Ultimate IE6 Cheatsheet: How To Fix 25+ Internet Explorer 6 Bugs
Flash of Unstyled Content (FOUC)
The simplified box model hack (IE5)
Overflow problems in Internet Explorer
Internet Explorer 6 and the Expanding Box Problem
Fix IE7 scrolling background problem in textarea form fields
10 ways to make Internet Explorer act like a modern browser
Fix IE7 scrolling background problem in textarea form fields
http://www.thebrightlines.com/2009/11/27/filtering-ie6-and-ie7-in-quirks-mode/
http://www.456bereastreet.com/archive/200612/internet_explorer_and_the_css_box_model/
Definitive Guide to Taming the IE6 Beast
http://blogs.msdn.com/ieinternals/archive/2009/08/20/WinINET-IE-Cookie-Internals-FAQ.aspx
http://net.tutsplus.com/articles/news/ie9-may-actually-be-a-great-browser/
http://blogs.msdn.com/ie/archive/2009/11/18/an-early-look-at-ie9-for-developers.aspx
http://msdn.microsoft.com/en-us/ie/ff468705.aspx
http://www.guardian.co.uk/technology/blog/2010/mar/16/internet-explorer-9-preview-microsoft
http://www.readactor.com/tutorials/ie-javascript-onmouse-event-fix/
http://www.howtocreate.co.uk/fixedPosition.html
http://www.codeproject.com/KB/applications/IE_dev_toolbar.aspx
http://msdn.microsoft.com/en-us/library/dd565628(VS.85).aspx
http://crisp.tweakblogs.net/blog/318/editcss-for-internet-explorer-concept.html
http://www.15seconds.com/Issue/070208.htm
CSS opacity filter syntax for IE8
IE and DOMReady bug
Kick-ass CSS3 Support in IE6, 7, and 8
HTML5 Way Around For IE
How to use RGBA() in IE
Got IE6?
Did Internet Explorer get the Box Model Right?
Internet Explorer Select Width Bug Workaround
Coding for IE6 = Progressive Enhancement
Enhanced Scripting in IE9: ECMAScript 5 Support and More
IE’s big leap forward; CSS3 selectors fully supported
Fixing HTML5 Loaded Via Ajax in IE
More IE9 goodness and elementFromPoint()
IE-only Styles: Where Should They Be Placed?
How To Attack An Internet Explorer (Win) Display Bug
Absolutely Buggy II
Box Model Hack
Fluid thinking
Browser Compatibility Development Guide
Commented Backslash MacIE5 CSS Hack - v2




ps: Comments and/or links to this article are most welcome!

Friday, June 29, 2012

Calculate AUS taxes in GoogleDocs spreadsheet

The following custom function will calculate the tax that needs to be paid for any given salary, for FinYear 2011-12.


function australianTax2011_12(grossSalary) {
var tax = 0.0;
if (grossSalary > 180000) { 
      tax = 54550 + ((grossSalary - 180000) * 0.45); 
 } else if (grossSalary > 80000) { 
      tax = 17550 + ((grossSalary - 80000) * 0.37); 
 } else if (grossSalary > 37000) {
      tax = 4650 + ((grossSalary - 37000) * 0.30); 
 } else if (grossSalary > 6000) {
      tax = 0 + ((grossSalary - 6000) * 0.15); 
 } 

 return tax; 
}

This was created in a couple of minutes, so that I could simply call a function and get the tax figure straight away, instead of doing arithmetic gymnastics in the spreadsheet.
It is not elegant or optimised for speed, size, anything.


Follow the instructions in here on how to create a custom function.

Example use in a cell:   =australianTax2011_12(37000)


Use at own risk! 
I will not be responsible for any erroneous results.




ps: Comments and/or links to this article are most welcome!

Wednesday, June 20, 2012

How to install FreeNas to run from a USB stick, Proliant N40L

You will need the following tools

- A zip extractor, such as WinRAR, WinZip or 7zip

- PhysDiskWrite (at this time, it is physdiskwrite 0.5.2.zip)
This allows you to write the disk image to the USB stick

- The FreeNas ISO image. 
In my case, I downloaded FreeNAS-8.3.0-RC1-x64.img.xz 
This is the newest version at this time. You may find a newer version. 
The important bit is to download a full install version and not an *update*.
For example, do not download FreeNAS-8.3.0-RC1-x64.GUI_Upgrade.xz


1) Create a temp directory, say C:\dooda

2) Extract the contents of physdiskwrite 0.5.2.zip into c:\dooda

3) using your favourite zip extractor, extract the contents of the FreeNas XZ image into c:\dooda

4) rename whatever came out of the XZ file into something simple, say FreeNAS.img.

5) Open a command prompt (as administrator) in c:\dooda

6) type physdiskwrite.exe -u FreeNAS.img and look very carefully at the displayed results. In my case, I see the following
physdiskwrite v0.5.2 by Manuel Kasper <mk@neon1.net>
Searching for physical drives...
Information for \\.\PhysicalDrive0:
   Windows:       cyl: 14593
                  tpc: 255
                  spt: 63
Information for \\.\PhysicalDrive1:
   Windows:       cyl: 243201
                  tpc: 255
                  spt: 63
   C/H/S:         16383/16/63
   Model:         ST2000DM001-9YN164
   Serial number:          
   Firmware rev.: CC4C
Information for \\.\PhysicalDrive2:
   Windows:       cyl: 981
                  tpc: 255
                  spt: 63
Which disk do you want to write? (0..2)  2  
WARNING: that disk is larger than 2 GB! Make sure you're not accidentally
overwriting your primary hard disk! Proceeding on your own risk...
About to overwrite the contents of disk 2 with new data. Proceed? (y/n) y
You need to decide which of the drives shown is the one to dump the FreeNas image on.
Whatever drive you select will be totally overwritten. Totally!
Select carefully!

I can see that drive 2 is the smallest drive (8GB), i.e. my USB stick, so I enter '2' and press ENTphydER.

Please note that there mustn't be any partitions at all on the USB stick.
If there are, you will get an error complaining that it failed to write after 0 bytes (or some such).
To completely empty the USB stick, do the following
1) Open a command prompt (but do so as an admin)

2) Enter diskpart

3) Enter List disk
(this will list your disks and allow you to find the drive number of your USB stick)

4) Enter Select disk N         
(where N is the disk number of the USB stick. See screen dump and notes above)

5) Enter Clean

Done!

You can now install FreeNas on your hardware by booting on your newly-created USB stick.

In my case it is an HP Proliant N40L.
I have updated its BIOS as described in this article.
FreeNas v8 tips and tricks can be found here.
How to mount an external USB disk


Enjoy!


ps: Comments and/or links to this article are most welcome!

Thursday, May 17, 2012

Internet Explorer 6 hacks, fixes etc

If you are unfortunate enough to have to support Internet Exploder (euphemistically known as Internet Explorer), that piece of garbage that MS inflicted on the world, here are some useful links that will help you.
IE7.js, IE8.js and IE9.js are JavaScript libraries to make Microsoft Internet Explorer5/6 behave like a standards-compliant browser. They fix many HTML and CSS issues and make transparent PNG work correctly under IE5 and IE6.

Visit this site for some interesting reading on the above scripts and the (then) imminent release of Internet Exploder 7

Wednesday, May 2, 2012

Monitor your Website’s Uptime with Google Docs

Here is a great GDocs script that will email you when your site goes down/up.

http://www.labnol.org/internet/website-uptime-monitor/21060/

Follow the instructions in the author's page and you will end up with your own copy of the script.
If you want to email multiple recipients instead of just the one, here are the changes I made to support that:

from line 47 onwards:

ScriptProperties.setProperty("status", code);

var recipients = email.split(";");
for (r in recipients) {
if (recipients[r] != "") {
MailApp.sendEmail(recipients[r], msg, error);
}
}
// end of code changes

Many thanks to the author +Amit Agarwal


ps: Comments and/or links to this article are most welcome!