Git lesson: cherry-pick command (possible in VS2015)

How many of you have been used cherry-pick in Git?

Cherry picking in git means to choose a commit from one branch and apply it onto another.

git cherry-pick <commit-hash>

Official documentation: https://git-scm.com/docs/git-cherry-pick

Visual Explanation: http://think-like-a-git.net/sections/rebase-from-the-ground-up/cherry-picking-explained.html

It is convinient way to copy changes from previous commit  in Visual Studio 2015

vscherrypick

List of All C# Collections. Use the right one.

There are a lot of types of built-in collections in C#:

Array, ArrayList, BitArray, BitVector32, Dictionary<K,V>, HashTable, HybridDictionary, List<T>, NameValueCollection, OrderedDictionary, Queue, Queue<T>, SortedList, Stack, Stack<T>, StringCollection, StringDictionary.

Consider what collection will be the optimal for the specific case. It will likely result in better performance and less room for error. For example if you want to store items as key/value pairs for quick look-up by key, so the best choice will be Generic.Dictionary<TKey, TValue>.  If you want to use items first-in-first-out (FIFO), go on Generic.Queue<T>. If you going to access elements by index frequently, go on System.Array if it’s non-generic Elements, but the best option will be Generic.List<T>, if you store elements of type T only. If you frequent action is access items sequentially, better choose Generic.LinkedList<T>.  There are a lot more considerations. More information can be found here:

My 3 recommendations. Don’t start to write your own collection class, .NET provide a large variety of existing classes, which you can you use or extend. Think about what actions will be applied on Collection more often. And Generic collections are always preferable than  non-generic.

Как дешево покупать на AliExpress. Пошаговый алгоритм с картинками.

Сделал анализ возможностей купить и вывел лучший алгоритм покупки:

Общие настройки:

  1. Если у вас автоматом открывается на русском http://ru.aliexpress.com/ – то перейти на глобальный английский сайт (так будет больше дешевых вариантов товара при поиске)aliglobalsite
  2. Валюту выбрать $(USD), а не рубли, т.к. сайт переводит в рубли по невыгодному курсу
  3. Регистрируемся на сайте с кэшбеком, например https://cashback.epn.bz (дает максимальный кэшбек для алиэкспресс из всех с которыми сравнивал), прописываем промокод summer2016-gk0z3, чтобы получить 8%, описание как это сделать

Алгоритм покупки:

  1. Ищем товар по ключевым словам на английском, надо указать модель. Например ищем наушники ROCK Zircon. В всплывающем окне выбираем категорию Earphones & Headphonesalisearchpopbox
  2. Корректируем категорию слева на экране ( В нашем случае это не требуется)   alirelatedcategories
  3. Переключаем вид отображения справа на квадратики, так удобнее сравниватьaliviewchoose
  4. Сортируем результаты по 1.рейтингу продавца или 2.количеству заказов aliresultssortingbyordersorrating.JPG
  5. Выбираем цену $ подешевле и чтобы были хорошие отзывы ★★★★★, а также наводим мышкой на продавца и смотрим на Positive Feedback (97,9% в наше случае). В нашем примере сразу отпадают 2 варианта (другой товар на картинке). А из оставшихся выделяем 2 варианта:
    1. US $12.74 у хорошего популярного, Positive Feedback = 97,9%, 32 заказа, 14 отзывов ★★★★★ 4,7
    2. US $11.99 у продавца менее популярного, но с более хорошими отзывами Positive Feedback = 98,9%, 27 заказов, 25 отзывов ★★★★★ 5,0alichoosingfromtopresults.jpg
  6. Читаем отзывы про каждый из выбранных вариантов. В нашем примере вариант номер 2 более предпочтителен и по цене и по отзывам. Даже читать не надо, т.к. все отзывы на 5: alifeedbacks
  7. Для получения кэшбэка копируем ссылку на товар в главную страницу кэшбек сервиса alicashbackforlink
  8. Нажимаем Купить с кэшбэком и попадаем на проверку ссылку, тут видно процент который получим за покупку alicashbacklinkcheck.JPG
  9. Жмем Продолжить (перейти к покупке) и попадаем обратно на AliExpress на экран  покупки товара. Выбираем 1.цвет и потом жмем 2.Buy nowalibuystart
  10. В следующем окне выбираем 1.адрес доставки, смотрим на наш 2.заказ, все ли правильно а также добавляем комментарий к заказу, где еще раз указываем цвет, а также просим скидку в обмен на хороший отзыв: “Black. Waiting for additional discount, because I will write review and recommendations for you” aliaddcommentinorder.JPG
  11. И внизу страницы пункт 3.Оплата. Чтобы сделать заказ, но не заплатить (это надо для последующих торгов с продавцом), переключаем оплату с вашей карты на Other payment method и только после этого нажимаем на Confirm & Payaliconfirmbutnotpay.JPG
  12. После этого мы можем торговаться с продавцом. Заходим в My Orders alimyorders.jpg
  13. Находим наш заказ и жмем Contact Seller aliordercontactseller.JPG
  14. Пишем сообщение продавцу, пытаемся убедить дать скидку : “Hi, friend. Can you make me discount in return I will write review and recommendations for you. Thank you in advance :)”

 

 

Web Service || WCF || Web Api …What to choose?

