Skip to content

Instantly share code, notes, and snippets.

View MirzaMerdovic's full-sized avatar
💭
🐀

Mirza Merdovic MirzaMerdovic

💭
🐀
View GitHub Profile
@MirzaMerdovic
MirzaMerdovic / WebAPI and OWIN dependency list.txt
Last active October 4, 2016 21:52
WabAPI 2 (OWIN IIS Host) - References
Here is the list of references that are already there when you create new Web-Empty project in VS 2015 (.Net 4.6.1):
1. Microsoft.CodeDom.Providers.DotNetCompilerPlatform
2. Microsoft.CSharp
3. System
4. System.ComponentModel.DataAnnotations
5. System.Configuration
6. System.Core
7. System.Data
8. System.Data.DataSetExtensions
9. System.Drawing
@MirzaMerdovic
MirzaMerdovic / ReadAsAsync<T>
Created September 9, 2016 21:56
Can't find HttpContent.ReadAsAsync<T>?
This one was in: https://msdn.microsoft.com/en-us/library/hh834253(v=vs.108).aspx
but now is here: Microsoft.AspNet.WebApi.Client
and I am tired of forgetting...
To get the list of installed versions: $PSVersionTable
To get the list of installed Azure modules: Get-InstalledModule | Out-GridView
If yu want to update all modules to latest version: Update-Module
using System;
using System.IO;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.Common;
namespace BuildAndDeploy.GetSourceTest
{
class Program
{
This is a summary of this article: http://yizhang82.me/value-type-boxing
using System;
interface IAdd
{
void Add(int val);
}
struct Foo : IAdd
@MirzaMerdovic
MirzaMerdovic / Generate Random number
Created June 5, 2017 09:44
Random number generation that can be used for SMS codes and similar.
private int GenerateRandomNumber()
{
int number = 0;
byte[] randomNumber = new byte[1];
do
{
var rngCsp = new RNGCryptoServiceProvider();
rngCsp.GetBytes(randomNumber);
var digit = randomNumber[0] % 10;
number = number * 10 + digit;
@MirzaMerdovic
MirzaMerdovic / SQL Tips n Tricks
Created October 9, 2017 20:15
SQL Tips and Tricks
WITH ROLLBACK IMMEDIATE
The ROLLBACK IMMEDIATE command tells the SQL Server that if it can’t complete the command right away,
then the other pending transactions should be rolled back.
Note: Option will disconnect all other users from the database.
I had trouble figuring out the message format that Splunk expects when you won't to post a message to exposed http event collector,
so there it is for future references since I will forget about it 100%
URL: http://localhost:8088/services/collector/event
headers:
- Authorization = Splunk {your_token}
- Content-Type = application/json
json payload:
{
# Project 1:
Base class:
public abstract class BaseRepository
{
private protected Task<string> GetEmail(int id)
{
return Task.FromResult("username@mail.com");
}
}
## Method
private static Task<IEnumerable<T>> QueryAnonymAsync<T>(IDbConnection connection, Func<T> typeBuilder, string sql)
{
return connection.QueryAsync<T>(sql, typeBuilder);
}
## Usage
return
await
QueryAnonymAsync(conn,