Search

Tutorials, tips&tricks, snippets..

#KISS: KEEP IT SIMPLE, STUPID!

Author

preruz

Create an iOS certificate and use it on build.phonegap.com

You can create a multiplatform app with Phonegap. At https://build.phonegap.com you can also compile the app and generate ipa/apk files. If you want, of course, to publish it on iTunes/Google Play you have to use a certificate. Here, how to create&use an iOS certificate.

Continue reading “Create an iOS certificate and use it on build.phonegap.com”

Advertisements

C# core: how to generate a pdf from a html with a xsl stylesheet as base64 stream

My goal was to create a base64 string representing the pdf, then send it to my mobile app and show it to the user (here for more info).

The following code is written using the Select.HtmlToPdf.NetCore package.

Continue reading “C# core: how to generate a pdf from a html with a xsl stylesheet as base64 stream”

Download&open a pdf base64 encoded in Android/iOS cordova/phonegap app

In my app, I need to download a pdf file from my api (base64 encoded, here how to create it), convert it and finally open it. Here how I made it.

Continue reading “Download&open a pdf base64 encoded in Android/iOS cordova/phonegap app”

String replace in SQL Server database table

Here a fast snippet

update my_table
set path = replace(path, 'oldstring', 'newstring')

If useful, you can also set a where condition.

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.
    if(pending) 
        return;

    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 date.day 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?”

Powered by WordPress.com.

Up ↑