Validate version consistency of NuGet packages in a solution (in PowerShell)

04 October 2016   Comments   nuget powershell

If you use NuGet you have will realise that there are times where same of your package may have different versions installed in different parts of your solution.

This could result in run-time inconsistencies and is something you would want to avoid.

Get SQL table name of an Entity in Entity Framework

29 August 2016   Comments   entity-framework sql

There are times when you find yourself needing to construct a raw SQL when working with Entity Framework. Particularly, if you want to stay away from the horror of hundreds-of-lines SQL generated by a complex EF mapping and would rather use Dapper to map the output of a raw SQL to your entities.

Generate Release-Notes from GitHub and TargetProcess

10 August 2016   Comments   github targetprocess

Recently we moved to a continuous delivery model on two of our major products, and as an essential part of that I had to think of a way of automatically generating release notes from the work developers continually put in (via pull-requests).

We use Target Process as the requirements management/issue tracking tool and such automation would have to be built in conjunction with that.

Setup TeamCity on a windows machine with reverse-proxy

01 August 2016   Comments   teamcity devops reverse-proxy windows

In case you are installing TeamCity on a windows machine that already has another application listening to it’s port 80 (in our case we have Octopus Deploy installed on the same machine), you would need to follow steps as below to get incoming port 80 traffic served by TeamCity.

How to safely deploy a decomposed database when using Entity Framework code-first

30 July 2016   Comments   entity-framework migrations

When moving to a continuous delivery model, we started decomposing some of our larger solutions into smaller sub-systems and systems built with Entity Framework code-first, face a tougher challenge with their database being decomposed.

The challenge is, how to avoid down-time between when the database (migrations) and the main website (or any other sub-system depending on the database) are deployed.

Slice an enumerable in LINQ

22 December 2015   Comments   LINQ

One of the useful methods I found missing from built-in LINQ functions is the ability to slice an enumerable into chunks… So here I include it, should be useful for anyone in the future:

Configure a telegram bot webhook into an existing express app

06 December 2015   Comments   nodejs heroku telegram webhook

Recently I wrote about How to build a telegram bot using node.js and heroku. In the article we use polling to listen to incoming messages. This approach has few problems though…

Build a telegram bot using node.js and heroku

10 November 2015   Comments   nodejs heroku telegram

A little while ago I started using telegram as my messaging app (admittedly along-side dozen other apps). But it didn’t take long till I realized, there is something different about telegram which is really cool. It’s [almost] fully open-source and more importantly highly programmable, so much that they natively support bots! and quickly I found myself wanting to write my own bot.

In this article I will take you through the steps of how to write a very simple telegram bot that interacts with users on telegram and delivers a service. You can use this as a starting-point for building your more complex bots.

Build a command-line interface app using node.js and dastoor

15 August 2015   Comments   nodejs cli command-line terminal

While building a command-line interface using node for myself (onetime-cli), I felt the need for a lean, convention-based and well-structured tool for building command-line interface apps.

This is how dastoor (in Farsi meaning “command”) was born.

In this article I will take you through how to create a simple (with the potential to become complicated) CLI.

Allow redirect URI subdomains in IdentityServer3

09 July 2015   Comments   identityserver openid security

IdentityServer3 is an awesome library that allows you to build [in no time] an single sign-on server using .NET and OWIN/Katana.

When client applications send a user to the server, they must provide a redirect_uri as a parameter which is used to send the user back to the application with the token.

One of the security measures build into IdentityServer is restricting the list of URIs allowed (for each client).

var client = new Client
{
    ClientName = "JS Client",
    ClientId = "implicitclient",
    RedirectUris = new []
    {
        "https://www.myapp.com/callback.html",
    }
}  

The default behavior of IdentityServer is to do an exact match on these (case insensitive).

But what if we have [an unpredictable list of] subdomains in our app? Exact matches won’t work in this case.

Build a gulp task to organise JSON dictionary files

02 June 2015   Comments   gulp angular translation JSON

Recently I’ve been building an angular app for a local language (farsi). To inject translated text in my template files, I use angular-template which is an awesome library that provides you with directives and filters to translate text in template files.

One of the ways to feed translated text into angular-template is to store translations into a JSON dictionary file and link it to the translator. (using this plugin.)

{
    "-- Select --": "-- انتخاب کنید --",
    "About": "درباره ما",
    "Action": "عملیات"
}
.config(function($translateProvider){
  $translateProvider.useStaticFilesLoader({
    prefix: '/lang/',
    suffix: '.json'
  });

  $translateProvider.preferredLanguage('fa-IR');
})

However on a decent-sized app, you will soon hit into difficulty organizing your dictionary files.

There is however always something to do to make life easier:

Adding JSON response mode to IdentityServer3

30 May 2015   Comments   identityserver openid security owin

We recently started building a solution composed of many websites. For authentication, we use IdentityServer3 to build single sign-on using OpenID connect protocol.

This is generally how a normal login scenario works:

  1. You open a page on site-a.com
  2. Because you are not logged in, site-a will send you to my-idserver.com/connect/authorize via a 302 response
  3. You login on my-idserver.com (or may well be already logged in), and your browser does a POST to site-a.com (with token parameters)
  4. site-a.com will handle the posted token and log you in.

This scenario fits most of our needs; However, we noticed we have a need that is not covered in IdentityServer3.

We need to call into my-idserver.com (from a javascript) and retrieve the token for the already logged in user.

how I use gulp to take care of my angular template urls

05 March 2015   Comments   angular gulp

While developing an angular SPA (single page app), I felt the need to find a shortcut to avoid repeating myself when it comes to the templateUrl of the ui-router states.

Given that I’m already using gulp to:

  • squash all javascript files into a single .js file (to avoid having numerous <script> tags in my html file) and
  • squash all template files into a template-cache.js file (to one request per-template on client)

I found that there can be a neat trick added to the gulp to shorten the templateUrls in my states.

Building an angular/node app that is secured by OAuth and JWT

28 February 2015   Comments   angularjs nodejs express oauth jwt authentication

So I recently started building an app using angular and node (express). To avoid any session memory and truly scalable and segregated API, I decided to build a token-based authentication for my app.

So what is JWT?

As defined on their website:

JSON Web Token (JWT) is a compact URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JSON object that is digitally signed using JSON Web Signature (JWS).

What I found interesting about JWT is that:

Add a heartbeat end-point to an azure worker role

03 February 2015   Comments   azure OWIN

Some background…

For one of my projects, I have a worker role on azure that performs some action in the background. In fact there are several of them that work in an orchestration together.

While building these workers, I noticed that I’m going to need one way to find out whether the worker is OK in the background and possibly get some very abstract information out of it. Having such a health monitorning is vital for a system which is composed of many background workers.

Gherkin component for prism code highlighting

26 October 2013   Comments   gherkin bdd prism code-highlighting syntax-highlighting

I previously wrote about prism and it’s C# component.

Now I have added a component to prism for Gherkin syntax. This will help you highlight your BDD features in your webpage/blog.

Here is an example:

C# component for prism code highlighting

26 October 2013   Comments   c# prism code-highlighting syntax-highlighting

Looking for a good code syntax highlighting tool for web, I stumbled upon prism and I found it simple, fast and flawless (as far as my needs go).

What makes it particularly cool is that it is open source and superbly extensible.

So I added a component (you can read ‘plugin’) for C# to it’s list of components. You can add any missing language by simply contributing to the github repository.

You can download the prism from here and choose C# (alongside other languages).

There are various themes to choose from. here is an example of how your code will look like in ‘okaidia’ theme: