This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var builder = WebApplication.CreateBuilder(args); | |
builder.Configuration | |
.AddAzureAppConfiguration(options => | |
{ | |
var connectionString = Environment.GetEnvironmentVariable("AppConfiguration__ConnectionString"); | |
options | |
.Connect(connectionString) | |
.Select("Appc:*", "configs") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.MapPost( | |
"/refresh", | |
async ( | |
[FromBody] Azure.Messaging.EventGrid.EventGridEvent[] request, | |
[FromServices] IConfigurationRefresherProvider refreshProvider) => | |
{ | |
var eg = request.First(); | |
if (eg.EventType == "Microsoft.EventGrid.SubscriptionValidationEvent") | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Perf | |
| where ObjectName == "System" | |
| extend UpTime = CounterValue * 1s | |
| project TimeGenerated, Computer, UpTime | |
| summarize arg_max(TimeGenerated, *) by Computer | |
| order by UpTime desc | |
================================================== | |
let Linu = Heartbeat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get OS version: | |
lsb_release -a | |
Get OS release name: | |
lsb_release -cs | |
Get Memory usage: | |
free -m | |
Resource monitor: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add all files and commit | |
git add . | |
git commit | |
# Rebase master to working branch | |
git rebase master -i | |
# Rebase and fixup N commits on master | |
In example below N = 2 | |
git rebase HEAD~2 -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static TDelegate BuildHandler<TDelegate>(TServiceImpl instance, string methodName) | |
{ | |
MethodInfo method = instance.GetType().GetMethod(methodName); | |
IEnumerable<ParameterExpression> parameters = method.GetParameters().Select(x => Expression.Parameter(x.ParameterType)).ToList(); | |
var call = Expression.Call(Expression.Constant(instance), method, parameters); | |
var func = Expression.Lambda<TDelegate>(call, false, parameters).Compile(); | |
return func; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Module -Name 'Carbon' -AllowClobber | |
$ip=get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1} | |
$ip.ipaddress[0] | |
Set-HostsEntry -IPAddress $ip.ipaddress[0] -HostName 'home' -Description "Local IP Address" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's say that your appsettings.{envinronment}.json looks like this. | |
``` | |
{ | |
"DatabaseConfiguration": { | |
"apiDb": "Server={localhost};Initial Catalog={database};User ID={userName};Password={password};", | |
"api2Db": "Server={localhost};Initial Catalog={database};User ID={userName};Password={password};" | |
}, | |
} | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you have a serialized dictionary in your configuration for example, something like this: | |
// "dictionary": [{"1":"asda"}, {"2":"qweww"}, {"3":{"awdsd333"}] | |
Dictionary<int, string> parameters = | |
((JArray)serializedJArray) | |
.Children<JObject>() | |
.ToDictionary(x => int.Parse(x.Properties().First().Name), x => x.Properties().First().Value.ToString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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, |
NewerOlder