Skip to content

Instantly share code, notes, and snippets.

View yordis's full-sized avatar
💜
Helping people one second at the time

Yordis Prieto yordis

💜
Helping people one second at the time
View GitHub Profile
@yordis
yordis / git-subdirectory-tracking.md
Created September 16, 2021 07:15 — forked from tswaters/git-subdirectory-tracking.md
Adding subdirectory of a remote repo to a subdirectory in local repo

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

defmodule EventStore.CategoryStreamLinker do
@moduledoc """
Links streams from aggregate instances to their respective category streams.
example: events from stream_uuid of `contractors_contract-07c52787-da0c-444f-9783-5d380f7093f9` will be
linked to stream_uuid of `contractors_contract`.
"""
use Commanded.Event.Handler,
application: My.App,
@yordis
yordis / frontmatter.js
Created July 25, 2021 21:53 — forked from sudkumar/frontmatter.js
MDX Remark plugin to handle frontmatter
// helps us in parsing the frontmatter from text content
const matter = require('gray-matter')
// helps us safely stringigy the frontmatter as a json object
const stringifyObject = require('stringify-object')
// helps us in getting the reading time for a given text
const readingTime = require('reading-time')
// please make sure you have installed these dependencies
// before proceeding further, or remove the require statements
// that you don't use
@yordis
yordis / generic_proxy.erl
Created June 14, 2021 19:08 — forked from marcelog/generic_proxy.erl
Quick and small tcp proxy written in erlang. Opens a socket and listens for incoming connections. For every new incoming connection, it will open a connection to the proxied host, and send whatever it gets from either side to the other.
-module(generic_proxy).
-export([run/0]).
-define(PORT_FROM, 63790).
-define(PORT_TO, 6379).
-define(BACKLOG, 10000).
run() ->
{ok, Socket} = gen_tcp:listen(0, [
@yordis
yordis / simple_txn_struct.go
Created June 8, 2021 06:33 — forked from StephenBrown2/simple_txn_struct.go
Simple transaction struct format from json
// This file was generated from JSON Schema using quicktype, do not modify it directly.
// To parse and unparse this JSON data, add this code to your project and do:
//
// txns, err := UnmarshalTransactionList(bytes)
// bytes, err = txns.Marshal()
package main
import "encoding/json"
@yordis
yordis / domain.go
Created May 8, 2021 16:42 — forked from alexrudd/domain.go
EventStoreDB: storing proto messages in events
package domain // domain layer
import "google.golang.org/protobuf/proto"
// Event represents a domain event that has been retreived from the event store.
type Event interface {
ID() string
Revision() uint64
Data() proto.Message
}
@yordis
yordis / 1 - PII Encryption with Elixir, Commanded, Vault.md
Created April 21, 2021 19:38 — forked from jwilger/1 - PII Encryption with Elixir, Commanded, Vault.md
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
@yordis
yordis / ELIXIR_DIALYZER.md
Last active February 5, 2021 08:07
Erlang Dialyzer + Elixir
  1. Run mix dialyzer in your project
mix dialyzer
  1. Run the following bash code, make sure to verify the environments
export ERLANG_VERSION=23.2
@yordis
yordis / eventstore.cs
Created January 6, 2021 02:39 — forked from adymitruk/eventstore.cs
simple event store in #0tech c#
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Text;
using System.Threading;
using System.Xml;
using System.Xml.Serialization;
using System.Linq;
using domain;
{
"environment": "staging"
}