Skip to content

Instantly share code, notes, and snippets.

View massimoselvi's full-sized avatar

Massimo Selvi massimoselvi

View GitHub Profile
<?php
namespace app\support\stubs;
/**
* Fix relations
* @see https://github.com/laravel/framework/pull/6576
*
*/
use Illuminate\Database\Eloquent\Relations\HasOne;
https://laracasts.com/search?q=polymorphic
https://laracasts.com/search?q=relationships
http://codeplanet.io/laravel-model-relationships-pt-1

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@massimoselvi
massimoselvi / SassMeister-input.scss
Created November 24, 2016 20:14 — forked from davidkpiano/SassMeister-input.scss
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
$scotch-color-key: 'base' !default;
$scotch-colors: (
'primary': (
'base': #8e3329,
@massimoselvi
massimoselvi / SparkRoleMiddleware.md
Created December 8, 2016 23:39 — forked from dillinghamio/SparkRoleMiddleware.md
Team Role Middleware For Laravel Spark

Team Role Middleware For Laravel Spark

Makes it simple to use Spark's role feature on routes

Route::group(['middleware'=>'role:owner'], function(){
    // owners only
});

Route::group(['middleware'=>'role:member'], function(){
@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