Adobe Fireworks Colour Picker Problem on Mac OS X Mountain Lion
I’ve had a problem with Adobe Fireworks CS5 ever since upgrading to a Retina Display MacBook. The problem is that the eye-dropper colour picker tool just doesn’t work any more. At all. Very frustrating.
I came across a very simple workaround today which can be found here:
http://simianstudios.com/blog/post/colour-picker-bug-workaround-for-adobe-fireworks-cs4-in-os-x-lion
Controlling Hide/Show Apex Regions Using Javascript
Hide/Show regions are very useful in that they allow users to hide certain on-screen content when it’s not relevant for them (and show it again just as easily) simply by clicking the small arrow icon in the top left of the region.
But how can you programmatically do the equivalent of clicking the arrow icons? Perhaps, for example, when a user clicks a particular button on your page, you want all Show/Hide regions to be expanded. How can you do this?
One answer is the snippet of code below. In this code, “MY_REGION” is the static ID of the region for which we wish to programatically click the show/hide arrow icon.
// How to programatically click a Hide/Show region hide/show button
$('#MY_REGION .uRegionControl').click();
We can use the snippet below to work out the current status of a Hide/Show region i.e. whether it is currently expanded or collapsed. The below snippet will return a value or “none” if the region is collapsed.
// How to find out whether a hide/show region is currently shown or not
$('#MY_REGION div.uRegionHeading').next().css('display');
We can build on the above to create a function which expands, collapses or toggles the state of a Hide/Show Region.
// ********************************************************
// ** Function setStateOfHideShowRegion(pRegionStaticId,pDoWhat)(type,id)
// ** Collapses, Expands of toggles any Hide Show region which has a static id
// ** defined by the string pRegionStaticId.
// ** Returns either "collapsed" or "expanded" to indicate the status of the
// ** region once this function has run.
// ** pDoWhat: either "expand", "collapse" or "toggle"
// ********************************************************
function setStateOfHideShowRegion(pRegionStaticId,pDoWhat) {
var returnState;
var currentState = 'expanded';
doWhat = pDoWhat.toLowerCase();
if ($('#'+pRegionStaticId+' div.uRegionHeading').next().css('display') == 'none') {
currentState = 'collapsed';
};
if (doWhat == 'toggle') {
$('#'+pRegionStaticId+' .uRegionControl').click();
returnState = (currentState=='expanded'?'collapsed':'expanded');
}
else if (doWhat == 'expand') {
if (currentState !== 'expanded') {
$('#'+pRegionStaticId+' .uRegionControl').click();
};
returnState = 'expanded';
}
else if (doWhat == 'collapse') {
if (currentState !== 'collapsed') {
$('#'+pRegionStaticId+' .uRegionControl').click();
};
returnState = 'collapsed';
};
return returnState;
}
Advanced Javascript Tutorial
Today I came across a great interactive tutorial which covers a series of advanced Javascript topics. It’s very well put together and lets you try out your own variations of the code being shown which can be very handy in making sure your understanding is correct.
It’s from John Resig, the creator of jQuery. The tutorial is not jQuery-centric though. In fact, it doesn’t talk about or use jQuery at all. It’s just pure Javascript.
You can find it here: http://ejohn.org/apps/learn/
Restoring a dropped table
Catastrophe! You’ve just accidentally dropped a table which contained really rather important data. What to do?
One thing you can do to recover the situation quickly (if you’re running 10g or later, that is) is to run the following command:
FLASHBACK TABLE MY_SCHEMA.MY_SUPER_IMPORTANT_TABLE TO BEFORE DROP;
If the table is still in the Recycle Bin, it’ll be recovered straight away. You can check whether the table is still available in the recycle bin and whether it can be recovered this way, with the following SELECT statement:
SQL> select original_name, can_undrop from recyclebin; ORIGINAL_NAME CAN -------------------------------- --- MY_SUPER_IMPORTANT_TABLE YES
You can read about the Recyle Bin and Flashback Drop here: http://docs.oracle.com/cd/B19306_01/backup.102/b14192/flashptr004.htm
An Interesting Feature of NOT IN and Multi-Row Subqueries
Take the following simple SQL statement:
SELECT * FROM dual WHERE 'x' NOT IN (SELECT 'a' FROM dual);
Since ‘x’ cannot be found in our subquery, you’d expect this to return a row from Dual right? Indeed it does:
SQL> SELECT * 2 FROM dual 3 WHERE 'x' NOT IN 4 (SELECT 'a' FROM dual); D - X
What about in the following case?
SELECT * FROM dual WHERE 'x' NOT IN (SELECT 'a' FROM dual UNION ALL SELECT NULL FROM dual);
You might expect this to return a row as well since ‘x’ is still not in our subquery (which now returns two values: ‘x’ and NULL).
You’d be wrong, however. This query will in fact return no rows:
SQL> SELECT * 2 FROM dual 3 WHERE 'x' NOT IN 4 (SELECT 'a' FROM dual 5 UNION ALL 6 SELECT NULL FROM dual); no rows selected
If the subquery referenced by your NOT IN statement contains any NULL values, the NOT IN condition will evaluate to unknown.
It’s worth noting that this is not the case if you use an IN as opposed to a NOT IN:
SQL> SELECT * 2 FROM dual 3 WHERE 'a' IN 4 (SELECT 'a' FROM dual 5 UNION ALL 6 SELECT NULL FROM dual); D - X
Preventing calls to console.log throwing errors in IE
When developing applications which make a lot of use of Javascript, it can be very useful to use the console.log() function to output debug to Firefox’s Firebug console or to Chrome’s Javascript console.
However, such calls will cause errors when run inside IE as it does not by default have a console object (depending on the version of IE you are running and what add-ons you have installed). These errors may prevent other aspects of your Javascript from running, essentially breaking you application.
One quick solution to this is to add the following piece of jQuery to your code which will prevent console.log() from doing anything at all in IE and hence preventing the errors from occurring:
$(document).ready(function(){
if ($.browser.msie) {console = { log: function() {} }};
})
Alternatively, you can incorporate the following piece of code which will, in IE, cause all messages sent to the console via console.log() to be alerted using alert() instead:
$(document).ready(function(){
if ($.browser.msie) {console = { log: function(msg) {alert(‘Debug: ‘+msg);} }};
})
New Release of jQuery UI
I’ve just noticed that there’s a new version of jQuery UI: 1.9. It includes nifty new widgets including Menu, Spinner and Tooltip. And who doesn’t love new widgets?
You can read about it and see demoes of the new functionality here: http://blog.jqueryui.com/2012/10/jquery-ui-1-9-0/


