I enjoyed reviewing 10 Popular PHP frameworks in 2020.
Category Archives: Programming
HTML forms
Found a cool series of articles: How to Build HTML Forms Right. Only the first two of five articles have been published so far, but I’m looking forward to the next three. The articles are about how to do forms right in HTML 5.
The articles are rich with links, click through for heaps of info. Some things that I found:
GRASP
Today I stumbled upon GRASP. I give it a 5 out of 10.
SQLite integrity check
To process an integrity check on an SQLite database:
$ sqlite3 database.sqlite 'pragma integrity_check'
mb_strimwidth
Today I learned about mb_strimwidth, very handy in a tight spot. It’s worth a review of the sidebar for other multibyte string options.
PHP Security Best Practices
I found an interesting article: Linux 25 PHP Security Best Practices For Sys Admins
php -d xdebug.profiler_enable=1
So to enable profiling on the command line run your script in PHP like this:
php -d xdebug.profiler_enable=1 /path/to/script.php
You need to have configured xdebug in php.ini, I do it with a file in /etc/php/7.2/cli/conf.d/xdebug.ini that looks like this:
;xdebug.profiler_enable = 0 xdebug.profiler_output_dir = "/tmp/xdebug" xdebug.profiler_output_name = "cachegrind.out.%p"
Note: you can enable profiling for all scripts with xdebug.profiler_enable = 1
Omitting date completed from MySQL dump file
By default when you run a dump with ‘mysqldump’ the date of the dump is appended to the file, e.g.:
jj5@love:~/desktop/experiment$ udiff * --- dbt__jj_dev_1__svn_jdrepo.1.sql 2019-06-11 18:11:13.267758230 +1000 +++ dbt__jj_dev_1__svn_jdrepo.2.sql 2019-06-11 18:12:03.856075974 +1000 @@ -32,4 +32,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-06-10 21:59:44 +-- Dump completed on 2019-06-10 12:06:49
This causes dumps for a single database that has not changed to have two dumps which differ. It’s better to have dumps from the same unchanged database to be the same. To facilitate that add the –skip-dump-date option when running ‘mysqldump’.
See here for the back-story.
Fixing character encoding issue in ViewVC
So I was having an issue with ViewVC wherein UTF-8 content (a copyright symbol) was being garbled in the web browser.
I chased a number of red herrings (Content-Type headers, http-equiv, XHTML vs HTML5) but eventually found the culprit in the viewvc.conf settings.
I needed to change the ‘detect_encoding’ setting from ‘1’ to ‘0’. Once that was done my content was presented correctly:
## detect_encoding: Should we attempt to detect versioned file ## character encodings? [Requires 'chardet' module, and is currently ## used only by the syntax coloration logic -- if enabled -- for the ## 'markup' and 'annotate' views; see 'enable_syntax_coloration'.] ## # 2019-06-02 jj5 - OLD: this was bollocksing things up... #detect_encoding = 1 # 2019-06-02 jj5 - NEW: so I changed it... detect_encoding = 0 # 2019-06-02 jj5 - END
Announcing numformat.php
So I was reading output from
/proc/spl/kstat/zfs/arcstats
and I couldn’t read it easily because the numbers weren’t formatted with thousands separators and I figured I could fix that…
I give you numformat.php. It automatically reformats any input that looks like a number…
There’s more info on the programming@progclub mailing list.