Skip to content

Instantly share code, notes, and snippets.

View M-Yankov's full-sized avatar
💻
🤖🧭🏃‍♂️🚵‍♂️

Mihail Yankov M-Yankov

💻
🤖🧭🏃‍♂️🚵‍♂️
View GitHub Profile
<div id="header" style="margin: 0; padding: 2px 10px; color: white; background-color: #228B22; width: inherit;">author:</div>
<div id="content" style="margin: 0; border: 1px solid #228B22; width: inherit; padding: 20px;">Quoted Content</div>
@M-Yankov
M-Yankov / index.cshtml
Created February 25, 2016 00:24
load image in html before it is uploaded
@{
ViewBag.Title = "Index";
}
<p class="text-success">@ViewBag.StatusMessage</p>
<div class="row">
<div class="col-md-12">
<div class="row">
<img src="@Url.Action("Image", "UserProfile")" class="img-responsive"
@(System.Threading.Thread.CurrentThread.CurrentCulture.Name) -< Culture
@(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat) -< Format
@{
var dateInfo = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat;
var formats = dateInfo.GetAllDateTimePatterns();
}
@foreach (var item in dateInfo.GetAllDateTimePatterns())
{
@M-Yankov
M-Yankov / MonthsBetweenTwoDates.cs
Last active June 30, 2017 13:55
Calculate months between two dates.
private int GetMonthsBetweenTwoDates(DateTime startDate, DateTime endDate)
{
int monthsCountResult = 0;
var monthsCount = 12;
if (startDate.Year == endDate.Year)
{
monthsCountResult = (endDate.Month - startDate.Month) + 1;
}
else
{
@M-Yankov
M-Yankov / ConsoleColors.cpp
Created July 16, 2016 13:22
C++ console colors
// color your text in Windows console mode
// colors are 0=black 1=blue 2=green and so on to 15=white
// colorattribute = foreground + background * 16
// to get red text on yellow use 4 + 14*16 = 228
// light red on yellow would be 12 + 14*16 = 236
// a Dev-C++ tested console application by vegaseat 07nov2004
#include <iostream>
#include <windows.h> // WinApi header
@M-Yankov
M-Yankov / StepsToGenerateCoverage.md
Created September 4, 2016 18:25
Steps to generate a test coverage results using VS integrated testing framework.

This instructions applies to upload your test coverage to coveralls.io

Using Coveleralls .NET package and Visual Studio 2015 Enterprise

  1. Create Unit test project. Click Analyze Code Coverage from main menu in Visual Studio.
  2. Check TestResults folder in root directory of your project. Find .coverage file.
  • (If you don't use VS 2015 Enterprice check:
    vstest.console.exe /inIsolation /Enablecodecoverage YourTestProject.dll and find the output .coverage file)
  1. Execute following command: "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe" analyze /output:coverage.coveragexml C:\PathToYourCoverage.coverage
@M-Yankov
M-Yankov / RefreshUIWPF.cs
Created September 24, 2016 22:03
WPF refresh UI
public static class ExtensionMethods
{
private static Action EmptyDelegate = delegate() { };
public static void Refresh(this UIElement uiElement)
{
uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
}
@M-Yankov
M-Yankov / cmdCommand.txt
Created October 24, 2016 11:56
CMD Build C# Solution
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>devenv.exe "C:\Users\mihkov\Desktop\McDInsights-A-Triks-VPN\Mc
DInsights-A-Triks-VPN\Source\McDInsights\McDInsights.sln" /build Debug
Source: https://msdn.microsoft.com/en-us/library/b20w810z.aspx
@M-Yankov
M-Yankov / SampleAsync.cs
Created November 23, 2016 08:25
Sample async example.
private async Task<string> Execute()
{
// Keep watching for out of memory exception when using new string
string text = "First Line" + Environment.NewLine + "Second" + Environment.NewLine + new string('-', int.MaxValue / 33);
text += text;
StringReader reader = new StringReader(text);
Console.WriteLine("=Before=");
string readText = await reader.ReadLineAsync();
@M-Yankov
M-Yankov / CsvExport.cs
Last active February 25, 2017 19:56
Do not use var
/* The code is get from project */
protected void btnExportCSV_Click(object sender, EventArgs e)
{
//Get List of all AnimalData from DAL as a List object
var listAnimalData = AdminMCCDAL.GetActiveAnimalData(); // !!!!
if (listAnimalData.Count > 0)
{
//Export this list of AnimalData to a .CSV file
listAnimalData.ExportCSV("MCC_AnimalIntakesExport");