Skip to content

Instantly share code, notes, and snippets.

@djordjedjukic
djordjedjukic / LoggingMiddleware.cs
Last active March 27, 2024 09:14
LoggingMiddleware
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNetCore.Http;
:: Install choco .exe and add choco to PATH
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
:: Install all the packages
:: choose: visual studio, office, .net core, .net, rider tools
:::: Dev tools
choco install git.install -y
choco install gitkraken
choco install vscode -y
@djordjedjukic
djordjedjukic / AppSettingsHelper.cs
Last active December 15, 2017 10:12
All values from Web.config in one place
public static class AppSettingsHelper
{
public static string SomeStingValueFromWebConfig => Get<string>("SomeStringValue");
public static int SomeIntValueFromWebConfig => Get<string>("SomeIntValue");
private static TValue Get<TValue>(string key)
{
try
{
var value = ConfigurationManager.AppSettings[key];
@djordjedjukic
djordjedjukic / ToIntSafe.cs
Last active December 15, 2017 10:08
Extension methods
public static int Int(this string stringValue, int defaultValue = 0)
{
if (stringValue == null) return defaultValue;
int integer = Int32.TryParse(stringValue, out integer) ? integer : defaultValue;
return integer;
}
@djordjedjukic
djordjedjukic / 0_reuse_code.js
Created December 22, 2016 21:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console