Jquery DataTables

October 20th, 2011 No comments

икона за подаръкA very useful jquery plugin to display data.

http://www.datatables.net

Categories: JavaScript Tags: , ,

My MVC Application

June 3rd, 2011 No comments

Православни икониикониAfter getting started with ASP.net MVC , watching the tutorials I ended up creating quite few “Hello world” MVC applications. Then added few database into it. It seemed cool and easy. But going a bit beyond hello world, there is a different wild world of techniques and technologies.Trying to find some best practices I got started from here.

Things I like to do with default generated MVC code from Visual studio:

1. Add an IOC container

I use Windsdor Castle that can be found here . The tutorial there will show how to add Windsdor IOC controller to the MVC 3 application. It shows how to download and reference Windsdor but I prefer Nuget way.

  • install-package Castle.Windsor

2.  Log4Net for logging

There is a Windsdor way of plugging in Log4Net. Its package can be referenced using nuget :

  • install-Package Castle.Windsor-log4net

Then after creating necessary installer class for Log4Net, a log4net.config file and its related table can be created from here.

3. Membership Framework

I like membership framework for creating login.The default template has sample code for register/login.But sometimes it is not enough, you may use your own login while extending from MembershipProvider.

4. Separate Entity Model and View Model

In one of the small MVC projects I had some data models created from Model First approach. Till some point the output data required was in same format as the Entities but then the requirements started changing. At that point, it did not made much sense to change the database itself but rather use an adapter. So as a rule, the models that Views use are separate from the models that EF uses. It also helps to avoid some problems that occurs when using data models entities directly as View model.

View < – > ViweModel < …….. > Data Model <-> Database

.. more to be added.

 

 

Categories: C# Tags: ,

QR image bookmarklet

May 23rd, 2011 No comments

Scenario: QR images has been use for ease of opening URL’s in phone.

There are terribly long ugly URLs which you have no way to copy except u really copy paste or firefox sync or XYZ sync it. Or you could copy the URL and generate a goo.gl link and then QR image from there.

You can run this bookmarkleet ( just browse any URL and when you are there click this ) and all links will have a QR image on right clicking the link.

Drag the following link and drop it in your browser’s bookmark.

QR Image

Thanks Manish for asking me to blog about it.

Categories: Blogging Tags:

Ajax File Uploader

February 27th, 2011 No comments

Started with a hopeful new HTML5 FileReader API and ended with a frustrating results, finally ended up with accepting this open source script.

https://github.com/valums/file-uploader

It Works.

Categories: JavaScript Tags:

facebook C# sdk is on nuget

February 22nd, 2011 No comments

Facebook C# SDK is on nuget with package names

Facebook, FacebookWeb, FacebookWebMvc

But still have some bugs Sad smile

Categories: C#, Facebook Tags:

Storing array in localStorage

February 22nd, 2011 No comments

Found here http://stackoverflow.com/questions/3357553/how-to-store-an-array-in-localstorage

HTML5’s window.localStorage can store anything. But for storing an array it’s a bit tricky.

To store an array suppose:

var names = [“A”,”B”];

Storing :

localStorage.setItem("names", names.join(‘|||’)); 

Retriving :

var names = localStorage.getItem("names").split(‘|||’);

Categories: JavaScript Tags:

JavaScript custom sort method to sort array of objects

February 22nd, 2011 No comments

 

suppose “data” contains an array of object :


{"data": [
      {
         "id": "1",
         "name": "B"
      },
      {
         "id": "2",
         "name": "A"
      }] }

Then the sort() method of that array can take a custom function just

like IComparer in C# and sort the array in-memory. 

 

var data = doc.data.sort(function(me,him){
		return me.name.localeCompare(him.name);
	});

This will sort the objects above comparing with its name property and 

results into a sorted array of objects with ascending name property. 

 

This blog is for my own reference. 
Categories: JavaScript Tags:

Classes for RSS in C#

February 18th, 2011 No comments

Was about to write code for RSS thingy but then I found this :

In Namespace :  System.ServiceModel.Web
			

 

XmlReader reader = XmlReader.Create("http://localhost/feeds/serializedFeed.xml");

SyndicationFeed feed = SyndicationFeed.Load(reader);

 

MSDN source : http://msdn.microsoft.com/en-us/library/bb515814%28v=VS.90%29.aspx

Categories: C#, JavaScript Tags:

Goo.gl has an API

February 8th, 2011 No comments

image

Google’s URL shortening service http://goo.gl is the most fastest service available.

It had been released before operable only from google toolbar and no API, but some people did some hack and extracted the JavaScript that it used.

Now, it does provide a neat API. Smile

With goo.gl we can not only create short url but also a QR image that can be used by barcode scanner for mobile devices.

An example of post method :

curl https://www.googleapis.com/urlshortener/v1/url \
  -H 'Content-Type: application/json' \
  -d '{"longUrl": "http://www.google.com/"}'

would have a JSON response as : 
{
 "kind": "urlshortener#url",
 "id": "http://goo.gl/fbsS",
 "longUrl": "http://www.google.com/"
}

A QR code can be generated just adding .qr to the short URL .

http://goo.gl/fbsS.qr

 

 

Categories: Blogging, Programming Tags:

My blog is back

February 7th, 2011 No comments

My blog was down for almost 10 days now. My web hosting moved my websites to new system to support a new control panel so that I can ….. do few things better way like switching between .net versions for ASP.Net. Support tickets went back and forth but sadly they did not take care of my blog database, I had to backup and restore it myself. Aaaw … I still need to restore few other databases and apps that used those databases, I dont even remember all of them. I created them along the timespan of 4 years, since I bought this web hosting.

Well at least I brought my blog back :) . Still as I remember, the sites that are not working are

t.bipins.net
notes.bipins.net
facebook.bipins.net
chatis.finally.in
*.finally.in :(

and few other that I cant remember right now.

(jobs)index3.html is fixed, thanks to a friend who reported it was not working.

Sorry for my friends who used some of my web pages.

Categories: Blogging Tags: