error handling in asynchronous node.js calls

Node 0.8 introduces a new concept called “Domains”. They are very roughly analogousness to AppDomains in .net and provide a way of encapsulating a group of IO operations. They basically allow you to wrap your request processing calls in a context specific group. If this group throws any uncaught exceptions then they can be handled … Read more

function fail never called if user declines to share geolocation in firefox

For Firefox it seems that PERMISSION_DENIED is raised only if “Never share” is selected; if the dialog is dismissed or “Not now” is selected, effectively nothing happens – even on mozillas geolocation demo if you dismiss the permissions UI nothing happens. This means that getCurrentPosition can return either because the user closed the confirmation UI, … Read more

What is the difference between Asynchronous calls and Callbacks

Very simply, a callback needn’t be asynchronous. http://docs.apigee.com/api-baas/asynchronous-vs-synchronous-calls Synchronous: If an API call is synchronous, it means that code execution will block (or wait) for the API call to return before continuing. This means that until a response is returned by the API, your application will not execute any further, which could be perceived by … Read more

How do I write a jquery function that accepts a callback as a parameter

function ChangeDasPanel(controllerPath, postParams, f) { $.get( controllerPath, postParams, function(returnValue) { var $DasSpace = $(‘#DasSpace’); $DasSpace.hide( “slide”, { direction: “right” }, 1000, function() { $DasSpace.contents().remove(); $DasSpace.append(returnValue).css(“display”, “block”); $DasSpace.show(“slide”, { direction: “right” }, 1000); } ); if (typeof f == “function”) f(); else alert(‘meh’); } ); }; You can pass functions like any other object in JavaScript. … Read more

Callback function syntax in Swift

Rob’s answer is correct, though I’d like to share an example of a simple working callback / completion handler, you can download an example project below and experiment with the getBoolValue‘s input. Swift 5: func getBoolValue(number : Int, completion: (Bool)->()) { if number > 5 { completion(true) } else { completion(false) } } getBoolValue(number: 2) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)