Pages

Tuesday, May 19, 2015

Locally debugging Paypal's Instant Notification Payments via ngrok

I was working on a personal project and needed to accomplish some specific requirements when clients purchased an item from the website. Now, Paypal has something called Instant Payment Notification (IPN) which is a mechanism by which Paypal makes an Http Post to any url you choose, and in that post it sends you some vital information about the financial transaction (more information on Paypal's IPN here).

The problem that I was having was that I was not able to locally debug the code that I had written for the URL that would receipt Paypal's Http Post, and the reason is that in your Paypal's business account, you are not allowed to enter a "localhost" type of url. So when you go to Paypal, log in and go to Profile -> My Selling Tools -> Instant Payment Notifications, you can then specify the URL where Paypal will post the requests and this URL is not allowed to be localhost.

Thursday, October 2, 2014

Evaluating similarity between strings. Jaro-Winkler implementation in C#

We recently had a requirement where our application had to let the user know about existing trading security names from the database that were "similar" to what the user was trying to import into the system.

Saturday, August 2, 2014

Automatically setting READ UNCOMMITTED isolation level in LINQ Contexts

We recently decided to set a READ UNCOMMITTED transaction isolation level for our queries to the database and we wanted to establish it at the Linq Context level so that all of our "Select" queries would apply it by default.

Reading table records in SQL temporarily locks them until the query finishes its execution and all the data is returned to the client. This locking may slow down the execution times of other competing queries on the same table. We had one particular query in one table that would normally take 10 - 12 seconds when executed alone. As soon as you had that same query competing with 35 other threads it would take anywhere between 60 to 120 seconds.

Friday, December 13, 2013

Waiting for all asynchronous tasks to finish

We recently had to revisit one of the reports of our system (a financial solution) because it was taking too long, anywhere between 20 to 40 minutes depending on the size of the Mutual/Hedge Fund Company). Basically, the report contained information about the positions of each account in a fund, things like Units held, Average Cost, Market Value, Series. Unfortunately, these numbers cannot be obtained through simple SQL aggregation functions like SUM or AVG and crunching the numbers results in an exercise a little harder than that which includes going through the transactions history of each account.

Monday, April 22, 2013

Set UpdateCheck to Never programatically for LINQ Data Contexts

By default when you generate a LINQ Data Context in Visual Studio, every column of every table has the UpdateCheck property set to Always. The implication of this is that the UPDATE sql statements issued by LINQ will include all the fields in the WHERE clause in order to match the exact copy of the record that was initially read and prevent overwriting changes made by other users/threads between the last time we read the record and the moment we try to update it. And that's fine in many scenarios but sometimes you want all the UPDATE statements to find the record to update and change it regardless of changes sent by others (a "last commit wins" type of policy) and for that you'd need LINQ's UPDATE statements to only include the table's primary key fields in the WHERE clause. That is, you need the UpdateCheck property set to Never for all the columns that are not primary keys.

Sunday, October 21, 2012

Visual Studio poor performance issue

Over the last two weeks my Visual Studio has been behaving strangely. Launching a simple console application in debug mode would take about 5 minutes for it to come up. Same thing happened when launching other projects in the solution in debug mode.

Today I cleaned up my Visual Studio configuration, rebooted my PC and the debugger launches instantly as expected. In case any of you are experiencing a similar issue, you can clean your visual studio by performing the following:

Tools -> Import and Export Settings…
Select “Reset all settings”, and click next.
Select “No, just reset settings”, and click next.
Choose your default collection of settings (Visual C# Development Settings)
Click Finish.

Wednesday, September 5, 2012

How to post a complex object via AJAX to an MVC Action

I needed to post an object from Javascript to an Action using Asp.Net Mvc, and realized it is not as straitghforward as I thought it would be. So, I put together a little example which can be used for reference in the future.