This blog is up… again

by 20. February 2011 07:52

Now running on #ec2 #ubuntu instance using #mono

Tags: , , ,

Life

MongoDB and C# syntax

by 10. March 2010 02:42

Normally while using mongodb-csharp driver you have to add new fields with sequential Appends.

Well, personally I prefer

Document doc = new Document(); 
            doc.Fill( 
                Width => 100, 
                Height => 200, 
                Attributes => new Pairs{ attr1 => 1, 
                                         attr2 => 2 });

over

          

Document oldstyle = new Document() 
                .Append("Width", 100) 
                .Append("Height", 200) 
                .Append("Attributes", new Document().Append("attr1", 1) 
                                                    .Append("attr2", 2));

Do you like the first case? Try MongoDB C# eXtras

Tags: ,

My code

How to break Google Chrome

by 9. March 2010 23:47

Wanna get "Uncaught SyntaxError: unexpected token new" error?

Just write something like this:

var obj = {
    new: true
}
 see? simple isn't it?

Tags: ,

Software | Life

LiveLisp is still alive

by 28. February 2010 02:14
What is LiveLisp?

It's my try to implement CommonLisp on .Net platform. Checkout new commits.

And for what LiveLisp is suitable now?

Well, it's very buggy actually. but it can calculate classic Fibonacci sequence. Also you actually can call any static or instance CLR method, reference assemblies and so on. And it has many Common Lisp related functions and some macros like prog and prog*.


Stay tuned!

Tags: ,

My code

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: 199]

Serializer, Asp.net Membership and Role providers... and may be something more by now

 

Tags: ,

My code

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About the author

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

Age: 25

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 2011

Recent Visitors