Ashish's Blogs
Blogs on .NET and LAMP Technologies
There's often more than one correct thing.
There's often more than one right thing.
There's often more than one obvious thing.
--Larry Wall
Friday, February 17, 2012
Good mobile development company for school apps
http://www.crescerance.com/
Tuesday, April 05, 2011
Back to technology
Monday, December 06, 2010
Is NoSQL a game changer?
http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html
Sunday, July 12, 2009
Saturday, July 04, 2009
WCF Sessions
In WCF, sessions are seen as group of ordered conversation in oppose to object centric behavior in ASP.NET. If the messages are exchange with same contract and contract specifies the session, a session is established for these messages. Following are the major differences between asp.net session and WCF session.
ASP.NET | WCF |
Session is initiated by the server. | Session is initiated and terminated by the client. |
Ordered processing (Messages are processed in sequence). | Unordered Processing |
Provides general data storing mechanism | No such mechanism |
In simplest form, we can specify session in following way:
[ServiceContract(SessionMode.SessionModeRequired)]
Public interface ICalculator { …}
WCF session has resemblance with local object. So by default, all subsequent requests are handled by same service instance.
Initiating operations are like constructors and Terminating operations are like destructors and requests between these two are like operation called on object.
[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples", SessionMode=SessionMode.Required)]
public interface ICalculatorSession
{
[OperationContract(IsOneWay=true, IsInitiating=true, IsTerminating=false)]
void Clear();
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void AddTo(double n);
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void SubtractFrom(double n);
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void MultiplyBy(double n);
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void DivideBy(double n);
[OperationContract(IsInitiating = false, IsTerminating = true)]
double Equals();
}
For detail: WCF Sessions.
Monday, June 08, 2009
C# 4.0 – the features I like most.
C# 4.0 is coming up with following new features as of its documentation on MSDN now:
- Dynamic lookup (You don't need to worry about type of target; Runtime figures out what exactly the operation means to the object)
- Runtime lookup (Operation is dispatched through reflection at runtime)
- Named and Optional Parameters (default values can be set to function argurments)
- New features in COM Interop – Compiling without PIAs, Omitting Refs, Dynamic Import
- Variance (Automatic assignments where it is safe in case of Generics)
- Covariance (The new IEnumerable and IEnumerator interfaces, now sequence of strings is also sequence of objects; very useful in Linq queries)
- Contravriance (Type parameters can be declared as "in" in Generics; IComparer<object> can be used where we are expecting IComparer<string>)
Though I have been using dynamic languages like python and perl, I really need to explore features of Dynamic lookup. As of developer of so many APIs, I can say that Named and Optional Parameter feature is really cool. It will provides enormous flexibility to API developers as well as API users. Last one is Compiling without PIAs. The developers who have worked on PIA can only know how useful this feature is. It gives big relief from versioning and loading large assemblies.
Wednesday, May 27, 2009
Regular Expression - using back reference in javascript
var test = "personal personal computers and super computers computers";
test = test.replace(/(\w+)\s+\1/g,"$1");
alert(test);
Thanks to Cracki for pointing out difference between back reference and back tracking.
Friday, March 27, 2009
Sixth sense technology
Technology Breakthrough by an Indian !!!!
http://www.ted.com/index.php/talks/pattie_maes_demos_the_sixth_sense.html
Friday, March 20, 2009
.NET String comparison benchmarking
Sunday, March 15, 2009
Regular Expression Cookbook
I have been waiting for this Regex cookbook for long time. I will make sure that I am the first person to get this book from store as soon as it is available.
http://www.amazon.com/gp/product/0596520689?ie=UTF8&tag=slfb-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0596520689
Thursday, March 05, 2009
IE 8 - New Ajax and DOM storage Features
- New Ajax Navigation
- DOM storage upto 10 MB
- Online/Offline detection in Javascript
- XmlHttpRequest Timeout
http://msdn.microsoft.com/en-us/magazine/dd458804.aspx#id0100180
Wednesday, March 04, 2009
Perl - Find and replace without Regex
my $pattern = '[lerp]+';
my $target = 'this is [lerp]+ perl';
(my $output1 = $target) =~ s/${pattern}//g;
(my $output2 = $target) =~ s/\Q${pattern}//g;
print $output1 , "\n";
print $output2 , "\n";
Ouput:
this is []+
this is perl
Becoming a great writer !!!
When asked to define "great" he said "I want to write stuff that the whole world will read, stuff that people will react to on a truly emotional level, stuff that will make them scream, cry, wail, howl in pain, desperation, and anger!"
He now works for Microsoft writing error messages.
Friday, January 09, 2009
Some common regexs
Sunday, November 30, 2008
Paging in SQL Server 2005 using OVER
USE northwind
DECLARE @startIndex INT,
@pageLength INT
SET @startIndex = 6
SET @pageLength = 5
SELECT *
FROM (SELECT o.shipname,
o.shipaddress,
Row_number()
OVER(ORDER BY o.customerid DESC) AS rownumber
FROM orders AS o
JOIN [order details] AS od
ON od.orderid = o.orderid
WHERE o.customerid = 'VINET') AS shipmentdetail
WHERE rownumber BETWEEN @startIndex AND (@startIndex + @pageLength - 1)
Sunday, November 23, 2008
Creating a user and giving permissions in database
Sometimes we need to create special users for our database. For example, in one of my applications, I need to provide appropriate permissions for remote server window service (which is running as a local system account on remote server), so that it can connect to my database and can perform read-write operations. I found following links helpful for understanding basics of SQL server security:
http://vyaskn.tripod.com/sql_server_security_best_practices.htm
http://msdn.microsoft.com/en-us/library/ms187750.aspx
To cut long story short, following is SQL command to create and give read-write permissions to remote machine. Suppose remore server name is 'TESTDOMAIN\testserver'.
GoGO
IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname = N'testdomain\testserver$')
CREATE LOGIN [testdomain\testserver$] FROM WINDOWS
GO
IF NOT EXISTS (SELECT * FROM dbo.sysusers WHERE name = N'testdomain\testserver$')
CREATE USER [testdomain\testserver$] FOR LOGIN [testdomain\testserver$] WITH DEFAULT_SCHEMA=[dbo]
GO
GRANT CONNECT TO [testdomain\testserver$]
EXEC sp_addrolemember 'db_datareader', 'testdomain\testserver$'
EXEC sp_addrolemember 'db_datawriter', 'testdomain\testserver$'
GO
Saturday, November 15, 2008
Mime Types for Office 2007 documents
+---------------------------------------------------------------------------+-------+
| application/vnd.openxmlformats-officedocument.wordprocessingml.document | .docx |
| application/vnd.openxmlformats-officedocument.wordprocessingml.template | .dotx |
| application/vnd.openxmlformats-officedocument.presentationml.presentation | .pptx |
| application/vnd.openxmlformats-officedocument.presentationml.slideshow | .ppsx |
| application/vnd.openxmlformats-officedocument.presentationml.template | .potx |
| application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | .xlsx |
| application/vnd.openxmlformats-officedocument.spreadsheetml.template | .xltx |
+---------------------------------------------------------------------------+-------+
Example of IEnumerable and Yield
Thursday, October 16, 2008
Using Resource files in Web Service (.NET 3.5) and Regular expression with LINQ
Those who has tried to use resource file in ASP.NET web service know well there is issue in using resource files in web service. Following code snippet targets 3 points:
1. Using resource file in web service or HttpHandlers.
2. Regular expression for converting resource strings with respective localized strings
3. LINQ integration in Regular expression.
Suppose placeholder for resource string in text is like ({BR[MyResourceString]BR}) . Following function will return localized string.
*/
public static string LocalizedHTML(string inputHtml)
{
if (string.IsNullOrEmpty(inputHtml)) return "";
Regex reg = new Regex(@"\(\{IA\[(.*?)\]IA\}\)", RegexOptions.Multiline | RegexOptions.Singleline
| RegexOptions.IgnoreCase | RegexOptions.Compiled);
System.Resources.ResourceManager RM =
new System.Resources.ResourceManager("Resources.Language",
global::System.Reflection.Assembly.Load("App_GlobalResources"));
return reg.Replace(inputHtml, m => (!string.IsNullOrEmpty(RM.GetString(m.Groups[1].Value)) ? RM.GetString(m.Groups[1].Value) : m.Value));
}
Monday, October 13, 2008
Finding installed FTS IFilters on SQL 2005
Saturday, August 30, 2008
10 Myths about Open Source Software in Business
Saturday, August 16, 2008
Easy log parsing with FileHelper
The idea is very simple
You can strong type your flat file (fixed or delimited) simply describing a class that maps to each record and later read/write your file as an strong typed .NET array
Sunday, August 03, 2008
I want a better...
Every block - next level of public data processing
"EveryBlock is a new experiment in journalism, offering a Web "newspaper" for every city block in Charlotte, Chicago, New York, Philadelphia and San Francisco — with more cities to come. Enter any address, neighborhood or ZIP code in those cities, and the site shows you recent public records, news articles and other Web content that’s geographically relevant to you. To our knowledge, it’s the most granular approach to local news ever attempted."