Skip to content

Instantly share code, notes, and snippets.

Avatar

Enrico Foltran enricofoltran

View GitHub Profile
@enricofoltran
enricofoltran / main.go
Last active Sep 25, 2022
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
View main.go
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
View parameters.php.aws
<?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 Apr 3, 2013
Symfony locale listener configuration
View services.yml
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 }
View LocaleListener.php
<?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 Apr 3, 2013
Symfony: display all flash messages in a twig template
View base.html.twig
{% 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 Feb 9, 2012
show current git branch on bash
View .bashrc
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 Dec 19, 2011
Contact form with Zend Framework
View Contact.php
<?php
/* /library/Square/Form/Contact.php */
class Square_Form_Contact extends Zend_Form
{
public function init()
{