Skip to content

Instantly share code, notes, and snippets.

@codehaks
codehaks / Test
Created July 27, 2019 19:42
Test
Test
@codehaks
codehaks / UseTagHelper.cshtml
Created November 1, 2018 07:05
UseTagHelper.cshtml
@page "/test/tag"
@{
ViewData["Title"] = "UserPartialView";
var watch = System.Diagnostics.Stopwatch.StartNew();
int count = 10000;
}
<h2>Performance Test : TagHelper</h2>
<hr />
@for (int i = 1; i < count+1; i++)
@codehaks
codehaks / UsePartialView.cshtml
Created November 1, 2018 07:04
UsePartialView.cshtml
@page "/test/partial"
@{
ViewData["Title"] = "UserPartialView";
var watch = System.Diagnostics.Stopwatch.StartNew();
int count = 10000;
}
<h2>Performance Test : Partial View</h2>
<hr />
@for (int i = 1; i < count + 1; i++)
{
@codehaks
codehaks / StarRating.html
Created November 1, 2018 06:58
Stars rating HTML
<i class="fa fa-star" style="color:#ffd800"></i>
<i class="fa fa-star" style="color:#ffd800"></i>
<i class="fa fa-star" style="color:#ffd800"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
@codehaks
codehaks / StarsTagHelper.cs
Created November 1, 2018 06:49
Star rating TagHelper
using Microsoft.AspNetCore.Razor.TagHelpers;
namespace Codehaks.TagHelpers
{
public class StarsTagHelper : TagHelper
{
public int Level { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
@codehaks
codehaks / _Stars.cshtml
Created November 1, 2018 06:45
Star Rating PartialView
@model int
@for (var i = 0; i < 5; i++)
{
if (i < Model)
{
<i class="fa fa-star" style="color:#ffd800"></i>
}
else
{
<i class="fa fa-star-o"></i>
@codehaks
codehaks / Startup.cs
Created October 7, 2018 08:22
Setting Identity Cookie TimeSpan
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddDbContext<AppDbContext>(options =>
options.UseSqlite("Data Source=app.db"));
@codehaks
codehaks / Compare.cs
Created October 3, 2018 08:03
Comparing Strings in C#
public class Compare
{
public IActionResult ToLower()
{
var all = _db.Users.ToList();
var now = DateTime.Now;
int jacksCount = 0;
for (int i = 0; i < 1000; i++)
@codehaks
codehaks / LiteDbConfig.cs
Created October 1, 2018 16:57
LiteDb Injection context
public class LiteDbConfig
{
public string DatabasePath { get; set; }
}
@codehaks
codehaks / LiteDbContext.cs
Created October 1, 2018 16:56
LiteDb Context
using LiteDB;
using Microsoft.Extensions.Options;
using System;
namespace BugPages.Common
{
public class LiteDbContext
{
public readonly LiteDatabase Context;
public LiteDbContext(IOptions<LiteDbConfig> configs)