This file contains hidden or 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 unsafe void Get(MyModel a) | |
{ | |
System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(a, System.Runtime.InteropServices.GCHandleType.Weak); | |
try | |
{ | |
IntPtr pointer = System.Runtime.InteropServices.GCHandle.ToIntPtr(handle); | |
string test = "0x" + pointer.ToString("X"); | |
} | |
finally | |
{ |
This file contains hidden or 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
msbuild ProjectFile.csproj /p:Configuration=Release ^ | |
/p:Platform=AnyCPU ^ | |
/t:WebPublish ^ | |
/p:WebPublishMethod=FileSystem ^ | |
/p:DeleteExistingFiles=True ^ | |
/p:publishUrl=c:\output | |
msbuild Solution.sln /p:Configuration=Release ^ | |
/p:DeployOnBuild=True ^ | |
/p:DeployDefaultTarget=WebPublish ^ |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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] |