How to handle lack of JavaScript Object.bind() method in IE 8

There is a good compatability script on this page: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind Just copy and paste it into your script. EDIT: placing the script below for clarity. if (!Function.prototype.bind) { Function.prototype.bind = function(oThis) { if (typeof this !== ‘function’) { // closest thing possible to the ECMAScript 5 // internal IsCallable function throw new TypeError(‘Function.prototype.bind – what … Read more

Weak Linking – check if a class exists and use that class

TLDR Current: Swift: if #available(iOS 9, *) Obj-C, iOS: if (@available(iOS 11.0, *)) Obj-C, OS X: if (NSClassFromString(@”UIAlertController”)) Legacy: Swift (versions prior to 2.0): if objc_getClass(“UIAlertController”) Obj-C, iOS (versions prior to 4.2): if (NSClassFromString(@”UIAlertController”)) Obj-C, iOS (versions prior to 11.0): if ([UIAlertController class]) Swift 2+ Although historically it’s been recommended to check for capabilities (or … Read more

Is JDK “upward” or “backward” compatible?

Note that for something to be backwards compatible there must be a counterpart that is forwards compatible (either intentionally or unintentionally). For example: are the DVD readers backwards compatible with CD’s or are the CD’s forward compatible with DVD readers? In this case, it depends if you look at the compiler (or the bytecode it … Read more

Enabling auto layout in iOS 6 while remaining backwards compatible with iOS 5

Autolayout can be enabled or disabled on each .storyboard or .xib file. Just select the particular file and modify the “Use Autolayout” property using the File inspector in Xcode: Using autolayout enabled interface files with the deployment target set to an iOS version prior to 6.0 results in compilation errors, e.g.: Error in MainStoryboard.storyboard:3: Auto … Read more

How to install both Python 2.x and Python 3.x in Windows

I found that the formal way to do this is as follows: Just install two (or more, using their installers) versions of Python on Windows 7 (for me work with 3.3 and 2.7). Follow the instuctions below, changing the parameters for your needs. Create the following environment variable (to default on double click): Name: PY_PYTHON … Read more

Python’s many ways of string formatting — are the older ones (going to be) deprecated?

The new .format() method is meant to replace the old % formatting syntax. The latter has been de-emphasised, (but not officially deprecated yet). The method documentation states as much: This method of string formatting is the new standard in Python 3, and should be preferred to the % formatting described in String Formatting Operations in … Read more