SQLite Parameters – Not allowing tablename as parameter

Generally one cannot use SQL parameters/placeholders for database identifiers (tables, columns, views, schemas, etc.) or database functions (e.g., CURRENT_DATE), but instead only for binding literal values. With server-side support for parameterized (a.k.a. prepared) statements, the DB engine parses your query once, remembering out the peculiars of any parameters — their types, max lengths, precisions, etc. … Read more

How to deal with Number precision in Actionscript?

This is my generic solution for the problem (I have blogged about this here): var toFixed:Function = function(number:Number, factor:int) { return Math.round(number * factor)/factor; } For example: trace(toFixed(0.12345678, 10)); //0.1 Multiply 0.12345678 by 10; that gives us 1.2345678. When we round 1.2345678, we get 1.0, and finally, 1.0 divided by 10 equals 0.1. Another example: … Read more

Flex 3 – how to support HTTP Authentication URLRequest?

The syntax is a little different for URLRequest, but the idea’s the same: private function doWork():void { var req:URLRequest = new URLRequest(“http://yoursite.com/yourservice.ext”); req.method = URLRequestMethod.POST; req.data = new URLVariables(“name=John+Doe”); var encoder:Base64Encoder = new Base64Encoder(); encoder.encode(“yourusername:yourpassword”); var credsHeader:URLRequestHeader = new URLRequestHeader(“Authorization”, “Basic ” + encoder.toString()); req.requestHeaders.push(credsHeader); var loader:URLLoader = new URLLoader(); loader.load(req); } A couple of … Read more

What is the best way to get the minimum or maximum value from an Array of numbers?

The theoretical answers from everyone else are all neat, but let’s be pragmatic. ActionScript provides the tools you need so that you don’t even have to write a loop in this case! First, note that Math.min() and Math.max() can take any number of arguments. Also, it’s important to understand the apply() method available to Function … Read more