Skip to content

Instantly share code, notes, and snippets.

@zofe
zofe / docker-compose-proxy.md
Last active February 11, 2020 09:32
Host multiple websites with docker-compose & nginx reverse proxy

docker-compose + nginx reverse proxy

local & stage development with docker-compose & nginx-proxy to host multiple websites on a stage server

two environments: local & stage ( with multiple domains on stage using proxy network)

software needed: docker + docker-compose

ref: https://blog.ssdnodes.com/blog/host-multiple-websites-docker-nginx/

Install Supervisor with sudo apt-get install supervisor in Unix or brew install supervisor in Mac OSX. Ensure it's started with sudo service supervisor restart in Unix or brew services start supervisor in Mac OSX.

In Unix in /etc/supervisord/conf.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

In Mac OSX first run supervisord -c /usr/local/etc/supervisord.ini and in /usr/local/etc/supervisor.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

This file points at /usr/local/bin/run_queue.sh, so create that file there. Give this execute permissions, too: chmod +x run_queue.sh.

Now update Supervisor with: sudo supervisorctl reread in Unix and with: brew services restart supervisor in MAc OSX . And start using those changes with: sudo supervisorctl update.

@zofe
zofe / RouteServiceProvider.php
Last active October 12, 2018 14:31
customized version of RouteServiceProvider (Laravel 5.6+) to enable dinamically a prefix (/{lang}/route-name) to support multilanguage, and keeping no prefix for default language.
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
@zofe
zofe / git.alzheimer.md
Last active July 22, 2018 08:33
appunti di git

comandi principali

  • git clone: crea una copia locale di un archivio remoto
  • git fetch: scarica gli aggiornamenti su di un ramo locale
  • git branch: crea, rinomina, cancella i rami dell'albero
  • git checkout: estrae i file relativi ad una versione o un ramo
  • git add: predispone il salvataggio di uno o più file modificati
  • git commit: salva nell'archivio una patch
  • git rebase: sposta la base di un ramo innestandola altrove
  • git log: mostra lo storico del ramo o di un file
@zofe
zofe / a14.metano.md
Created July 20, 2018 15:35
distributori metano A14 - Bari-Bologna / Bologna-Bari

distributori metano A14 (salire BARI-BOLOGNA)

  • uscita Vasto Nord (1 km dal casello direzione vasto, alla seconda rotonda sx, chiuso domenica)
  • Area di Servizio Esino Est (ENI-Sarni, dopo ancona-nord)
  • Area di Servizio Bavano Est (ENI-Autogrill, dopo cesena-nord)

distributori metano A14 (scendere BOLOGNA-BARI)

@zofe
zofe / rocket.chat.compute.engine.appunti.md
Last active November 27, 2018 16:00
appunti installazione rocket chat su google cloud ( compute engine )
@zofe
zofe / parallelize.helper.php
Created June 29, 2018 15:03
parallelize php process helper
<?php
function parallelize($func, $arr, $procs=4)
{
//to work with collections
//but you can also use chunk() n.f.
$chunks = $arr->chunk(ceil((count($arr) / $procs)));
$pid = -1;
$children = array();
foreach ($chunks as $items) {
@zofe
zofe / appunti_docker.md
Last active November 15, 2017 15:29
appunti docker

requisiti per creare ambienti docker adatti allo sviluppo

Dockerfile di esempio, prende una distro (lamp minimale basata su alpine-linux), installa pacchetti..
configura variabili d'ambiente, copia file di configurazione, apre porte

    FROM janes/alpine-lamp
@zofe
zofe / index.php
Created October 19, 2016 14:22 — forked from tacone/index.php
<?php
/*
|--------------------------------------------------------------------------
| Check for maintenance
|--------------------------------------------------------------------------
|
| Se l'applicazione è standby proviamo ad aspettare che torni su. In questo
| modo l'utente non riceve messaggi di errore durante il deploy, non perde
| i dati inviati nel form, etc.
@zofe
zofe / rest.php
Last active September 28, 2016 16:16
general purpose rest client
<?php
//general purpose rest client
function rest_helper($url, $params = null, $body="", $verb = "GET", $format = "json", $auth_token='mytoken')
{
$cparams = array(
"http" => array(
"method" => $verb,
"ignore_errors" => true,
"timeout" => 5,
)