Today I found Getting Started with PHP Extension Development via PHP-CPP which talks about what it says on the label. But then some more searching revealed a more direct alternative: How to Create a PHP C Extension to Manipulate Arrays – Part 1: Basic Array Class Extension
Category Archives: Programming
Knuth on reusable code
Today via Lobsters: APL Style: Patterns/Anti-patterns:
I also must confess to a strong bias against the fashion for
reusable code. To me, “re-editable code” is much, much better
than an untouchable black box or toolkit. I could go on and on
about this. If you’re totally convinced that reusable code is
wonderful, I probably won’t be able to sway you anyway, but
you’ll never convince me that reusable code isn’t mostly a
menace.— Donald Knuth, Interview with Andrew Binstock
Front-End Performance Checklist 2021
Via Lobsters today: Front-End Performance Checklist 2021 from Smashing Magazine.
You Can’t Sacrifice Partition Tolerance
Today via Hacker News: You Can’t Sacrifice Partition Tolerance.
Modern Javascript: Everything you missed over the last 10 years
This on r/programming today: Modern Javascript: Everything you missed over the last 10 years. A nice run down on contemporary JavaScript…
The Bourne shell and Bash aren’t the right languages for larger programs
Today I read The Bourne shell and Bash aren’t the right languages for larger programs. It linked to this DKMS script which was interesting. TIL: ‘readonly’ in BASH.
10 HTML Semantic Tags and When to Use Them
Today on r/programming: 10 HTML Semantic Tags and When to Use Them.
5 things I learned while developing a billing system
On r/programming today: 5 things I learned while developing a billing system.
Best Unicode Fonts for Programmer
So today I went looking for a font to replace ‘Inconsolata 14’ in my NetBeans IDE because it wasn’t supporting Unicode and I found Best Unicode Fonts for Programmer which lead me to DejaVu Sans Mono.
While I was at it I changed my Konversation font from Ubuntu Mono 12 to DejaVu Sans Mono too.
My friends on #lobsters also recommended:
- Monaco (Apple font)
- JetBrains Mono
- Fira Mono (13pt)
- Hack
- IBM Plex Mono
I love being a programmer
My ZFS RAID array is resilvering. It’s a long recovery process. A report on progress looks like this:
Every 10.0s: zpool status love: Tue May 4 22:32:27 2021
pool: data
state: DEGRADED
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scan: resilver in progress since Sun May 2 20:26:52 2021
1.89T scanned out of 5.03T at 11.0M/s, 83h19m to go
967G resilvered, 37.54% done
config:
NAME STATE READ WRITE CKSUM
data DEGRADED 0 0 0
mirror-0 ONLINE 0 0 0
sda ONLINE 0 0 0
sdb ONLINE 0 0 0
mirror-1 DEGRADED 0 0 0
replacing-0 DEGRADED 0 0 0
4616223910663615641 UNAVAIL 0 0 0 was /dev/sdc1/old
sdc ONLINE 0 0 0 (resilvering)
sdd ONLINE 0 0 0
cache
nvme0n1p4 ONLINE 0 0 0
errors: No known data errors
So that 83h19m to go wasn’t in units I could easily grok, what I wanted to know was how many days. Lucky for me, I’m a computer programmer!
First I wrote watch-zpool-status.php:
#!/usr/bin/env php
<?php
main( $argv );
function main( $argv ) {
$status = fread( STDIN, 999999 );
if ( ! preg_match( '/, (\d+)h(\d+)m to go/', $status, $matches ) ) {
die( "could not read zpool status.\n" );
}
$hours = intval( $matches[ 1 ] );
$minutes = intval( $matches[ 2 ] );
$minutes += $hours * 60;
$days = $minutes / 60.0 / 24.0;
$report = number_format( $days, 2 );
echo "days remaining: $report\n";
}
And then I wrote watch-zpool-status.sh to run it:
#!/bin/bash watch -n 10 'zpool status | ./watch-zpool-status.php'
So now it reports that there are 3.47 days remaining, good to know!