Code Samples, Announcements, News and just tons of other awesome things for software developers.
Recent Tweets @skitsanoscom

When you coding for a mobile device with use of Adobe AIR you might face quite weird behaviour for components like FormItem, in some cases input fields within it will try to get out far beyond their width, so in order to sort it out here is quick hack for you, make a new component, let’s call it LabeledInput with the following code:

<?xml version=”1.0”?>

<s:HGroup

xmlns:fx=”http://ns.adobe.com/mxml/2009

xmlns:s=”library://ns.adobe.com/flex/spark

verticalAlign=”top”

paddingLeft=”10” paddingRight=”10”

gap=”10”

width=”100%”

creationComplete=”init()”>

<fx:Script><![CDATA[

import spark.components.Label;

[Bindable]

public var title:String;

[Bindable]

public var labelWidth:int = 100;

private function init():void

{

var label:Label = new Label();

label.width = labelWidth;

label.text = title;

this.addElementAt(label, 0);

}

]]></fx:Script>

</s:HGroup>

It simply will do the same thing as FormItem does, just you won’t need to wrap it under the Form tag, we added label and labelWidth properties to hold our input label and it’s width. As you can see it just prepends label before any content you passed into this control. Using it is quite easy thing, here is a small app for you:

<?xml version=”1.0” encoding=”utf-8”?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009

xmlns:s=”library://ns.adobe.com/flex/spark

xmlns:components=”components.*”>

<s:layout>

<s:VerticalLayout paddingTop=”20” paddingBottom=”20”/>

</s:layout>

<components:LabeledInput title=”Username: ” labelWidth=”150”>

<s:TextInput prompt=”username” width=”100%”/>

</components:LabeledInput>

<components:LabeledInput title=”Password: ” labelWidth=”150”>

<s:TextInput prompt=”password” width=”100%”/>

</components:LabeledInput>

</s:Application>

Visually, result will be something like this:

SQL Server Import Wizard

As we promised this January, we added to Kanapes IDE a really nice and handy tool - SQL Server Import Wizard, it will help you with migrating your data from data tables and views into CouchDB. You will find this tool by right-clicking on any selected server node in your Project Explorer.

More detailed tips about SQL Server Import Wizard we will describe in dedicated blog post coming up shortly.

Cloudant Search 2.0

Another interesting feature we added is support for Cloudant Search 2.0. Cloudant’s search is built upon Lucene and allows you to do more ad hoc queries over your data than can be done with primary and secondary indexes. Please note that adding indexes to Kanapes IDE Project Explorer works only on Cloudant hosted servers. Just select any db from the list, select Design Document, right click and you will see new menu item appeared called ndx. When you select it, following dialog will popup, so just name your index and you will get into a code editor mode like with other function types.

Etc additions and improvements

You can Copy and Paste Design Documents between Databases, view Document Revisions, your recently opened projects now listed on welcome tab for a quick access. We also added you quick links for two CouchDB hosting options to start with if you don’t want to run your own CouchDB for any reason. Still, if you want to play with Cloudant Search 2.0 (https://cloudant.com/for-developers/search/) you need an account for that.

Also, you can compact databases and views as well with performing cleanup on selected views.

Having OSX and Linux builds are still on our list, but no timeline defined for these ones.

Talk to us

Most of the features added into Kanapes IDE actually added after collecting your feedback, so talk to us, it cost you nothing ;) You can ping @kanapeside on Twitter, or hit it Facebook https://www.facebook.com/kanapeside or just drop us an email directly from http://kanapeside.com web site

Have fun!

The biggest downside of Mono for Android is that you are building on Mono, a completely separate runtime that what Android expects. And while there are certainly some advantages to having access to a full CLR, marshalling calls between it and Android’s Dalvik runtime can be expensive. So why not skip the IL code and emit Dex code directly?


Actually that is a slight exaggeration. The dot42 (https://www.dot42.com/) compiler doesn’t actually skip the IL. Rather, it reads the IL code and converts it into a new language called RL or Register Language. The main difference between IL and RL is that IL is stack-based (somewhat like Java’s byte code) while RL is register based. Once converted into RL, a set of optimizations are performed and the final product is compiled again. This last compilation gives us dex code, the language of Android’s Dalvik Runtime.


Through each step of the process the original .NET debugging information is maintained, though of course it must be converted from the Windows/.NET PDB format to dex’s debug information format. dot42 uses the Android Debug Bridge to connect the Visual Studio debugging facilities


Android Libraries are accessed by directly referencing JAR files. “After compilation, your calls are redirected to calls into the original Android libraries.” Some mapping between types is needed, but that is largely addressed by the compiler. For example, java.lang.Boolean is mapped to C#’s Nullable.


Because dot42 emits dex code, there are some C# features that you will not be able to use. The most notable of these is user defined value types, a.k.a. structs. Since they don’t exist in Dalvik, there is simply no way to map them.


When using dot42, you’ll often need to decide between the C# and Android versions of common data structures. For example, should you use .NET’s List or Java’s ArrayList? According to Ewout Prangsma, developers should favor the Java version if they are concerned about memory and download size. Even though their implementation of List is basically a thin wrapper around ArrayList, it is still extra code that needs to be packaged and shipped to the phone.


dot42 is a commercial product that starts at 499 Euro per developer with the usual bulk licensing options.


(Source: http://www.infoq.com/news/2013/02/dot42)

Last week Opera announced that they were dropping development of their own Presto rendering engine and forking Webkit and V8 instead. Christian Heilmann provides some details and explains why this is a loss for web developers. “I always called Opera the Douglas Crockford of browsers as it was ruthless in its implementation of standards. If something didn’t work in Opera there is a good chance that you did something wrong.” (more: Christian Heilmann)

Well, original article states ‘7 Things Developers Should Know About SQL Server’, but #2 mention there is bullshit, the rest, think, it’s quite interesting reading.

Oh, by the way, did you ever used tips from http://support.microsoft.com/kb/920093 ?

Microsoft Azure’s cloud outperformed Amazon Web Services in a series of rigorous tests conducted by Nasuni, a storage vendor that annually benchmarks cloud service providers (CSPs).

Nasuni uses public cloud resources in its enterprise storage offering, so each year the company conducts a series of rigorous tests on the top CSPs’ clouds in an effort to see which companies offer the best performing, most reliable infrastructure. Last year, Amazon Web Services’ cloud came out on top, but this year Microsoft Azure outperformed AWS in performance and reliability measures. AWS is still better at handling extra-large storage volumes, while Nasuni found that the two OpenStack powered clouds it tested — from HP and Rackspace — were lacking, particularly at larger scales.

When you need to list quickly all your serial ports, you can use these simple lines in c#:

foreach (var p in SerialPort.GetPortNames()) {
Console.WriteLine(p);
}

It works both for Microsoft .NET and Mono frameworks, and somewhat similar to this shell command in *nix:

ls /dev/tty.*

Just appeared on CouchDB web site binaries for Mac OSX users, this build is for 1.2.1 release

You can find now JsonBridge on Facebook by visiting http://www.facebook.com/jsonbridge Code samples, downloads notifications and other related news will be posted on http://jsonbridge.com and Facebook both now.

JsonBridge client for ActionScript 3 got updated, Grab it from http://svn.skitsanos.com:8888/svn/sas3lib/ with demo/demo as your SVN credentials.
Today’s changes in ActionScript client is about latest support of JBAPs (JsonBridge Authentication Plugins) where you can use your own Authorization HTTP header to handle authentication.

Just to get you an very basic idea on how to use this thing in your Flex or ActionScript 3 application, here is the code sample for you, but let’s define our JsonBridge end-point URL:
private var urlJsonBridge:String = ‘http://jsonbridge.mywdk.com/jsonbridge/’;

Because we enabled JBAP in our web.config which look like this now:
<?xml version=”1.0”?>
<configuration>
  <appSettings>
    <add key=”jsonbridge.AuthEnabled” value=”true”/>
  </appSettings>
  <system.web>
    <compilation debug=”true” targetFramework=”4.0”/>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests=”true”/>
  </system.webServer>
</configuration>

we need to tell JsonBridge to use Authorization and pass to it new Authorization HTTP Header:
JsonBridge.url = urlJsonBridge;
JsonBridge.useAuthorization = true;
JsonBridge.authorizationHeader = new URLRequestHeader(‘Authorization’, ‘Simple demo:demo’);

And now we can perform the call to server side methods, for example we want to browse available server side assemblies:
JsonBridge.execute(‘_browse’, null, null, function (success:Object):void
{
textOutput.text = ”;
if (success.type == “error”)
{
textOutput.text = success.message;
} else
{
for (var i:int = 0, l:int = success.result.length; i < l; i++)
{
textOutput.text += (success.result[i] + ‘\n’);
}
}
}, function (failure:Object):void
{
textOutput.text = failure.message;
});

As you can see execute() method didn’t changed at all, so all your old applications can function with no changes required.

sas3lib.swc Download this file
JsonBridgeExample.zip Download this file
We just released new JsonBridge updates for .NET that finally allows you to have very flexible way of handling authentication for your REST requests. This way you can implement Basic Authentication or support for OAuth or any other type of Authorization you would like to have for your own web application. To enable JBAP (JsonBridge Authentication Plugin) you need to make sure your web.config has jsonbridge.AuthEnabled set to true, otherwise JsonBridge will ignore your Authorization header and continue executing your request in free mode.
web.config
  <appSettings>
    <add key=”jsonbridge.AuthEnabled” value=”true”/>
  </appSettings>

Then you need to write your own JBAP/plugin, which is pretty straight forward thing, you just need to make sure you keep the class path like JBAP.YourAuthenticationClassName so when JsonBridge with jsonbridge.AuthEnabled set to true will execute request it will look into HTTP header Authorization find the name of the Handler and will try to load JBAP.YourAuthenticationClassName.dll in order to execute validate method. Validate method accepts just one parameter.
So if your HTTP header looks like this:
Authorization: Simple demo:demo

JsonBridge will look for JBAP.Simple.dll invoke validate method and pass to it everything that goes after Simple, in my particular example it will receive demo:demo
If validate method will return false you will see “Authorization failed” error wrapped into JsonBridge reply of InvokationErrorType type. Otherwise, on true it will execute your request and return you result you expect from your invoked method.

Example of JsonBridge Authentication Plugin (JBAP)
namespace JBAP
{
public class Simple
{
public bool validate (string authHeaderValue)
{
var authPair = authHeaderValue.Split (‘:’);
if (authPair [0] == authPair [1])
{
return true;
}
else
{
return false;
}
}
}
}}

JsonBridge is available as Open Source contribution and you can grab it from our WDK10 SVN here:
http://skitsanoswdk.googlecode.com/svn/trunk/WDK10/ 
For developers that using Java instead .NET we ill provide access to Java sources a bit later these days. Older version you can grab from our labs SVN: http://svn.skitsanos.com:8888/svn/JsonBridge/java

jQuery client is ‘preloaded’ with JsonBridge, you can access it on your web application/site via simply typing http://yoursitename/jsonbridge/jquery.jsonbridge.js, you can see it as an example on http://jsonbridge.mywdk.com/jsonbridge/jquery.jsonbridge.js, you can also directly include it same way into your html like:

<script type=”text/javascript” src=”http://jsonbridge.mywdk.com/jsonbridge/jquery.jsonbridge.js” ></script>

We are glad to anounce that ActionScript 3 client for JsonBridge available as well and now it’s a part of sas3lib (available via SVN from http://labs.skitsanos.com:8888/svn/sas3lib). JsonBridge client available in com.skitsanos.net.remoting package of sas3lib.

It has jut one method: execute() which accepts following parameters:

  • classpath:String, 
  • method:String, 
  • params:Array, 
  • resultHandler:Function, 
  • faultHandler:Function

Example on how to use it:

var params:Array = [{location: 23, dateTo: ‘01/01/2011’, dateFrom: ‘03/18/2011’}];

var jb:JsonBridge = new JsonBridge();

jb.url = ‘http://mywebsite/jsonbridge/’;

jb.execute(‘Reporting.ReceivedVolumeReport’, ‘getTotalsForPackagingItems’, params, function(e:Object):void

{
    trace(e.toString());
}, function(e:Object):void

{
    trace(e.message);
});

Just wanted to share couple of notes on what’s cooking wond here at Skitsanos Labs… Recently i was banging my head into a wall on where to find some simple and effective way to call remote methods on server side and return back results to my application written in JavaScript and in Adobe Flex. There are quite many frameworks that allows you to do RPC or Remoting, but none of them actually was simple enugh to jump start any application with minimal effort, and we had in mind at least following list if requirements:

  • We should keep existing business logic as is, with no modifications to existing classes and methods;
  • We need access to server side classes and their methods via RESTful interface and provide output in atleast JSON format;
  • Keeping in mind that we are going ‘mobile’ on some projects, we need to make sure that there won’t be any need to implement any new functionality to cover mobile clients;
  • We need it workign from any programing language, but first ones to test against were JavaScript (with jQuery) and Adobe Flex/Aswing/ActionScript 3
  • We need support for service methods like browse list of server side assemblies, list their classes and methods.
  • We need to keep and reuse existing functionality provided by web server*.
  • We need to have support for ‘simple’ and ‘complex’ class method parameters both.

So, last 2 days i spend on making JsonBridge that goes to be part of next WDK10 (set of in house libraries we use in all projects, mainly made for modular content management engine). As result I have simple solution, that we can use in all projects we are working on. JsonBridge works with GET and POST methods, calls that require any method parameters, can be called with GET, calls that require some parameters sent should be done via POST.

Example of the method that can be called via GET:

public string execute()
{

return “WDK.API.JsonBridge.Text.execute() works!”;
}

I can call this method like this:

http://jsonbridge.vpn/jsonbridge/WDK.API.JsonBridge.Test/execute

Where:

  • WDK.API.JsonBridge.Test is the Class path 
  • execute - is the method within this class

Example of the method that requires POST:

public string executeWithComplexParam(string param, TestParamType param2)
{

return “Your param: ” + param + ” and param2.name: ” + param2.name + “, param2.status: ” + param2.status.ToString();
}

As you can see it has 2 parameters, one ‘simple’ and one ‘complex’ type, to invoke this method on server i just need to call URL like this:

http://jsonbridge.vpn/jsonbridge/WDK.API.JsonBridge.Test/executeWithComplexParam

and post in request body JSON array of parameters:

[
“my first parameter”, 
{“name”: “zz”, “status”: “200”}
]

JsonBridge will analize number of parameters you sent, their types and so on and when everything meets invocation criteria it will call/invoke server side method and return you result.

Like this in my case:

Your param: my first parameter and param2.name: zz, param2.status: 200

Basically that’s it.

You can see it in action at this simple demo: http://jsonbridge.mywdk.com/