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
// ASP Net Core 2.2.2 | |
// Get registered services from WebHost instance. | |
// In case the IServiceCollection or ApplicationBuilder is not available in the current context. | |
// The method can be used in separate assembly | |
pulbic void TestMethod() | |
{ | |
using (IServiceScope scope = this.webHost.Services.GetRequiredService<IServiceScopeFactory>().CreateScope()) | |
{ | |
RoleManager<IdentityRole> roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>(); |
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
public class Program | |
{ | |
public static async Task Main(string[] args) | |
{ | |
Stopwatch timer = Stopwatch.StartNew(); | |
Task a = OperationSlow(); | |
Task b = OperationFast(); | |
await Task.Delay(5000); |
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
/* Test on Firefox 64.0 | |
* See https://html2canvas.hertzen.com/ | |
* https://github.com/niklasvh/html2canvas/ | |
* | |
* Usage: | |
* Open a page | |
* Open developer console (F12) | |
* Paste the script below | |
* Click save image. | |
* |
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 listItems = []; | |
document.querySelectorAll('.task_item') | |
.forEach(e => listItems.push(e.textContent) ) | |
listItems.join('\n'); | |
// Regex separate year labels (\w+)([0-9]{4}) |
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
scrollbar, scrollbar *:not(scrollbarbutton), scrollcorner { | |
-moz-appearance: none !important; | |
--scrollbar-width: 15px; | |
--scrollbar-height: var(--scrollbar-width); | |
} | |
scrollbar, scrollcorner { | |
background: #fff !important; | |
} | |
scrollbar[orient="vertical"] { |
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 s2data = $allUnitsSelect.select2({ | |
ajax: { | |
url: '/GetValues', | |
dataType: 'json', | |
data: function (params) { | |
var query = { | |
text: text, | |
} | |
return query; |
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
/* How to not block UI thread: */ | |
public static void Main() | |
{ | |
/* Your code here */ | |
Task exitTask = ExitCommandAsync(); | |
Task.WaitAll(exitTask); | |
/* Console remains active */ | |
} |
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
(ex as System.Data.Entity.Validation.DbEntityValidationException).EntityValidationErrors.ToList()[0].ValidationErrors.ToList()[0] |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous"> | |
<style> |
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
dynamic person = new object { Name = "John", Age = 32, Title = "HR" }; | |
// In case the person comes from somewhere else | |
if (person != null) | |
{ | |
var properties = person.GetType().GetPtoperties(); // Will return an Array of System.Reflection.PropertyInfo[]; | |
// or | |
Type theType = (Type)person.GetType(); | |