Skip to content

Instantly share code, notes, and snippets.

View mlienau's full-sized avatar

Mitchell Lienau mlienau

  • feature[23]
  • Jacksonville, FL
View GitHub Profile
@mlienau
mlienau / readme.md
Last active April 26, 2023 18:58
An Angular directive to update a input type date's year to the current year if you only type the last two digits of the current year

HTML <input type="date" /> elements store the value as an ISO8601 (YYYY-MM-DD) date string, but for us Americans it's very common for us to write the date as m/d/yy.

The Problem

If you write the value as M/D/YY, that's a valid date but the value becomes 00YY-MM-DD which is an invalid SQL Server date and causes errors when it shouldn't necessarilly.

Adding this directive to any <input type="date" /> should change the value to {CURRENT_FULL_YEAR}-MM-DD automatically if you enter M/D/{LAST_TWO_DIGITS_OF_CURRENT_YEAR}.

Disclaimer - This probably will not work well after the year 9999.

@mlienau
mlienau / app.component.ts
Created August 26, 2022 20:23
Full screen mat-dialog
/* This DOES NOT need to be in app.component.ts,
* it can be anywhere, but for optimal performance the listener should probably only be added once
*/
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit, OnDestroy {
title = 'app';
@mlienau
mlienau / Component.razor
Created April 1, 2022 02:35
Blazor: View PDF in new tab from byte array
@inject IJSRuntime JSRuntime
@implements IAsyncDisposable
@code {
string? localFileUrl;
async Task ViewThePdf()
{
var response = await Api.GetPdfResponse("/route/to/pdf");
var pdfBytes = await response.Content.ReadAsByteArrayAsync(); // using Refit
import * as React from "react";
export interface Column<TItem> {
title?: React.ReactNode;
tdProps?: React.HTMLProps<HTMLTableCellElement>;
thProps?: React.HTMLProps<HTMLTableHeaderCellElement>;
renderer?: (item: TItem, index?: number, array?: TItem[]) => React.ReactNode | JSX.Element;
key: keyof (TItem);
/**
* @param: The lower case representation of the searchable value
@mlienau
mlienau / DictionaryToMapConverter.cs
Created February 9, 2018 20:29
JSON.NET converter for serializing a C# Dictionary to a javascript Map initialization array
public class DictionaryToMapConverter<TKey, TValue> : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return false;
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
// I'm only using this for writing as of now