FeedReader pre-alpha is out

by 15. January 2010 16:47

Try it now! – Note: it’s still buggy.

I’ll write about changes in original ExtJS FeedReader as soon as I can. Stay tuned! However you can still grub plain (not minified) Js from server but note this is pre-alpha quality code. ALSO: this installation uses my home PC as mongodb host.

Tags: , , ,

My code

Reopen closed tabs on ExtJS TabPanel and autoDestroy

by 5. January 2010 00:58

Basically when you close a tab TabPanel completely destroys it by default (and you can’t reopen closed tab).

To override this behavior add autoDestroy: false to your TabPanel settings object.

But when you try to close a tab you will see  something like this:

autoDestroy_before

That is, tab header is disappeared but the body still visible.

The problem is that you should process remove operation by yourself. Especially if you still want to hide tab body after closing the tab. To do this add two event handlers:

listeners: { 
            remove: function(tp, c) { 
                c.hide(); 
            }, 
            add: function(tp, c) { 
                c.show(); 
            } 
        }

autoDestroy_after

Tags:

IT | Software

AG_E_UNKNOWN_ERROR (code 4004) while referencing custom control in Silverlight

by 28. December 2009 16:20

AG_E_UNKNOWN_ERROR

Check all namespace declarations in your Generic.xaml.  If you find something like this:

xmlns:local="clr-namespace:Your_namespace" you should add assembly reference as well:
xmlns:local="clr-namespace:Your_namespace;assembly=Your_assembly"

AG_E_PARSER_BAD_TYPE

Maybe you forgot add reference to assembly(and all its references) with custom control?

Error: Unhandled Error in Silverlight Application Code: 2103 Category: InitializeError Message: Invalid or malformed application: Check manifest

Right click on project, go to properties, and select the valid name under "Startup object"

Tags: ,

IT | Software

Building the simplest online feed reader (Part 1: Feed Downloader)

by 27. December 2009 01:07

Try it now! – Note: it’s still buggy.

I’ll write about changes in original ExtJS FeedReader as soon as I can. Stay tuned! However you can still grub plain (not minified) Js from server but note this is pre-alpha quality code. ALSO: this installation uses my home PC as mongodb host.

 

What shall We do?

In this part we will develop schema for our mongodb-based data store and a small console program that will download and update feeds for us.

Database schema

MongoDB specific thoughts

While building that chema we need to keep in mind that we use MongoDB. So we can properly utilize its features.

1) It’s schema free – that is we can add new keys to document whenever we want it.

2) Every document has its own unique id.

3) Every document store all the keys – that is length of the keys is what is important.

3) We can store collections within documents.  But retrieving a document is kind of atomic operation – you can’t get just a part of the document.

4) Indexes make retrieving fast but under some conditions they slow down the writing. And their creation ALWAYS locks entire database.

More...

Tags: , , ,

My code

Building the simplest online feed reader (using ExtJS, ASP.NET MVC and MongoDB)

by 27. December 2009 00:30

Try it now! – Note: it’s still buggy.

I’ll write about changes in original ExtJS FeedReader as soon as I can. Stay tuned! However you can still grub plain (not minified) Js from server but note this is pre-alpha quality code. ALSO: this installation uses my home PC as mongodb host.

 

What an online feed reader is? Definitely it’s a web application. The application that has at least two components. The components are listed here:

  • User interface (executed in browser, ExtJS)
  • Controller (executed on server, ASP.NET MVC)
  • Data store (located somewhere, MongoDB)
  • Feeds downloader (of course we can update our feed only when browser request occurs, but we can lose some entries for example in case of a long pause in usage of the reader)
  • And last but not least is a syndication library (Argotic framework)

Our feedreader will have the following features:

  • Feed list (adding, deleting, feeds)
  • Feed items viewer
  • Standalone feeds downloader

INTRODUCTION

More...

Tags: , ,

My code

How to serialize an object to MongoDB Document in C#

by 20. December 2009 01:25

Although mongodb-csharp diver syntactically allows you to add to document every object (Document’s Append and Add methods have (string, object) signature) you can’t add an arbitrary object just because the driver only supports basic data types (numbers (but not all), strings) and Enumerations. But if you want to do something like this:

House house = new House("Springfield", new Room[]
            {
                new Room{
                    Length = 2,
                    Width = 2
                },
                new Room{
                    Length = 3,
                    Width = 3
                }
            });

to get something like this

{     
    "Address": "Springfield",     
    "Rooms": [
        { "Length": 2, "Width": 2 }, 
        { "Length": 3, "Width": 3 }      
     ] 
}

Well, now we can do it with MongoSerializer.

So what can we do with MongoSerializer? 
Just the same things as with XmlSerializer - serialize and deserialize (well, for this time just serialize :-)
However there're some interesting side effects:
Due to the fact that mongo documents actually stored in a MongoCollection we can use all mongo features - indexing, very fast queries, etc.

Basically, with MongoSerializer you can convert regular .NET object to key/value representation:
Document Serialize(Object)
With this basic operation you still have to add documents to MongoCollection manually.

House house = new House("Springfield", new Room[]
{
    new Room{
        Length = 2,
        Width = 2
    },
    new Room{
        Length = 3,
        Width = 3
    }
});

Console.WriteLine("Now we will convert House instance to Document\r\n");
Document document = house.Serialize();

// let's see the string representation
Console.WriteLine(document.ToString());
Console.WriteLine("Press Enter key\r\n\r\n");
Console.ReadLine();

Console.WriteLine("now we'll convert an atomic value\r\n");
document = 1.Serialize();

// let's see the string representation again!
Console.WriteLine(document.ToString());

Console.WriteLine("Note that atomic object have added to the document with the empty key");
Console.WriteLine("Press Enter key\r\n\r\n");
Console.ReadLine();

Console.WriteLine("ok, how to convert a collection?\r\n");
var rooms = house.Rooms;

document = rooms.Serialize();

Console.WriteLine(document.ToString());
Console.WriteLine("Well again, collection was edded with the empty key");
Console.WriteLine("Press Enter key\r\n\r\n");
Console.ReadLine();

Console.WriteLine("To properly convert an enumeration or a collection you need to convert its members one-by-one on a loop. Or just use anonymous type: new { rooms = rooms }\r\n");

document = new { rooms = rooms }.Serialize();
Console.WriteLine(document.ToString());

Console.WriteLine("The End.");
Console.ReadLine();

MongoSerializer.zip (292.88 kb) [Downloads: 25]

Tags: ,

My code

My ASCII85 encoding implementation

by 18. December 2009 23:56

As I tweeted before i have found a c# ASCII 85 encoding implementation. But the link was broken, so i decided to write it by myself. And here it is:

public static string ASCII85(this byte[] data)
{
    // padding 
    int tail = 4 - data.Length % 4;
    byte[] padded_data;

    if (tail != 4)
    {
        padded_data = new byte[data.Length + tail];
        Array.Copy(data, padded_data, data.Length);
    }
    else
    {
        padded_data = data;
    }

   List result = new List(padded_data.Length);

    for (int i = 0; i < padded_data.Length; i += 4)
    {
        uint block_int = 0;

       /* for (int j = 0; j < 4; j++)
        {
            block_int |= (uint)padded_data[i + j] << ((3 - j) * 8);
        }*/

        /*for (int j = 3; j >= 0; j--)
        {
            block_int |= (uint)padded_data[i + (3 - j)] << (j * 8);
        }*/

        block_int = (uint)(padded_data[i] << 24) | (uint)padded_data[i + 1] << 16 | (uint)padded_data[i + 2] << 8 | (uint)padded_data[i + 3];

        if (block_int == 0)
        {
            result.Add((byte)'z');
        }
        else
        {
            uint n = block_int / 52200625;
            result.Add((byte)(33 + n));
            block_int = block_int - n * 52200625;

            n = block_int / 614125;
            result.Add((byte)(33 + n));
            block_int = block_int - n * 614125;

            // if data was padded how to get rid of tail? 

            n = block_int / 7225;
            result.Add((byte)(33 + n));
            block_int = block_int - n * 7225;

            n = block_int / 85;
            result.Add((byte)(33 + n));
            block_int = block_int - n * 85;

            result.Add((byte)(33 + block_int));
        }
    }

    return Encoding.ASCII.GetString(result.ToArray());
}

Tags: ,

My code

Thoughts on MongoDB indexes and auto increment

by 8. December 2009 18:57

If you come(as i do) from SQL world the first thing about indexes you may ask about is auto incremented indexes. Personally i used it as an unique id in relationships such as author->article. However in MongoDB we can use extremely useful built-in, auto generated, unique ids (such an id always appended to the document with key “_id”).

In SQL word id is usually an 4 byte integer, but in Mongo it’s 12 bytes long.

According to the documentation(http://www.mongodb.org/display/DOCS/Object+IDs) ObjectId generator uses increment.

Anyway, some very interesting links:

http://jira.mongodb.org/browse/SERVER-195

Very detailed discussion on relations for SQL guys

Note: in mongodb-csharp ObjectID type is called Oid.

UPDATE

Although ObjectIds are unique you can’t (at least not always) use it for (date) sorting. If you insert records from many machines (or processes) MongoDb doesn’t guarantee that they will constantly grow since internally it uses memcmp function to compare _ids

When the _ids compared memcmp firstly compares time when they created. Usually ObjectID generator have 1 second resolution. If time is the same then machine ids compared. In mongodb-csharp driver for example, machine id is the first 3 bytes of HostName md5 hash. As you can see the result of comparison even at this point is unpredictable.

Tags:

IT

How to install M-Audio delta drivers on Server 2008 R2

by 4. December 2009 17:49

When i tried to install latest Windows 7 drivers on my PC(currently running on MS Server 2008) I saw the following message “The operating system is not supported by …”. How to trick the installer? Well, solution comes from this post. Simply we need to open unpacked installer in Orca – a tool for MSI installers editing and delete some version checks.

Tags: ,

IT | Life

3 wtf Internet Explorer Javascript Errors

by 26. November 2009 23:43

 

  • Invalid property value. bodyStyle: 'background-color: <-space_here#dfe8f7;'. Without space it works perfectly. You can find bodyStyle setting in ExtJs control constructors.
  • Unkown runtime error Ext.DomHelper.overwrite("_id_here_", '       ');. You cannot set innerHTML of table in Explorer directly. Use deleteRow/appendRow methods.
  • Invalid source HTML for this operation (also known as Unknown runtime error) $('span').innerHTML += <div>...</div>''. You cannot insert a block element inside a non-block element

For me, these errors became a revelation =). Mainly because of the fantastically useful error messages.

Tags: , ,

IT | Software

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

My projects

About the author

Name: Ilya Khaprov (rus Илья Хапров)

Age: 23

Sex: Male

I'm a postgraduate (an "aspirant" in Russian terminology see Wikipedia for details) at Bryansk State Technical University.

I'm working with .Net since 2004. Also i like lisp.

My research interests lie in the area of Intelligence. In particular i am studing personal information filters, ontology learning, and some other stuff.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in  anyway.

© Copyright 2009

Recent Visitors