Skip to content

Instantly share code, notes, and snippets.

View Eonasdan's full-sized avatar

Eonasdan Eonasdan

View GitHub Profile
@Eonasdan
Eonasdan / ExceptionHandlerMiddleware.cs
Last active February 9, 2018 21:33
Borrowed ExceptionHandlerMiddleware from Microsoft.AspNetCore.Diagnostics/Internal/DiagnosticsLoggerExtensions.cs that takes area into effect.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
@Eonasdan
Eonasdan / AddClassHelper.cs
Last active February 15, 2018 16:58
MVC core tag helper for my Bootstrap 4 datapicker https://github.com/tempusdominus/bootstrap-4. Easy to modify for BS3.
/// <summary>
/// Adds <paramref name="newClass"/> to <paramref name="output"/> or appends it.
/// </summary>
/// <param name="output"></param>
/// <param name="newClass"></param>
public static void AddClass(this TagHelperOutput output, string newClass)
{
var classAttribute = output.Attributes.FirstOrDefault(a => a.Name == "class");
if (classAttribute == null)
{
@Eonasdan
Eonasdan / SerializeViewModel.cs
Created March 1, 2018 15:56
a C# MVC helper to take an model object and convert it to a serialized object
public static HtmlString SerializeViewModel(this HtmlHelper helper, object viewModel, JsonSerializerSettings serializer = null)
{
if (serializer == null)
{
serializer =
new JsonSerializerSettings {ContractResolver = new CamelCasePropertyNamesContractResolver()};
}
return new HtmlString(JsonConvert.SerializeObject(viewModel, serializer));
}
@Eonasdan
Eonasdan / !ReadMe
Last active July 14, 2018 14:42
SQLite EF Style Migrations
Note: IFileService is not completely necessary unless you’re doing Xamarin Forms and need.
@Eonasdan
Eonasdan / crystal_flower_plant.json
Last active June 6, 2019 11:56
Agricraft + Seeds For Wizardry + Electroblob's Wizardry. Place under config\agricraft\json\defaults\mod_t3s4ebw
{
"path": "mod_t3s4ebw/crystal_flower_plant.json",
"enabled": true,
"id": "ebwizardry:crystal_flower_plant",
"plant_name": "Crystal Flower",
"seed_name": "Magic Seeds",
"seed_items": [
{
"item": "t3s4ebw:magic_seed",
"meta": 0,
@Eonasdan
Eonasdan / HallOfShame.md
Last active October 5, 2019 14:51
Recruiter Hall of Shame

This is a list of recuiter companies that either

  • Don't actually read/understand your skill profile.
  • Don't pay attention to location requirements
  • Don't pay attention to your job type (full time, contract) requirements.
Company Email Suffix (@xyz.com)
@Eonasdan
Eonasdan / PredicateExtensions.cs
Created April 13, 2020 20:21
Predicate Extensions
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq.Expressions;
namespace Extensions
{
[DebuggerStepThrough]
public static class PredicateExtensions
{
@Eonasdan
Eonasdan / ApplicationDbContext.cs
Created April 15, 2020 20:30
Read dates from SQL as UTC in EF Core
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
//....
var dateTimeConverter = new ValueConverter<DateTime, DateTime>(
v => v.ToUniversalTime(),
v => DateTime.SpecifyKind(v, DateTimeKind.Utc));
var nullableDateTimeConverter = new ValueConverter<DateTime?, DateTime?>(
@Eonasdan
Eonasdan / bootstrap.toast.ts
Created October 2, 2021 14:40
ngx-toastr Bootstrap 5
import { Component } from '@angular/core';
import { GlobalConfig, Toast, ToastPackage, ToastrService } from 'ngx-toastr';
import { BootstrapContextEnum } from '../../models/bootstrap-context-enum';
@Component({
selector: '[bootstrap-toast-component]',
template: `
<div
class="toast {{ containerClass }} show"
role="alert"
@Eonasdan
Eonasdan / ComparePlugin.ini
Last active November 16, 2025 16:29
Notepad++ Compare plugin dark mode colors
[Main]
Old is First=1
Old on Left=1
Default Compare is to Prev=1
Go to First Diff=0
Check Encodings=1
Wrap Around=0
Compact NavBar=1
Ignore Spaces=0
Detect Moves=1