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.
Category Archives: Programming
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 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.
bzr_hookless_email configuration bug
I ran into this bug using bzr_hookless_email, fortunately someone had published a patch which seems to have fixed the issue:
=== modified file 'bzr_hookless_email.py'
--- bzr_hookless_email.py 2012-03-22 15:15:15 +0000
+++ bzr_hookless_email.py 2012-04-25 06:05:55 +0000
@@ -159,7 +159,7 @@
self._config = self._branch.get_config()
def update(self):
- smtp = SMTPConnection(self._config)
+ smtp = SMTPConnection(self._branch.get_config_stack())
smtp_from = None
for revision in self._revisions_to_send():
msg = self._compose_email(revision)
PHP PDO
I’m learning the PHP PDO interface for database programming. Today I read about fetch, fetchAll, bindColumn and the predefined constants.
PHP mail
I used the PHP mail function for the first time today. I had to configure the SMTP setting for my mail server in my php.ini file and after that it worked fine. Still only sending plain text email, and I’m not sure that I can for HTML email. :P
Excel’s VLOOKUP Function
I used Excel’s VLOOKUP Function for the first time today. I guess I don’t spend much time in Excel!
HTML5 Boilerplate
I learned about the HTML5 Boilerplate library today. It’s a template for creating a HTML5 website.
Facebook Graph API
Learning about the User in the Facebook Graph API. One disappointing thing I learned today is that you can’t automatically download the email addresses of your friends via a facebook app.