Today I used the Datepicker for Bootstrap. I grabbed the files from the CDN.
Category Archives: Internet
HTML Singleton Tags
Found a list of HTML Singleton Tags, the tags that don’t require a closing tag.
PHP Output Buffering Control
Using PHP Output Buffering Control…
PHP $_SERVER[ ‘SERVER_PROTOCOL’ ]
Today I queried the $_SERVER[ ‘SERVER_PROTOCOL’ ] value in PHP to determine the HTTP version used by the request.
PHP file_get_contents with HTTP Basic Auth
Today I needed to figure out how to read some data from a URL that required HTTP Basic Auth. The solution was pretty simple, use file_get_contents and pass in a configured stream context. I found the following code on the stream_context_create documentation:
$cred = sprintf( 'Authorization: Basic %s',
base64_encode( 'username:password' )
);
$opts = array(
'http' => array(
'method' => 'GET',
'header' => $cred
)
);
$ctx = stream_context_create( $opts );
$data = file_get_contents( $url, false, $ctx );
Easy-peasy!
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..?)
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! :)
Firefox: Open in Browser
Today I installed the Open in Browser Firefox extension which lets me open files in Firefox rather than having to download them… handy!
Running Apache as ME!
On my development machine I want Apache to run under my user id so I can automatically generate files (and have permission to write them).
I configured Apache like this:
root@mercy:/etc/apache2# grep -R www-data . ./envvars:export APACHE_RUN_USER=www-data ./envvars:export APACHE_RUN_GROUP=www-data root@mercy:/etc/apache2# vim envvars export APACHE_RUN_USER=jj5 export APACHE_RUN_GROUP=jj5 root@mercy:/etc/apache2# apache2ctl graceful /var/lock/apache2 already exists but is not a directory owned by jj5. Please fix manually. Aborting. root@mercy:/etc/apache2# chown jj5:jj5 /var/lock/apache2 root@mercy:/etc/apache2# apache2ctl graceful
Easy-peasy!
Wait… that didn’t work. The problem was apache2ctl graceful didn’t pick up the new envvars file, this fixed it:
root@mercy:/etc/apache2# /etc/init.d/apache2 restart