Posts

Disabling HTML5 Video Right-click Download

So, for the Arena Hotel project I've just completed I needed to prevent the default HTML right-click context menu that allows download of videos. There is no tag parameter for this, so the only way you can do it is by disabling context menus either on the container div, or the whole document. Wedge this code in: $(document).ready(function(){   // Kill the right-click context menu globally   document.oncontextmenu = function() { return false; }   // or just kill for a particular container div   $('#mydiv').bind('contextmenu',function() { return false; }); });

Mountain Lion MySQL Death Bug

Like a bad tech cold, the Mountain Lion MySQL death bug has finally (inevitably?) reached me having already taken out several developer friend's systems. This can result in you losing ALL of your data, so backup your data directory FIRST - probably it'll be in /usr/local/mysql/data so: sudo bash cp -R /usr/local/mysql/data ~/backups/ Next, kill off your duff my.cnf file: my /etc/mysql.cnf /etc/mysql.cnf.old ... and restart: mysqld --verbose

Not getting PHP errors following Mountain Lion Upgrade? What to do...

After upgrading to Mountain Lion I found that my php.ini (usually in /etc/php.ini) had been nuked meaning that no errors were being displayed in my development LAMP environment :( Actually, it seems that Apple simply rename your existing php.ini file to php.ini-5.2-previous (or similar) so that you jump back to the default PHP settings. Rectifying this is fairly straightforward however - simply: 1. Open Terminal 2. Log in as root by typing  sudo bash 3. Type: cd /etc cp php.ini-5.2-previous php.ini 4. Restart apache with:   apachectl graceful And you're good to go...

Free Early Years software for 2012

Really proud to announce that our increasingly popular school pupil tracking software Pupil*Asset  is going to be offering support for the new Early Years EYFS foundation stage profile for FREE (so long as someone at the school gets training to keep our support guys from going crazy...) If you are interested in tracking the revised FSP (from Sept 2012 for ac.year 12/13) you can register your interest here . There are only a limited number of training places (and hence systems) so get in there!

Script to Toggle TinyMCE for ALL TextAreas

TinyMCE has it's foibles (as you will surely know if you've found this post) and many people - particularly those with HTML knowledge - like to turn it off. In our CMS this is achieved with a toggle button, and some javascript. I thought I'd share it, because it is SO useful to us: 1. Make sure this javascript appears somewhere: $(function() {   $("#richTextToggle").toggle(function(){     $("textarea").each(function(){       tinyMCE.execCommand('mceRemoveControl', false, $(this).attr('id'));     })   }, function () {     $("textarea").each(function(){       tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));     })   }); }); 2. Create a toggle link / btn: Toggle Rich Text

Changing your Mac OSX Terminal's default text editor

For just this session, simply type: export EDITOR=emacs (or replace emacs with vim , nano or whatever) Personally, I like to use emacs on servers, but on my Mac TextWrangler is way more helpful. One of the great things about TextWrangler is that you can get it to magically pop edit requests out of the Terminal simply by installing it and typing "edit". To make all other programs use this method try: export EDITOR="edit -w" For a more permanent fix, add the same line to your .bashrc file. If you've not already got one of those, type: edit ~/.bashrc (The one exception is git, which you'll need to configure thus:) git config core.editor "edit -w"

Mobile Detection Script (Javascript redirect for iPhone / Android / Blackberry)

I struggled to find us a usable mobile javascript redirect - even StackOverflow's helpful crew were awash with geeky prejudice along the lines of "not all mobiles have javascript enabled"... Almost all of the modern web requires javascript to be on, and if you're a) one those geeks who has it switched off or b) have a pre-Android/iPhone/Blackberry handset then you can try your luck with the main non-mobile site anyway. So here goes - a short, quick, simple mobile detect + redirect script: /* Klik Mobile Detection Script */ function touchAndGo(where) {   var ua = navigator.userAgent.toLowerCase();   if (ua.search("iphone") > -1 ||  ua.search("ipod") > -1 ||  ua.search("android") > -1 ||  ua.search("blackberry") > -1 || screen.width <= 480) {     location.href=where;   } } touchAndGo("http://touch.mysite.com/");