Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter "Shawty" Shaw shawty

View GitHub Profile
@shawty
shawty / MailboxConfig.cs
Last active Aug 4, 2022
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
View MailboxConfig.cs
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 Jul 28, 2022
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 …
View install-dotnet.sh
#!/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 Jul 28, 2022
Provisioning Scripts that I use for managing containers running DOTNET 6 projects on LXD/LXC installs under Ubuntu server.
View adduser.sh
#!/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 Jul 28, 2022
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.
View dotnet.profile
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 Sep 4, 2021
Linux Bash Provisioning Script to deploy a Blazor Server app to a Linux LXC container. #linux #lxd #container #dotnet #blazor
View provisondnc.sh
#! /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 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 / 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 / _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 / 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
@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)