Render checkbox list with initially checked items in Yii2

This guide shows, how to (in Yii2) render checkbox list with correctly selected items (preselected during form render), using both HTML helper classes and active form approach.

This is an extended version of this Stack Overflow question and an answer following it, plus some additional information from me and from other sources.

Read More “Render checkbox list with initially checked items in Yii2”

Chained, AJAX-updated listboxes in Yii2

There’s a great answer at Stack Overflow that shows, how in Yii2 you can implement a form containing listbox and two input fields. Listbox contains data from one model and when user selects any option, remaining two input fields should be populated with relevant values from related model.

I wrote an extended version of this code. It populates two other listboxes instead of just input fields. And it uses a little bit less deprecated code! :>

Read More “Chained, AJAX-updated listboxes in Yii2”

Portable Storage vs Internal Storage in Android 6.0 Marshmallow

Differences: Motorola Support.

Card is encrypted and not accessible outside given device. Thus, for example, you can’t take it off, connect it to your computer and copy files that way, in case you couldn’t do this via USB cable (due to completely poor MTP protocol). For the same reason, if Android fail to recognise your SD card (happens awfully often under 6.0 Marshmallow) then you can’t access your files (i.e. download your pictures etc.) at all.

For security reasons (right!) card is encrypted, but for some strange reasons sometimes Android doesn’t work to well with its own encryption. This means that sometimes your files may become simply broken.

I had this problem with MP3 ringtones. From one day, without any particular reason, my phone started to emit some sound garbage as ringtones instead of my favorite songs. Quick analysis proven that poorly supported encryption plus even more poor MTP protocol plus broken connection between PC and Android resulted in files being broken.

Failures: Quora.

Git diagram for data transport commands

If you’re unfamiliar with data transport commands in Git or have troubles understanding the idea of four “buckets” (workspace, index, local repository and remote repository) or you’re generally a newbie to Git, then there’s a great answer at Stack Overflow, which basically is a diagram image taken from Oliver Steele’s blog and that actually explains everything! :>

Read More “Git diagram for data transport commands”

Changing Yii2 application’s configuration at runtime

You can’t use Yii::t() method inside Yii2 application’s configuration, right?

I mean… you can use it (application won’t fail), but you will always get string passed as method’s param in return, instead of actual translation, no matter, what language is currently set in your application.

This makes “How to translate application title (or any other configuration parameter)” a quite good question.

Read More “Changing Yii2 application’s configuration at runtime”

Media supported by Samsung 50HU6900 4K TV

Three months ago I have purchased my first 4K / UHD TV — Samsung 50HU6900 — and after some time I tried to used the built-in media player to play some of my files. At the very end it turned out that — as in all Samsung devices — this is a piece of crap, full of some strange limitations. Finally, I have reverted back to my old, good standalone FHD player and I’m using Samsung one only for UHD / 4K files.

But, for all of you, that aren’t so reluctant, here is a list of media supported by this TV (and probably many more Samsung TVs) and all the limitations, you need to fulfill in order to have your media played.

Read More “Media supported by Samsung 50HU6900 4K TV”

Create a loop in a stored procedure to insert many rows with random data

A solution based on this Stack Overflow answer to insert many random data rows to given table in SQL:



        DECLARE i INT;
        SET i = 1;
        WHILE i <= NumRows DO
            SET @dn = CONV(FLOOR(RAND() * 99999999999999), 20, 36);
            INSERT INTO `devs` VALUES (NULL, FLOOR((RAND() * 3)), CONCAT('Dev ', @dn));
            SET i = i + 1;
        END WHILE;

To execute this little piece just call:

CALL InsertRand(77);

That’s all folks! :>