Skip to content

Instantly share code, notes, and snippets.

View enricofoltran's full-sized avatar

Enrico Foltran enricofoltran

View GitHub Profile
@enricofoltran
enricofoltran / README.md
Created January 27, 2019 14:30
SCRIPT-8
@enricofoltran
enricofoltran / main.go
Last active October 3, 2024 14:08
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
<?php
$app['parameters.aws.access_key'] = $_SERVER['AWS_ACCESS_KEY_ID'];
$app['parameters.aws.secret_key'] = $_SERVER['AWS_SECRET_KEY'];
$app['parameters.mailer.host'] = $_SERVER['ASCIIGRAM__MAILER__HOST'];
$app['parameters.mailer.port'] = $_SERVER['ASCIIGRAM__MAILER__PORT'];
$app['parameters.mailer.username'] = $_SERVER['ASCIIGRAM__MAILER__USER'];
$app['parameters.mailer.password'] = $_SERVER['ASCIIGRAM__MAILER__PASS'];
$app['parameters.mailer.encryption'] = $_SERVER['ASCIIGRAM__MAILER__ENCRYPTION'];
@enricofoltran
enricofoltran / services.yml
Created April 3, 2013 15:53
Symfony locale listener configuration
parameters:
acme_i18n.listener.locale_listener.class: Acme\Bundle\I18nBundle\EventListener\LocaleListener
services:
acme_i18n.listener.locale_listener:
class: %acme_i18n.listener.locale_listener.class%
arguments: [ @service_container, "%locales%" ]
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: -255 }
@enricofoltran
enricofoltran / LocaleListener.php
Created April 3, 2013 15:52
Symfony locale listener
<?php
namespace Acme\Bundle\I18nBundle\EventListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class LocaleListener
{
@enricofoltran
enricofoltran / base.html.twig
Created April 3, 2013 14:16
Symfony: display all flash messages in a twig template
{% if app.session.flashbag.peekAll|length > 0 %}
{% for type, messages in app.session.flashbag.all %}
{% for message in messages %}
<div class="{{ type ? type : '' }}">
{{ message|trans({}, domain|default('messages')) }}
</div>
{% endfor %}
{% endfor %}
{% endif %}
@enricofoltran
enricofoltran / .bashrc
Created February 9, 2012 13:15
show current git branch on bash
parse_git_branch()
{
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\033[01;34m\] \w\[\033[31m\]\$(parse_git_branch) \[\033[00m\]$\[\033[00m\] "
@enricofoltran
enricofoltran / Contact.php
Created December 19, 2011 07:54
Contact form with Zend Framework
<?php
/* /library/Square/Form/Contact.php */
class Square_Form_Contact extends Zend_Form
{
public function init()
{