Skip to content

Instantly share code, notes, and snippets.

View malscent's full-sized avatar

Justin Ashworth malscent

  • Couchbase
  • West Palm Beach, FL
View GitHub Profile
@malscent
malscent / cb-vpc-connect.template
Created September 15, 2021 15:14
Couchbase Connect 2021 - Demo VPC CFT
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "This template is a demo template from Connect 2021, it represents a recommended infrastructure setup for Couchbase Server and Sync Gateway, with Local zone usage. It includes a bastion host, which creates its own SSH keypair upon deployment.",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
{
"Label": {
"default": "Environment Configuration"
},
@malscent
malscent / cb-gateway.template
Last active September 16, 2021 14:37
Couchbase Connect 2021 - Demo Sync Gateway CFT
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Couchbase Sync Gateway on Amazon Linux 2",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
{
"Label": {
"default": "Network Configuration/Access"
},
@malscent
malscent / cb-server-connect.template
Created September 15, 2021 15:10
Couchbase Connect 2021 CFT Demo - Couchbase Server
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Couchbase Enterprise Edition Server on Amazon Linux 2",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
{
"Label": {
"default": "Network Configuration/Access"
},
@malscent
malscent / IValidTokenGenerator
Created October 9, 2020 18:42
How we do token generation from a CLI using client id and secret
using System.Collections.Generic;
using System.Threading.Tasks;
namespace valid.apiframework.core.interfaces
{
public interface IValidTokenGenerator
{
Task<string> GetBearerTokenAsync(string AuthorityUrl, string ClientId, string ClientSecret, List<string> Scopes);
Task<string> GetPasswordTokenAsync(string AuthorityUrl, string UserName, string Password, string ClientId, string ClientSecret, List<string> Scopes);
}
@malscent
malscent / TestingFunctionality.cs
Created September 22, 2020 21:13
This is a basic test to handle the streaming of an event, building projection and asserting that snapshot is built correctly
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BuildUp.InMemoryImplementation;
using BuildUp.Models;
using Xunit;
namespace BuildUp.Test
{
using System.Collections.Generic;
using System.Data.Common;
using System.IO;
using Marten;
using Marten.Schema;
using Marten.Storage;
using Marten.Util;
namespace tx.DataAccessLayer.Schema
{
@malscent
malscent / DeleteAndPatchTests.cs
Created September 16, 2020 23:07
How to specify patchable/delete events for heuristics when building projections
using System;
using System.Linq;
using Xunit;
namespace BuildUp.Test
{
public class DeleteAndPatchTests
{
public class DeleteEvent
{
@malscent
malscent / BasicOperations.cs
Created September 15, 2020 18:37
Basic operation tests of a Projection building process
using System;
using System.Runtime;
using System.Runtime.InteropServices.ComTypes;
using System.Security.Cryptography.X509Certificates;
using Xunit;
namespace BuildUp.Test
{
public class BasicOperations
{
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
namespace action_tests
{
class Program
{
static void Main(string[] args)
{
@malscent
malscent / SessionCreation.cs
Created March 6, 2020 13:40
How we create a session within our unit of work.
private bool StartSession()
{
// _connection is a wrapper NpgsqlConnection that is passed in the constructor of the UnitOfWork
// if a session already exists, don't need to create a new one.
if (_session?.Connection != null)
{
return true;
}
// If when creating the unit of work, a transaction was not passed in we
// enlist in any ambient transactions