Tutorials, tips&tricks, snippets..


Round number keeping trailing decimals without using string

I need all values to rounded to 8 decimal places. So, for example, 1.2 should round to 1.20000000, but Math.Round(value, 8) rounds to 1.2.

I’m using a C# class to populate and then serialise to xml. One of the values is a double. If I assign a ‘1.2’ to the value this gets serialised to ‘1.2’ when I actually need ‘1.20000000’.

I found this fast way to do this without converting the number to string:

foo = doubleValue + 0.00M;

And that makes the value 1.20000000 instead of just 1.2. This was better then doing a ToString and then parsing it back.


Disable onClick after first click to avoid double (or more) clicks

In my app (but this is valid also for web app), I have a problem: if user clicks twice (or more), twice requests (or more) are sent to the API server. Here a snippet to avoid this behavior with useless requests.

var pending = false;

function Foo(param)
    // test to see if something else set the state to pending.
    // if so... return, we don't want this to happen.

    pending = true; // raise the flag!

    /* ... later ... */
    // in the success method of your AJAX call add:
    pending = false;

SQL Group By Date.Day

Another fast snippet: how to group by the from a date/datetime column.

select sum(amount) as total, dateadd(DAY,0, datediff(day,0, created)) as created
from sales
group by dateadd(DAY,0, datediff(day,0, created))

Convert a List<int> to a List<int?>

Here a very fast but useful snippet:

List<int?> nullList = myIntList.ConvertAll<int?>(x => x);

How to create expandable FAQ page in HTML?

I needed to create a simple FAQ page for my Phonegapp app. I found a lot of sample, but all of them were too complicated, I was searching for a simple one.

After a while, I found some useful examples and I put them together to create my FAQ page with HTML, CSS and Javascript.

Continue reading “How to create expandable FAQ page in HTML?”

Round button in HTML5 with CSS3

Quick snippet below: how to create round button in HTML5 with CSS3.
Continue reading “Round button in HTML5 with CSS3”

Where can I find the IIS logs?

Where does IIS7 store logs by default? Here:


JavaScript: add month to Date object

Here two simple snippets useful to add (or subtract) months to a Date object:

function add_months(dt, n) 
    return new Date(dt.setMonth(dt.getMonth() + n));      

dt = new Date();
console.log(add_months(dt, 10).toString());  

You can also create it as prototype, if you prefer:

Date.prototype.add_months = function(w){

var date = this;
date.setMonth( date.getMonth()+10 );

return date;


var date = new Date();
console.log( date.add_months(10).toString() );

Using European VAT Verification SOAP Service

EU created a service to obtain confirmation of the validity of the VAT identification number of any specified person. This service works with SOAP and can validate all the EU VAT. You just need to send the state code and the VAT.

Continue reading “Using European VAT Verification SOAP Service”

Powered by

Up ↑