Skip to content

Instantly share code, notes, and snippets.

View pwhe23's full-sized avatar

Paul Wheeler pwhe23

View GitHub Profile
@pwhe23
pwhe23 / FreshdeskJWT.cs
Last active May 25, 2021 18:09
FreshDesk SSO using JWT with C#
// https://www.nuget.org/packages/JWT/
using JWT.Algorithms;
using JWT.Builder;
using Microsoft.AspNetCore.WebUtilities;
using System.Security.Cryptography;
class Program
{
void Main()
{
@pwhe23
pwhe23 / JsonTempDataSerializer.cs
Created October 12, 2020 18:22
JsonTempDataSerializer
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Infrastructure;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
public class JsonTempDataSerializer : TempDataSerializer
{
private readonly JsonSerializer _jsonSerializer = JsonSerializer.CreateDefault(new JsonSerializerSettings
@pwhe23
pwhe23 / ExecuteCsx.cs
Last active September 11, 2020 13:50
ExecuteCSX
using Dotnet.Script.Core;
using Dotnet.Script.DependencyModel.Context;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
public static T ExecuteCsx<T>(string scriptPath, params string[] args)
{
using var scriptStream = File.OpenRead(scriptPath);
var compiler = new ScriptCompiler(LogFactory, true);
var runner = new ScriptRunner(compiler, LogFactory, ScriptConsole.Default);
@pwhe23
pwhe23 / ConfigureFromClass.csx
Created May 9, 2020 15:32
System.CommandLine ConfigureFromClass example
#r "nuget: System.CommandLine, 2.0.0-beta1.20253.1"
//https://discoverdot.net/projects/dotnet-script
using System;
using System.CommandLine;
using System.CommandLine.Binding;
using System.CommandLine.Invocation;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
@pwhe23
pwhe23 / Main.cs
Last active May 9, 2020 23:16
System.CommandLine ConfigureFromClass example
//Nuget: System.CommandLine
//Nuget: System.ComponentModel.Annotations
using System;
using System.CommandLine;
using System.CommandLine.Binding;
using System.CommandLine.Invocation;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;

Keybase proof

I hereby claim:

  • I am pwhe23 on github.
  • I am paulwheeler (https://keybase.io/paulwheeler) on keybase.
  • I have a public key whose fingerprint is FAAF A0C9 F0CD 5655 9A40 F7C8 9313 BA6E 7AF9 CEC8

To claim this, I am signing this object:

@pwhe23
pwhe23 / Random.ps1
Last active August 29, 2015 14:06
Random.ps1
Add-Type -AssemblyName 'System.Windows.Forms'
Add-Type -AssemblyName 'Microsoft.VisualBasic'
$maximum = [int][Microsoft.VisualBasic.Interaction]::InputBox("Enter Maximum (inclusive)", "Max", "5")
$popup = $true
function Main() {
if ($Host.Name -eq "Windows Powershell ISE Host") {
Clear-Host
}
## Automate FTP uploads
## Go to destination
cd C:\Test
$location = Get-Location
"We are here: $location"
## Get files
$files = Get-ChildItem -recurse
## Get ftp object
$ftp_client = New-Object System.Net.WebClient
$ftp_address = "ftp://user:pass@adress:/home/chardcastle/test"
@pwhe23
pwhe23 / Sync.cs
Created July 9, 2014 15:27
Sync FtpClient
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
namespace System.Net.FtpClient
{
public class Sync
@pwhe23
pwhe23 / GenerateProcCalls.tt
Last active May 13, 2021 09:57
Generate Proc calls from Database
<#@ Template Debug="true" HostSpecific="true" #>
<#@ Output Extension=".cs" #>
<#@ Assembly Name="Microsoft.CSharp" #>
<#@ Assembly Name="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" #>
<#@ Assembly Name="System.Core" #>
<#@ Assembly Name="System.Data" #>
<#@ Import Namespace="System" #>
<#@ Import Namespace="System.Collections" #>
<#@ Import Namespace="System.Collections.Generic" #>
<#@ Import Namespace="System.Configuration" #>