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
View program.cs
class Program
{
static void Main(string[] args)
{
IEnumerable<string> basket1 = new List<string> { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
IEnumerable<string> basket2 = new List<string> { "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" };
IEnumerable<string> basket3 = new List<string> { "21", "22", "23", "24", "25", "6", "7", "8", "9", "30" };
foreach (var item1 in basket1)
foreach (var item2 in basket2)
@tugberkugurlu
tugberkugurlu / program.cs
Created February 7, 2014 14:55
C# FtpClient code
View program.cs
using System;
using System.IO;
using System.Net;
using System.Net.FtpClient;
using System.Threading.Tasks;
namespace FtpClientSample
{
class Program
{
@tugberkugurlu
tugberkugurlu / program.cs
Created February 10, 2014 16:08
Simple C# yield return sample
View program.cs
class Program
{
static void Main(string[] args)
{
IEnumerable<string> values = GetStrings().Take(10);
foreach (string value in values)
{
Console.WriteLine(value);
}
@tugberkugurlu
tugberkugurlu / program.cs
Created February 13, 2014 10:05
CreateMD5Hash
View program.cs
protected virtual string CreateMD5Hash(string input)
{
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
View owin-di-question.md

I have an IFoo instance which I need to use as per request instance. Here is how my startup class look like:

public void Configuration(IAppBuilder app)
{
    HttpConfiguration config = new HttpConfiguration();
    config.Routes.MapHttpRoute("DefaultHttpRoute", "api/{controller}");

    app.Use<RandomTextMiddleware>()
       .UseWebApi(config);

}

@tugberkugurlu
tugberkugurlu / Program.cs
Created February 25, 2014 17:20
HttpClient usage sample
View Program.cs
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 100; i++)
{
Run();
}
using (HttpClient client = new HttpClient())
@tugberkugurlu
tugberkugurlu / program.cs
Last active August 29, 2015 13:56
How to Use Service Bus Queues
View program.cs
static void Main(string[] args)
{
// Reference: http://www.windowsazure.com/en-us/documentation/articles/service-bus-dotnet-how-to-use-queues/
// Service Bus Partitioned Queue: http://code.msdn.microsoft.com/windowsazure/Service-Bus-Partitioned-7dfd3f1f
// BrokeredMessage.ViaPartitionKey: http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.brokeredmessage.viapartitionkey.aspx
const string QueueName = "TestQueue";
string serviceBusConnStr = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
QueueDescription qd = new QueueDescription(QueueName);
@tugberkugurlu
tugberkugurlu / LinqExtensions.cs
Created February 27, 2014 16:28
Split IEnumerable<T> extension
View LinqExtensions.cs
public static class LinqExtensions
{
public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> list, int parts)
{
int i = 0;
var splits = from item in list
group item by i++ % parts into part
select part.AsEnumerable();
return splits;
}
@tugberkugurlu
tugberkugurlu / program.cs
Last active August 29, 2015 13:57
HttpClient TCP connection try
View program.cs
class Program
{
static void Main(string[] args)
{
ServicePointManager.DefaultConnectionLimit = 12;
for (int i = 0; i < 100; i++)
{
Run();
}
@tugberkugurlu
tugberkugurlu / Location.cs
Last active August 29, 2015 13:57
Location Class which should be struct?
View Location.cs
using System;
using System.Data.Spatial;
public class Location
{
public Location(double lat, double lng)
{
Latitude = lat;
Longitude = lng;
}