Serious Web Services: Windows Communication Foundation (WCF), Web API, OData, and More

https://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/DEV-B209#fbid=

 

http://www.codefoster.com/webservicesforward/

http://stackoverflow.com/questions/9348639/wcf-vs-asp-net-web-api

http://stackoverflow.com/questions/9778665/wcf-vs-asp-net-web-api/9859981#9859981

https://www.captechconsulting.com/blogs/aspnet-web-api-vs-windows-communication-foundation-wcf

 

https://msdn.microsoft.com/en-us/library/jj823172(v=vs.110).aspx

Understanding Host Headers in IIS

Introduction

IIS has the ability to host multiple websites on one single server. To do this, a unique combination of the host header name, IP address and port number must exist. This article will explain what a “host header” is, how it works, and explain some common misunderstandings of the host header concept.

The host header is part of the HTTP message

The client and webserver communicates using the HTTP protocol. The data sent between the client and server is called a HTTP message (see RFC 2616, section 4). The HTTP message has a body section and a header section. The body section may contain the HTML code of the webpage returned from the server to the client as an answer to a GET request. The header section contains information such as Content-Length, Referer, Host (and possibly also much more).

How the client communicates with the webserver

To understand where the HTTP message is examined, it is crucial to understand the communication between the client and server. The communication is (typically) introduced by a user typing the domain name and port number into their browser (Internet Explorer). For example, say that the user want to visit http://www.ilopia.com, in this case the user would type the URL http://www.ilopia.com into their browser. Internet Explorer will default to the HTTP protocol and the default port (80) for HTTP.

The browser will now need to resolve the domain name the user has typed into their browser because the client must establish a connection to the IP address and port number. The resolution of the domain name into an IP address can be done by utilizing a DNS server or the hosts file.

Once the domain name has been resolved, the client established a connection to the webserver and then sends a request message. This request message contains the host header, and may look like:

GET /index.htm HTTP/1.1
Host: http://www.ilopia.com

The server receives the HTTP message and examines it. If a host header is found (a HTTP message may not have a host header), IIS will find out if there is any host header name configured in IIS that matches the host header received in the HTTP message. If there is a host header name that matches the host header, index.htm will be served from this website’s home folder.

The last step is that IIS will respond to the request.

Name resolution is not part of IIS

As could be seen in the section “How the client communicates with the webserver” above, the HTTP message (and the host header) is not examined until a connection is established between the webserver and client. So when configuring IIS to use host headers, it is necessary to configure name resolution as well. Name resolution is not part of IIS (IIS is a web server, not a name resolution service). Instead a DNS service is necessary, or for a small network the hosts file may be sufficient.

Behind the scenes

Each website set up in IIS “binds” to an IP address, port number and host header name. Each website’s configuration is stored in the metabase property ServerBindings, which has the string format IP:Port:Hostname. An example would look like 192.168.0.1:80:www.gafvert.info. The host header name (www.gafvert.info in the example) and IP (192.168.0.1 in the example) can be omitted.

To determine which website should handle a request, IIS checks if there is a website configured to listen on the IP address and port number the request came in on, and which also matches the host header value sent in the HTTP message. If it finds a website with a ServerBindings property that matches this exactly, the request is routed to that website.

If there is no website with an exact match, IIS checks if there is a website configured to listen on all IP addresses (in IIS Manager called “All Unassigned”), the port the request came in on, and with a configured host header name matching what is sent in the HTTP message. If a match is found, IIS routes the request to that website.

The last step is to see if there is any website with a blank host header configured in IIS, which will then handle the request.

 (Article by Kristofer Gafvert)

Resources

Using Host Headers to host multiple websites on IIS 6.0
Test host header configuration with the hosts file
Host Headers versus multiple IPs when hosting several websites
Can I use host headers to run multiple FTP sites?
Append a host header to a website in IIS by code

IIS processing of HTTP request

Working with .Net applications deployed on IIS now, I decided to refresh memories about IIS architecture. It can be helpful to any .NET developer.

IIS 7 and above have a similar HTTP request-processing flow as IIS 6.

Here is the diagram, with steps explanation below it.

introduction-to-iis-architecture-101-overviewofhttprequest0.

  1. When a client browser initiates an HTTP request for a resource on the Web server, HTTP.sys intercepts the request.
  2. HTTP.sys contacts WAS to obtain information from the configuration store.
  3. WAS requests configuration information from the configuration store, applicationHost.config.
  4. The WWW Service receives configuration information, such as application pool and site configuration.
  5. The WWW Service uses the configuration information to configure HTTP.sys.
  6. WAS starts a worker process for the application pool to which the request was made.
  7. The worker process processes the request and returns a response to HTTP.sys.
  8. The client receives a response.

In a worker process, an HTTP request passes through several ordered steps, called events, in the Web Server Core. At each event, a native module processes part of the request, such as authenticating the user or adding information to the event log. If a request requires a managed module, the native ManagedEngine module creates an AppDomain, where the managed module can perform the necessary processing, such as authenticating a user with Forms authentication. When the request passes through all of the events in the Web Server Core, the response is returned to HTTP.sys.

Diagram 2, below, shows an HTTP request entering the worker process.introduction-to-iis-architecture-101-httprequestworkerproc

It’s just a small piece of  IIS architecture.For more information about IIS go to Introduction to IIS