Skip to content

Instantly share code, notes, and snippets.

View massimoselvi's full-sized avatar

Massimo Selvi massimoselvi

View GitHub Profile
@massimoselvi
massimoselvi / php-mcrypt-homebrew.md
Created March 8, 2018 09:14 — forked from teroyks/php-mcrypt-homebrew.md
Add PHP mcrypt extension on Mac OS X with Homebrew

You can install the mcrypt PHP extension with homebrew and use it with the standard PHP installation that comes with OS X.

Install mcrypt:

brew install mcrypt

Install the php extension -- this installs the whole php 5.5, but you can still use the system-provided one by default Note: install the version compatible with whatever your OS X PHP version currently is (check with php -v)

brew install homebrew/php/php55-mcrypt

@massimoselvi
massimoselvi / add_cloudflare_ips.sh
Created September 24, 2018 07:56 — forked from dduvnjak/add_cloudflare_ips.sh
Add CloudFlare IP addresses to an EC2 Security Group using awscli
# first we download the list of IP ranges from CloudFlare
wget https://www.cloudflare.com/ips-v4
# iterate over the lines in the downloaded file
# make sure to set `--group-id` and `--port`; more details at http://docs.aws.amazon.com/cli/latest/reference/ec2/authorize-security-group-ingress.html
while read p; do aws ec2 authorize-security-group-ingress --group-id sg-e0000000 --protocol tcp --port 80 --cidr $p; done< ips-v4

AWS Lambda Event Sourcing Architecture

I'd like to have a AWS lambda / event system that allows for a certain kind of flexability, here's what I need.

  • Events come in via HTTP post webhook with headers and body
    1. Store {headers, body} in one main events table where the event is named what the action is e.g. 'orderCreate', this acts as a ledger of events, with the main columns name, data, created_at.
    2. I'd like to build up the state of individual object, in their own table so for orders a table would exist with that name the event of a orderCreated the row is created and subsiquent orderDeleted the row is deleted.
  1. I need a way to tap into this event and trigger some side-effect event, for instance if a orderCreated comes in to the system I also need to fire something when that comes in such as invoiceCreated I need a way to access the stream of all events and subscribe to the orderCreated and fire a invoiceCreated which ideally should repeat this process all over again
@massimoselvi
massimoselvi / machine.js
Last active December 20, 2020 08:10
Generated by XState Viz: https://xstate.js.org/viz
/*
* FETCH MACHINE (work in progress)
* preview: https://xstate.js.org/viz/?gist=0291cafd5f583c165a3ef1dd35bf02af
*/
// Available variables:
// - Machine
// - interpret
// - assign
// - send
@massimoselvi
massimoselvi / machine.js
Last active December 20, 2020 08:11
Generated by XState Viz: https://xstate.js.org/viz
/*
* FETCH MACHINE bis (work in progress)
* preview: https://xstate.js.org/viz/?gist=a3768c794e1d159d1740225d0899c43c
* previous: https://xstate.js.org/viz/?gist=0291cafd5f583c165a3ef1dd35bf02af
*/
// Available variables:
// Machine (machine factory function)
// assign (action)
// XState (all XState exports)
@massimoselvi
massimoselvi / machine.js
Last active December 20, 2020 08:04
Generated by XState Viz: https://xstate.js.org/viz
// https://xstate.js.org/viz/?gist=caa428d6095266ec9cb79b033c7d9017
/*
* https://xstate.js.org/viz/?gist=caa428d6095266ec9cb79b033c7d9017
*/
const yellowStates = {
initial: 'normal',
context: {
blinking: false
@massimoselvi
massimoselvi / machine.js
Last active December 20, 2020 08:06
Generated by XState Viz: https://xstate.js.org/viz
/*
* Entity CRUD bis
* preview: https://xstate.js.org/viz/?gist=5cee8452667147d56aa04f4bbfb0ed2d
*/
const machine = Machine({
id: 'fetch',
initial: 'idle',
states: {
idle: {
@massimoselvi
massimoselvi / machine.js
Last active December 20, 2020 08:06
Generated by XState Viz: https://xstate.js.org/viz
/*
* Entity CRUD
* preview: https://xstate.js.org/viz/?gist=31505a4986fab5d82190d55eec826648
*/
const machine = Machine({
id: 'handler',
initial: 'idle',
states: {
idle: {
@massimoselvi
massimoselvi / machine.js
Last active December 20, 2020 08:08 — forked from sbussard/machine.js
Generated by XState Viz: https://xstate.js.org/viz
/*
* User centric API
* preview: https://xstate.js.org/viz/?gist=6a454e83ee19acb9ab1a79b0657dd60f
*/
// Available variables:
// - Machine
// - interpret
// - assign