Used PHP’s urlencode today…
Category Archives: Programming
psql fatal role does not exist
I was setting up a postgres server and I got the message “psql fatal role ‘user’ does not exist”. Found a solution over here, basically:
CREATE USER jj5 SUPERUSER; CREATE DATABASE dbname WITH OWNER jj5;
Sorting Arrays in PHP
Everything you ever wanted to know about sorting arrays in PHP.
PHP instance of Closure vs is_callable or function_exists
The problem is that is_callable and function_exists check a string to see if it’s a function. But I wanted to check to see if it was an anonymous function and not a string. Turns out you can do this by checking for an instance of Closure:
if ( $fn instanceof Closure ) { $fn( ... ); }
Design by Contract
Just read the Design by Contract article on Wikipedia… a good read!
MySQL INET_ATON and INET_NTOA
You can convert an IP address to an int, and vice versa, with these two MySQL functions. Of course I learned about this after I’d already implemented IP address support using BINARY(4) and my own parser/formatter… now that I have my own implementation I can’t bring myself to let it go, and I worry about support for signed/unsigned 32-bit ints (perhaps my concerns are unfounded..?)
Ackermann function
I was reminded today of the Ackermann function which is famous in computer science.
Robots HTML META tags
Today I added the Robots <META> tag with noindex, nofollow to my HTML error documents.
PHP HTTP response data
Today I learned about headers_list and http_response_code… yay! :)