posted 2 years ago

Do you use CodeIgniter's Form Helper?

I've always ignored it in the past as too "faffy" but with the introduction of CSRF tokens in CI 2 it's suddenly looking attractive. It it worth taking the hit and converting my existing 37 forms to use it?

Also, is it possible to get the CSRF benefits just using form_open does anybody know?

[UPDATED] It turns out you can turn on CSFR in config.php then simply replace your hand-rolled form tag and closing tags, and magic happens! No need to convert all your validation, repopulation etc.

posted 2 years ago

Version controlling db schema (likely mysql)

Version controlling code is easy, at best fiddly, but version controlling database schema (and static data) is hard.

At the moment we're using a very crappy "shell scrip > mysqldump > files and version control" loop just so we have some idea but it's far from ideal.

What are people using? There seem to be some reasonable tools build in code frameworks (South etc) but are these applicable to controlling a mysql db for a PHP project?

posted 2 years ago

One liner to get kitten based placeholdr images

                for x in 400 500 600 700 800 900 1000
 do 
for y in 1000 900 800 700 600 500 400
do 
curl -o ${x}_${y}.jpg -O http://placekitten.com/${x}/${y}
 done
 done                
Raw

placekitten.com generates placeholder images of kittens, a work of genius by @markjames

This dirty one liner downloads 49 images of various sizes to make your testing bundles in 30 seconds.

Be king to placekitten.com, hold onto your downloaded images rather than crunch their server every 5 minutes

posted 2 years ago

Onliner to see what you listened to in 2010

                curl -g  http://ws.audioscrobbler.com/2.0/user/coldclimate/topartists.xml?period=12month | xmlstarlet sel -t -m //artist -v name -o ":" -v playcount -n                
Raw

Replace coldclimate with your last.fm username and see what/who you listened to most in 2010

posted 2 years ago

Working out what options Vagrant is using for your NFS mount

                sudo tail -f /etc/exports                
Raw

If you're having problems with NFS mounts when vagrent up'ing, open a fresh session and use the code above to see what's getting added to your export file.

Then when you "vagrant up" in another session window you will see something like this appear

VAGRANT-BEGIN: 6ae00fba-2076-45e7-8f52-2c931741b746

/home/username/Desktop/lucid32exp 192.168.10.150(rw,no_subtree_check,all_squash,anonuid=1000,anongid=1000)

VAGRANT-END: 6ae00fba-2076-45e7-8f52-2c931741b746

And that's what options Vagrant is using to try and mount.

posted 3 years ago

Finding TLD in PHP

                // Rare you'll need this, but handles subdomains etc.

$theBits = explode('.', $_SERVER['HTTP_HOST']);

// and your TLD is $finalBit
$finalBit = $theBits[sizeof($theBits)-1];

//Currently using this to liveswitch between live and development                 
Raw

The title says it all

posted 3 years ago

DataTables Jqueury pluggin

                Correct table syntax
<table>
<thead>
<tr>
<th>Title </th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell</td>
</tr>
</tbody>
</table>                
Raw

If you get errors such as "oTable not defined" it's likely to be the structure of your table causing the derailment. I had a missing in the

, took hours to find.
Annoying to debug, I was convinced it was the way I was calling jQuery