Android provides two ways of sending SMS using SDK. First of them is to use Intent library with proper configuration to use system’s messaging application. The second one is to use the SmsManager, what allows us to send SMS without any further question and confirmation. Let’s consider the latter one. Read More »
Backup all MySQL databases into separate compressed files
The easiest way of making backup is to use mysqldump, but it may not be as easy as it seems. Although there is a flag –all-databases, it results in dumping everything into a single file.
Let’s consider the following situation: you want to make automatic backup of each database on the server into the separate, bzip2 compressed file named with the date; and you want to store backups only for 7 days. Sounds a bit challenging?
Read More »
Adding rows to a TableLayout during the runtime
Have you wondered how to create dynamic table in Android? It’s not really a hard thing to do, it just requires a XML template and some code in Java… shall we? Read More »
Scrollable content on the screen
If you are not very familiar with all kinds of layouts and views used in Android, there is a great chance that (as me) you didn’t know about ScrollView and you have been wondering how to make content (i.e. of a table) scrollable. The basic layouts and structures do not support scrolls and once the table/list/whatever goes below the screen, its content just cuts off. Read More »
DOMDocument and wrong output encoding
Have you ever used DOMDocument class to analyze HTML structure of a random page (i.e. retrieved by cURL or something) loaded by loadHtml() method? Have you ever had difficulties with displaying national letters (diacritics) from analyzed content?
It may occure when charset of the page was placed after the tag you tried to analyze (i.e. <title> before charset in the <head> section).
Ironically1, if you process UTF-8 pages, DOM methods may return output with encoding different from input’s one. I admit I lost some time myself to find out what the problem was and trying to fix it. The easiest (and only that worked for me) way of fixing this issue is to use mb_convert_encoding() function. The code goes as follows:
// some code here $dom = new DOMDocument(); $encodedPageSource = mb_convert_encoding($basicPageSource, 'HTML-ENTITIES', 'UTF-8'); $dom->loadHTML($encodedPageSource); // some code here
Thanks to such convertion the arbitrary Unicode characters are inserted.
1 – the irony is DOMDocument only supports UTF-8
It has begun!
Hello there and welcome on my little blog. Hopefully it won’t be little for much longer and you will find it helpful in real life problems related to its main topic – (web) development and (web) programming.
This is actually my very first blog of any kind so forgive me a lack of experience and grammar failures that may and will occur (however I’ll be grateful for pointing them all
). But first things first – this blog has one purpose, and one purpose only: to store information. To store useful information, tutorials and other kind of materials necessary for people who’d like to start (or have already started) their journey as (web) developers – mainly Facebook (Graph API with PHP/JavaScript) and Android (Android SDK) but other stuff may also be found in the future.
Enough with the foreplay. Enjoy being here!