Posts

Showing posts from 2013

User authentication on Android against hashed passwords created with Asp.Net Identity

Microsoft shipped a new membership system called ASP.NET Identity with Visual Studio 2013 and .Net 4.5.1. It allows us to add login features to the applications built for the web, phone, or store. By default the ASP.NET Identity system will store all the user information in a database. ASP.NET Identity uses Entity Framework Code First to implement all of its persistence mechanism. What if we going to build an Android app with offline capabilities, where the users would sync the stored credentials created by Asp.Net Identity on the server in order to login? We would have to verify the provided user password against locally stored hashed password to authenticate the user. Below is the code that can be used for this task: /** * Verifies provided plain text password against hash * @param hashedPass * @param password * @return true or false */ private boolean verifyPassword(String hashedPass, String password){ if (hashedPass == null){ return false; } byte[] n

Synchronization algorithm for exchanging data in the “Client – Server” model via REST API

Image
Many mobile applications require to sync data with a server if they operate in the client – server model to exchange data with the central repository. If the server serves up resources through a REST API , then all sync logic can be handled on the client side. The sync logic is able to handle bi-directional sync between central server and multiple clients where only incremental changes apply on both sides with some conflict detection. Each table (both server and client) participating in the sync process should include two additional fields: “ Ts ” as Number , “ Deleted ” as Boolean . The Ts  field is maintained by the server side. For example SQL Server automatically generates a unique incremental value on each insert or update. The Ts field is used to determine whether one record in the table was modified more recently than another so to download only the incremental changes. Also it will help to identify the new records created on the client as they will have no Ts value.

Managing hiring process in tech-sector

Image
Recently we used a five stages hiring process to fill two openings for .Net Senior Developers. The process was based on Jeff Atwood’s article " How to hire a programmer " to minimize our time waste on unqualified candidates and find the good fit. The idea was to dedicate our time only to candidates who passed online technical test. We didn’t bother to study the received CVs as recruitment agencies already used to filter applicants to match our job specs (well, maybe just short glance to ensure the candidate claims the relevant experience). Each candidate had to go through five stages listed below: Online technical test (15-30 minutes) – we used Interview Zen where we created the test with three programming questions (SQL, C# collections, JavaScript). Portfolio check - successful candidates had to share some code they wrote (open-source / personal projects, blog posts, etc.) Phone interview (20-30 minutes) – a few programming related questions such as: What is

Send emails with SQL Server using Html files

Image
Sending emails from MS SQL Server using the Database Mail is easy. Once the Database Mail is active and configured (see this blog for quick configuration) the emails can be send using the SQL script below: USE msdb GO EXEC sp_send_dbmail @profile_name='EmailProfile', @recipients='test@example.com', @subject='Test message', @body='This is a test message.' In cases where there is a need to send emails in html format - creating the content inside of SQL script is not so convenient. With the help of OPENROWSET function we can read the content of html file, which contains the properly formatted and tested html. For example below is the html file that we can easily open in the browser and validate it displays correctly the way we want. It contains the html and body tags which wraps the content that will be inserted into the email’s body. Test Email This is a test message Below is the SQL script which will send the emails by readi

Create Google Charts in Asp.Net MVC by generating JSON data on the SQL SERVER

Image
The purpose of this article is to share the implementation of Google Charts with data retrieved from SQL Server whereas JSON is created on the SQL Server. Google chart tools provide a rapid way of creating charts from some data for the web developers. All charts are populated with data stored in a DataTable object. The DataTable object can be filled with data using JSON format. There are several different ways of creating and populating a DataTable and they all have some advantages and disadvantages (more about it here ). The application I needed to add Google Charts to be Asp.Net MVC using nHibernate with MS SQL Server. The idea is to create all required data on the SQL Server using stored procedures to gain performance benefits, minimize the efforts of creating JSON for each chart and realize the DRY principal. Once the required SQL stored procedure is created we are going to convert the result table data into JSON and pass it into our DataTable constructor. Let’s say we

Managing configuration differences between environments in Visual Studio 2010/2012

Image
   Working in a team where every developer has to keep their own custom config file can be achieved using the Visual Studio built-in configuration transformation feature ( here is more about configuration transformation ). By default the configuration transformation is applied during project package / publish process. To enable the transformation on the project build we can follow the steps described by Tim in his answer . Additionally there is an extension tool SlowCheetah - XMLTransforms which can be added to the project as a Nuget package. Once it is installed the Preview Transform context menu becomes available on the transform files. It allows to preview the web.config after transformation. Really cool! Below is the summary of how to enable web configuration transformation on the build for the Web Application Project in VS2012: Create a new XML file with the following content in your project and rename it to "[YourProjectName].wpp.targets".  This file w

This is my new blog now

Image
 Here is my new blog. S4SME blog will be down as I have finished my experiment with S4SME.com website and see no any need to keep it running. All those blog posts will be moved to my new blog.