Swift func to show alert dialog in AppDelegate or ViewController

Was trying to show an alert dialog in a project’s AppDelegate.swift and ViewController.swift and decided to move it to a function in a separate utility class. Main issue was how to make it work as the class was a plain Swift class – self.present() could be used inside ViewController, self.window?.rootViewController?.present() could be used inside AppDelegate, …

List tables with table size in MySQL

The following query will list the top 5 tables by table size in MySQL. SELECT TABLE_SCHEMA, TABLE_NAME, CEIL((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS table_size_in_MiB, TABLE_ROWS AS estimated_row_count, AVG_ROW_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN (‘information_schema’, ‘innodb’, ‘mysql’, ‘performance_schema’, ‘phpmyadmin’, ‘sys’, ‘tmp’) ORDER BY table_size_in_MiB DESC LIMIT 5; Note that TABLE_ROWS is only accurate …

Print QR code to network-enabled thermal receipt printer using Java

For more information on the ESC/POS command set which receipt printers use for printing, see What is ESC/POS and How Do I Use It by Michael Billington, also the author of the excellent escpos-php PHP library for receipt printers. Thanks to this StackOverflow post as well: printing QR codes through an ESC/POS thermal printer? 🙂 …

Print Chinese text to network-enabled thermal receipt printer using Java

For more information on the ESC/POS command set which receipt printers use for printing, see What is ESC/POS and How Do I Use It by Michael Billington, also the author of the excellent escpos-php PHP library for receipt printers. Steps to run: Save the code below as NetworkReceiptPrinter.java – change printer IP accordingly. Run javac …