Skip to content

Instantly share code, notes, and snippets.

View shawty's full-sized avatar

Peter "Shawty" Shaw shawty

View GitHub Profile
@shawty
shawty / MailboxConfig.cs
Last active August 4, 2022 15:12
C# code to parse an asterisk voicemail.conf configuration file in the asterisk telephony toolkit. NOTE: depends on "IniParser" available from : https://github.com/rickyah/ini-parser
namespace TelephonyServices.DataModels;
public class MailboxConfig
{
public string MailboxNumber { get; set; } = "";
public string MailboxSecret { get; set; } = "";
public string MailboxName { get; set; } = "";
public string MailboxEmail { get; set; } = "";
public string MailboxPager { get; set; } = "";
public string MailboxOptions { get; set; } = "";
@shawty
shawty / install-dotnet.sh
Created July 28, 2022 12:07
Bash script to provision a standalone Linux container based on Debian, setting it up to run DOTNET 6 SDK and including the Midnight Commander file manager and text editor. (NOTE: Do not use this one, if you are using the 'dotnet.profile' approach, this script is ONLY for use with OS's that do not have cloud-init in the base image, if you have a …
#!/bin/bash
if [ -z "$1" ]
then
echo "Container name must be provided on first parameter"
echo "USAGE: install-dotnet.sh <containername>"
exit 1
fi
lxc file push ./install-script $1/root/install.sh
@shawty
shawty / adduser.sh
Created July 28, 2022 12:01
Provisioning Scripts that I use for managing containers running DOTNET 6 projects on LXD/LXC installs under Ubuntu server.
#!/bin/bash
if [ -z "$1" ]
then
echo "User name must be provided on first parameter"
echo "USAGE: createuser.sh <username> <containername>"
exit 1
fi
if [ -z "$2" ]
then
@shawty
shawty / dotnet.profile
Last active July 28, 2022 15:28
LXD Profile to add to your LXD install, allowing the creation of lightweight DOTNET 6 containers when using "lxc launch" (EG: lxc launch ubuntu mycontainer -p dotnet) , you can add this profile to LXD using the following command: "cat dotnet.profile | lxc profile edit dotnet" from the ubuntu command line.
config:
user.user-data: |
#cloud-config
apt:
preserve_sources_list: true
sources:
microsoft:
keyserver: https://packages.microsoft.com/keys/microsoft.asc
keyid: BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF
@shawty
shawty / provisondnc.sh
Created September 4, 2021 11:39
Linux Bash Provisioning Script to deploy a Blazor Server app to a Linux LXC container. #linux #lxd #container #dotnet #blazor
#! /bin/bash
#Container is a new instance, so first thing we do is update the base software
apt update
apt upgrade -y
#Then we add the base tools we require along with the apache webserver
apt install mc -y
apt install gnupg -y
apt install apache2 -y
@shawty
shawty / SqlTableToCSharp.sql
Last active October 28, 2020 13:07
SQL Server 2012 upwards, stored procedure to write a C# class for a given table name
create procedure [utils].[SqlTableToCSharp]
@tableName nvarchar(MAX)
as
begin
declare @classBody nvarchar(MAX) = '';
@shawty
shawty / GridEditor.razor
Last active October 24, 2023 09:48
Blazor component to allow editing of a data table using a simple grid and drop down
@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 / _BS4Validation.cshtml
Last active November 6, 2019 19:29
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.
<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 / rpi_install_instructions.txt
Last active March 17, 2021 23:32
Instructions on how to get the latest dotnet core 3 (as of 24th April 2019) and Blazor running on a Raspberry PI
*******************************************************************************************************
** 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
@shawty
shawty / JwtDecoder.cs
Created April 11, 2019 21:03
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. :-)
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)