February17
Let’s get the ball rolling wit this handy one about inserting csv or other delimited data to mysql dbs using INFILEs. This looks like a basic php version too.
When getting the annoying error 1075 “Incorrect table definition; There can only be one auto column and it must be defined as a key” when trying to add a new primary key, this page has an awesome solution.
Using sprintf() to zerofill variables, handy like so:
$zeroball1 = $this->escape($result->ball1);
$zeroball2 = sprintf("%02d",$zeroball1);
echo $zeroball2;
Zend Framework and MySQL
For counting across rows, first check out the excellent official mysql page on row counting. Then to apply it to Zend framework, this is probably the best starting place for MySql select queries in Zend FW, and I check it regularly. Basically, to run a mysql query like SELECT `results`.`bonus`, COUNT(*) AS `counter` FROM `results` WHERE (draw = 0) GROUP BY `bonus`; you need the following in your model. Note the ‘counter’ => ‘COUNT(*)’ syntax…
$query = $db->select()
->where("draw = $draw_val")
->from('results',array('bonus','counter' => 'COUNT(*)'))
->group('bonus');
For further and more detailed quality examples of Zend and MySql, this is good. Check out lars’ comment here on counting across multiple tables.
February15
A2 Hosting are by far the best web hosts I’ve come across, in terms of value for money, quality, reliability and customer support. So I’ll be adding some reference material here as I have time, more or less for my own benefit too.
Will be adding more here but for now here is the guide to installing TRAC.
SMTP and IMAP details for google apps mail. Vid tutorial of the same.
February14
For a starting point on jQuery, here’s a page with a load of useful links (at the bottom) from good old Smashing Magazine.
Here’s a great tutorial resource for jQuery – tonne of good links off it too. One of the best, which starts with the most fundamental/basic topics, and works its way up to writing a jQuery plugin, is unsurprisingly one of jQuery’s own tutorials, by Jörn Zaefferer. A good, basic end() example.
Here’s a handy cheatsheet too, and a great page on manipulation capabilities.
Pretty much all you need on SiFR is right here. And here’s how to create your own Flash files without using Adobe suite. No you’ve got no excuse!
February11
Haven’t had time to check it out yet, but this looks promising, and just what I want to be able to send sms messages to mobiles in Ireland from a php script. http://www.webdeveloper.com/forum/showthread.php?t=170285
Good one here too, based on TM4B, which by all accounts is a good gateway to use. Here’s a list of SMTP delivery gateways to sms, note for Ireland that Meteor are way ahead of the curve, and phonenumber@mymeteor.ie or phonenumber@sms.mymeteor.ie can be used to send sms via SMTP to Meteor customers. Sadly, Vodafone and O2 do not provide this service in Ireland, even though they provide elsewhere in the world. Once again Irish consumers getting the worst of it…
And best of all, here’s an open source SMS gateway!! Haven’t tried it fully yet, but if I can get that working will save a tonne of cash!
February11
This is handy, you can use:
curl -w %{http_code} url
to retrieve the http response code for a given url.
Bash script for parsing my lotto results:
#!/bin/bash
count=0;
var1=0;
exec<"lotto.txt"
while read line
do
if [ $[$count % 2] -eq "0" ];
then
var1=$(echo $line | awk '{ print $1 $2 $3}');
echo $line;
else
var2=$(echo $line[-1] | awk '{ print $1 $2 $3}');
echo $var1 $line;
#echo $date1
fi
let "count+=1";
done
February9
…to my non-poker related blog. This is really just a handy way for me to keep track of my web dev adventures, so it’s not really for public consumption, but you’re more than welcome!!