Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter "Shawty" Shaw shawty

View GitHub Profile
@shawty
shawty / JwtDecoder.cs
Created Apr 11, 2019
Quick and dirty JWT Token decoder class to use in Blazor based projects, since trying to use the official MS Jwt Token libs at present causes things to blow up. :-)
View JwtDecoder.cs
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace IntranetV6.Client.Classes
{
public static class StringExtensions
{
public static int GetNextHighestMultiple(this int source, int multipicand)
@shawty
shawty / _BS4Validation.cshtml
Last active Nov 6, 2019
Quick & dirty but very simple ASP.NET MVC Partial that allows you to use the MVC/Razor validation attributes on your models, but have the classes on those models work with Bootstrap 4's validation styles.
View _BS4Validation.cshtml
<script>
let errorElements = Array.from(document.getElementsByClassName("input-validation-error"));
errorElements.forEach(element => {
let inputElement = $(element);
let messageDiv = inputElement.next("div");
if (messageDiv) {
messageDiv.text(inputElement.data("val-required"));
@shawty
shawty / GridEditor.razor
Last active Nov 13, 2019
Blazor component to allow editing of a data table using a simple grid and drop down
View GridEditor.razor
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Web
@using MyProject.DataModels
@inject MyProject.Services.ClientGridData _gridDataService
@inject MyProject.Services.Clients _dropDownDataService
<div class="row d-flex align-items-center">
<div class="col">
@shawty
shawty / SqlTableToCSharp.sql
Last active Oct 28, 2020
SQL Server 2012 upwards, stored procedure to write a C# class for a given table name
View SqlTableToCSharp.sql
create procedure [utils].[SqlTableToCSharp]
@tableName nvarchar(MAX)
as
begin
declare @classBody nvarchar(MAX) = '';
@shawty
shawty / rpi_install_instructions.txt
Last active Mar 17, 2021
Instructions on how to get the latest dotnet core 3 (as of 24th April 2019) and Blazor running on a Raspberry PI
View rpi_install_instructions.txt
*******************************************************************************************************
** PLEASE NOTE THAT THIS IS NOW SOMEWHAT OUT OF DATE, THE GENERAL APT-GET LINUX INSTALL INSTRUCTIONS **
** FOR UBUNTU/DEBIAN NOW LARGLEY WORK ON RASBIAN **
*******************************************************************************************************
First things first, make sure your Raspberry PI has the latest updates for Raspbian on by running
sudo apt-get -y update
sudo apt-get -y upgrade