I used EchoSign for the first time today. It’s Adobe’s online electronic signature system, pretty handy.
Author Archives: Jay Jay
Subscribing mailman list members via the command line
Found this article which shows how to subscribe list members via the command line:
/usr/lib/mailman/bin/add_members -r - my_list <<-EOF >sue@foo.com >bob@bar.com >EOF
Escaping SQL values in PHP without using mysql_real_escape_string
Found this article which has a handy ‘escape’ function:
// replace any non-ascii character with its hex code.
function escape($value) {
$return = '';
for($i = 0; $i < strlen($value); ++$i) {
$char = $value[$i];
$ord = ord($char);
if($char !== "'" && $char !== "\"" && $char !== '\\' && $ord >= 32 && $ord <= 126)
$return .= $char;
else
$return .= '\\x' . dechex($ord);
}
return $return;
}
Single Sign On: integrating Postfix/Kerberos/LDAP
Some reading to do concerning integrating Postfix/Kerberos with LDAP:
http://www.postfix.org/LDAP_README.html
http://www.boobah.info/howto/postfix-ldap.html
http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_ldap.html
Execute Multiple MySQL Queries from One String in PHP
Found this article today, Execute Multiple MySQL Queries from One String in PHP. It’s a work around for processing MySQL batch queries separated by semicolons.
Using grep (not sed) to grab IP addresses from Apache web logs
Today I ran the following command to see how many people accessed the ProgClub wiki over the previous 5 hours:
jj5@charity:/var/log/apache2$ grep "GET /wiki/" access.log |
grep "13/Jul/2013:0" | grep -Eo '^([0-9]{1,3}\.){3}[0-9]{1,3}' | sort | uniq | wc
Cloning a JavaScript object with jQuery
Today I heard from John Resig on StackOverflow about how to clone objects using jQuery:
// Shallow copy
var newObject = jQuery.extend({}, oldObject);
// Deep copy
var newObject = jQuery.extend(true, {}, oldObject);
HTTP Caching in Mozilla
Turned up this old document about HTTP Caching in Mozilla.
HTTP cache control headers
I had to do two things today. One was to make sure that in production all of my resources were cached. The other was to make sure that in development none of my resources were cached. I ended up with these two functions, which seem to be doing the trick to disable/enable caching:
function set_nocache() {
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
function set_cache() {
header('Expires: ' . gmdate( 'D, d M Y H:i:s', time()+31536000 ) . ' GMT');
header('Cache-Control: max-age=31536000');
}
Reference: Completely disable any browser caching.
Which mime type to use for MP3?
I read this article and learned that the best mime type to use for MP3 files is audio/mpeg.