Skip to content

Instantly share code, notes, and snippets.

View tugberkugurlu's full-sized avatar
:shipit:
💥 shakalaka

Tugberk Ugurlu tugberkugurlu

:shipit:
💥 shakalaka
View GitHub Profile
<TargetFrameworks>
<Framework name="net451" />
<Framework name="netcoreapp1.0">
<Dependencies>
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
</Dependencies>
</Framework>
</TargetFrameworks>
// getProducts connects to DB to retrieve the products
// getRevenue connects to DB to retrieve revenue based on the product attributes
// convertRevenue and calculateProfit are pure functions
// saveProfit writes the calculated profit to a DB
getProducts 1 |>
getRevenue |>
convertRevenue |>
calculateProfit |>
saveProfit

Value Object

An Address is a good example of a value object. Both addresses with the same attributes will always be the same.

Entity

A User is a good example for an entity. It has an identity and even if two different users have same attributes, it will not be a match.

Aggregate

@tugberkugurlu
tugberkugurlu / NonNullableOfT.cs
Last active November 11, 2016 08:55
It's not a perfect solution but at least allows you to create non-lying method signatures. Origin: https://twitter.com/tourismgeek/status/796771077531848706 and https://codeblog.jonskeet.uk/2008/10/06/non-nullable-reference-types/
using System;
/// <summary>
/// Wraps a reference type value which should not be null.
/// </summary>
/// <typeparam name="T"></typeparam>
public struct NonNullable<T> where T : class
{
private readonly T _value;
@tugberkugurlu
tugberkugurlu / program.cs
Last active November 11, 2016 09:01
Directory validation for write access
using System;
using System.IO;
using System.Linq;
namespace ConsoleApplication4
{
// see: http://stackoverflow.com/a/6371533/463785
// see: http://stackoverflow.com/questions/1281620/checking-for-directory-and-file-write-permissions-in-net
class Program
// Based on:
// - Getting Started with Neo4j in .NET with Neo4jClient Library: http://www.tugberkugurlu.com/archive/getting-started-with-neo4j-in--net-with-neo4jclient-library
// Other links:
// - Neo4j: http://neo4j.com/
// - Neo4j .NET Client: https://github.com/Readify/Neo4jClient
// - Cypher query language: http://neo4j.com/developer/cypher-query-language/
public class Agency { public string Name { get; set; } }
public class Person { public string Name { get; set; } }
let randomString len =
let chars = "ABCDEFGHIJKLMNOPQRSTUVWUXYZ0123456789"
let charsLength = chars.Length
let random = System.Random()
let randomChars = [|for i in 0..len -> chars.[random.Next(charsLength)]|]
new System.String(randomChars)
public class ClaimsPrincipalParameterBinding : HttpParameterBinding
{
public ClaimsPrincipalParameterBinding(HttpParameterDescriptor descriptor)
: base(descriptor)
{
}
public override Task ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)
{
ClaimsPrincipal claimsPrincipal = actionContext.Request.GetRequestContext().Principal as ClaimsPrincipal;
@tugberkugurlu
tugberkugurlu / docker-things.sh
Created October 19, 2016 19:07
Docker CLI Cheatsheet
# List all stopped containers
docker ps --filter "status=exited"
# Remove all stopped containers
docker rm $(docker ps --filter "status=exited" -aq --no-trunc)
# Remove all unused images (http://stackoverflow.com/a/32723127)
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

Getting Into the Zero Downtime Deployment World

Continuous delivery is a huge step forward in our ability to rapidly deliver features and value to the users of distributed applications, but it comes with a cost and a responsibility. Most modern web applications need to be highly available, and this also means that it should be up during the deployments. Dealing with zero-downtime deployments is a challenge, and there is no easy solution. Moreover, the solutions available vary based on the number of integrated clients, which parts of the World it addresses, how many active users it has... Isn’t there a simple way to figure out how to get there?

Join me to get into the details of the key steps on your path to zero downtime deployments. Learn about the patterns, practices and techniques that make it easier, such as semantic versioning and blue/green deployments. We’ll also walk through an end-to-end demo of how a high traffic web application can survive the challenge of deployments.

What seemed insurmounta