Posts

A guide for modeling a graph database - A lunch with Neo4J chief scientist Jim Webber, London

Since the invention of NOSQL databases, it gets more and more attention from the developer community. One of the remarkable and unique databases exists in this topic of NOSQL is the graph database of NEO4J, an open-source database which stores the data as a Graph. Modeling a graph database is quite different than modeling the regular RDBMS database, and even from other NOSQL databases such as key-value collections. We got used to identifying the molecularity of the data and save it as the columns, joining similar data together into tables. But since Neo4J is a flexible graph database, this case does not work there. In order to model the data, we need to identify first the queries that we're about to run on the database. These queries will form the basic logical sentences which are the keys of modeling the database (more about that coming up in a second). We need to identify where to store each piece of information: - as a node - as an edge - as a property of a node or of ...

Javascript, animation and easing functions

I recently had to create an animation, which obey to the laws of physics, using javascript and HTML5. Among the gravity and free falling, one of these animations had to also apply sort of bouncing and elastic laws. After creating it first with CSS3 and HTML, we realized that most of the Android devices does not support it fully yet. Especially versions prior to Ice Cream Sandwich, such as Android 2.1, 2.2, 2.3 and lower (Froyo and its siblings). So, I had to transfer everything into HTML5 Canvas, and instead of applying the css-transitions, I had to implements everything alone. The first website I encountered and would like to highly recommend is Timothee Groleau's easing generator which can be found here : http://timotheegroleau.com/Flash/experiments/easing_function_generator.htm Originally made for Flash - but can easily adopted to Javascript HTML5 too. The output of his generator is basically a function describes a certain movement of an object. Such...

TreePanel generated from TreeStore

Apparently, generating a treePanel from a treeStore is not 'out-of-the-box' like generating a grid or even generating tree from static json in Ext-JS. In addition, at the moment there are not a many examples out there that explains how it should be done. Most of the examples are using a static JSON (memory). But what if you are using a store with an already-made JSON which you need to customize to be a tree? listeners to the rescue The way to make it happen, is to alter the store a bit. we start by defining a store as usual: Ext.define('MyTreeStore', { extend: 'Ext.data.TreeStore', config: { someConfig: 0 }, constructor: function (cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ autoLoad: true, storeId: 'MyTreeStoreID', root: { expanded: true }, proxy: { type: 'rest', url: 'http:/...

C#, Entity Framework, WCF and JSON serialization

Ever tried to serialize Entity Framework with WCF? Have you tried it with the Lazy-Initialization feature? And how about the Proxy Creation Enabled? There's a problem of circular reference if one table is referencing another table - which referencing the first one. We have had a great deal of problems with it. We even tried to consult an external expert of Entity Framework who simply told us it's impossible to serialize it on WCF. oh darn... :( We tried many solutions before we gave up: like that one: http://geekswithblogs.net/danemorgridge/archive/2010/05/04/entity-framework-4-wcf-amp-lazy-loading-tip.aspx and that: http://blogs.microsoft.co.il/blogs/gilf/archive/2011/10/17/avoiding-circular-reference-for-entity-in-json-serialization.aspx We even used t4templates to create a whole new set of flattened objects (!!!) But it doesn't really make life easier as one has to load separately each and every object. But this was not what we were looking for. We needed a solution that...

ExtJS 4.0 - Class system, object inheritance and config

Recently we've started using the new Ext-JS 4.0 class system. one of the obstacles I came across with was using the configuration while making inheritance. On most of the examples in the web - it works seamlessly perfect. but what happens when you try to extend an existing object? for example, 'Ext.panel.Panel' ? Suddenly - weird stuff happens and it doesn't work any longer. So for example: Ext.define('ProductionMap.popup.serverExplorer', { extend: 'Ext.panel.Panel', config: { ParameterConfig: '', }, constructor: function (cfg) { this.initConfig(config); return this; }, initComponent: function () { ... } will give an error. took me an hour to figure it out - but I found the solution and it's REALLY simple. It's all about the constructor: instead of that code, use: constructor: function (cfg) { this.initConfig(config); this.callParent([config]); return this; }, ...

Charts, JSON and ExtJS

A bit late, I admit, but finally I've started using Sencha's ExtJS framework. The first project I was executing was involving charts with JSON data loaded from a C# ASP.NET WCF service. I have encountered several problems and a lack of proper documentation. Many of the solutions were finally found in another websites and forums but there was no blog post I have found that had everything together in one example. So I'm proud to be one of the first who does that. I will also describe the problems I've encountered and of course - the solutions. In ExtJS, the code is created in Windows , Panels or Forms . The latter, Form , can not be added to Asp.net page as it regenerates a <form> tag, which can not be placed under the already-generated <form runat="'server'"> of the asp.net. I've used the Ext.Panel then, in an external JS file, like so: Ext.onReady(function () { var myPanel = new Ext.Panel({ }); }); inside the panel, among the rest o...

Image Resizing & Cropping on the fly in .NET - high quality

While developing a CMS for small gallery websites, I decided to store only the original uploaded image and not to create a thumbnail upon uploading. I didn't want, of course, to use the html resizing feature, especially not while uploading high res images. Instead, I created a generic handler that creates the thumbnail image on the fly. Not only this handler knows how to resize the image, but also to crop it, in case I want all the images to be on a fixed ratio of width and height. So, how is it done? There are many blog posts of resizing images on the fly. where you'll find a code similar to this: public static Bitmap CreateThumbnail(Bitmap loBMP, int lnWidth, int lnHeight) { System.Drawing.Bitmap bmpOut = null; try { ImageFormat loFormat = loBMP.RawFormat; decimal lnRatio; int lnNewWidth = 0; int lnNewHeight = 0; //*** If the image is sm...