Skip to content

Instantly share code, notes, and snippets.

@trbngr
trbngr / delete_stream_events_of_type_function.sql
Last active March 16, 2023 11:40
Delete events of a certain type from a stream
create or replace function delete_stream_events_of_type(target_stream_id bigint, target_event_type text) returns integer
language sql
as
$$
-- disable triggers
alter table stream_events disable trigger no_update_stream_events;
alter table stream_events disable trigger no_delete_stream_events;
alter table events disable trigger no_delete_events;
defmodule Mix.Tasks.InspectAggregate do
use Mix.Task
alias MyApp.EventStore
def run(args) do
Application.ensure_all_started(:eventstore)
_ = EventStore.start_link()
{opts, _} =
@jwilger
jwilger / 1 - PII Encryption with Elixir, Commanded, Vault.md
Last active August 12, 2023 03:06
Quick Code Sample on Encrypting PII with Commanded for GDPR/CCPA Compliance

This code is extracted from one of my private projects as an example of how to implement encryption of PII in event streams using two keys: a master key for each "data subject" that is stored in Vault and never transported to the systems that process the PII, and a key unique to each event that is stored (itself encrypted) with the event.

To be clear, the key that is stored with the data is encrypted by another key that is not stored with the data. The idea is that each "data subject" has an encryption key that is stored in Vault (external). When you encrypt data, the library will:

  1. create a new AES 256 encryption key
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files: