Skip to content

Instantly share code, notes, and snippets.

View laurencee's full-sized avatar

Laurence0x03 laurencee

  • Brisbane, Australia
View GitHub Profile
@laurencee
laurencee / ArtifactDtos.cs
Created July 31, 2024 00:38
C# DTO dump for ArtifactMMO
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
using System.Text.Json.Serialization;
// ReSharper disable PropertyCanBeMadeInitOnly.Global
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable InconsistentNaming
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
@laurencee
laurencee / SerializeIConfiguration.cs
Created September 4, 2022 08:19
Serialize .NET IConfiguration to json
// Small modification of https://stackoverflow.com/a/62533775/2631967
JToken SerializeConfiguration(IConfiguration config)
{
var obj = new JObject();
foreach (var child in config.GetChildren())
{
if (child.Path.EndsWith(":0"))
{
var arr = new JArray();
@laurencee
laurencee / set_octopus_var_for_env.ps1
Last active March 27, 2018 19:32
Sets an octopus variable for an environment
<#
.SYNOPSIS
Create or update an octopus variable
.DESCRIPTION
Registers a machine as an octopus tentacle and will unregister any existing same-named tentacle.
.PARAMETER projectName
The name of the project in Octopus
.PARAMETER variableName
The name of the variable to be created/updated
.PARAMETER machineRoles
# Usage: powershell ExtractInitialDatabaseScript.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
function GenerateDBScript([string]$ServerName, [string]$Database, [string]$scriptpath) {
$outFile = "$scriptpath\$($Database)_Inital_setup.sql"
if (-not (Test-Path $scriptpath)) {
[System.IO.Directory]::CreateDirectory($scriptpath)
}
If (Test-Path $outFile) {
Remove-Item $outFile
}
@laurencee
laurencee / Program.cs
Last active December 29, 2015 09:09
Redis subscription handling sending json serialized types through redis pub/sub using servicestack redis/common/text
using System;
using System.Data;
using System.Runtime.Remoting.Messaging;
using System.Threading.Tasks;
namespace RedisClientPrototype
{
class Program
{
static void Main(string[] args)