My CSS height value wasn’t being applied. Found this. The problem was that I needed to specify heights for all of the ancestor elements. Bug fixed!
Category Archives: Programming
Piping PHP CLI output to less broken
Today I had an interesting problem.
When I ran:
# php test.php | less
The ‘less’ program entered input mode and the up and down arrow (and j, k keys) weren’t working.
Eventually I figured out a solution:
# php test.php < /dev/null | less
The PHP CLI seems to be interfering with the terminal and piping in /dev/null to PHP CLI stdin fixes the problem!
Calculate a median with MySQL
Today I read this article and found this technique for calculating a median value:
SELECT x.val from data x, data y GROUP BY x.val HAVING SUM(SIGN(1-SIGN(y.val-x.val)))/COUNT(*) > .5 LIMIT 1
HTML meta refresh
Today I read What is the Meta Refresh Tag? about the HTML Meta Refresh facility, basically:
<meta http-equiv="refresh" content="0;url=https://www.jj5.net/">
Embedding archive.org videos…
Today I read about how to link to archive.org videos…
MySQL convert_tz
Today I used the MySQL convert_tz function.
Before I could use named timezones with convert_tz I had to load the timezones.
Loading MySQL timezone data
Turns out MySQL doesn’t load timezone info by default! As you can read about here.
To load MySQL timezone info:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
PHP DateTimeZone->getOffset()
Today I had to use PHP’s DateTimeZone->getOffset() to get a timezone offset. It needed formatting which I did with:
function timezone_offset() {
$offset = timezone()->getOffset( now() );
$hours = round( abs( $offset ) / 3600 );
$minutes = round( ( abs( $offset ) - $hours * 3600 ) / 60 );
$result = ( $offset < 0 ? '-' : '+' )
. ( $hours < 10 ? '0' : '' ) . $hours
. ':'
. ( $minutes < 10 ? '0' : '' ) . $minutes;
return $result;
}
301 permanent HTTP redirects with Nginx
According to this article:
rewrite ^/store/view/product/(.*) /store/view.jsp?product=$1 permanent;
Setting svn:ignore from the command line
Today I had to lookup how to set svn:ignore from the command line:
$ svn propset svn:ignore [file|folder] [path]