Skip to content

Instantly share code, notes, and snippets.

View K-Phoen's full-sized avatar

Kévin Gomez K-Phoen

View GitHub Profile
@K-Phoen
K-Phoen / grafana_alert_slack_template.tmpl.go
Created June 19, 2022 19:23
Improved Slack template for Grafana alerts
{{ define "custom_alert.title" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}: {{ .Alerts.Firing | len }}{{ if gt (.Alerts.Resolved | len) 0 }}, RESOLVED: {{ .Alerts.Resolved | len }}{{ end }}{{ end }}]{{ if gt (len .GroupLabels) 0 }} Grouped by: {{ range .CommonLabels.SortedPairs }}{{ .Name }}: {{ .Value }}{{ end }}{{ end }}{{ end }}
{{ define "__text_alert_name" }}{{ range .Labels.SortedPairs }}{{ if eq .Name "alertname" }}{{ .Value }}{{ end }}{{ end }}{{ end }}
{{ define "__text_alert_summary" }}{{ range .Annotations.SortedPairs }}{{ if eq .Name "summary" }}{{ .Value }}
{{ end }}{{ end }}{{ end }}
{{ define "__text_alert_description" }}{{ range .Annotations.SortedPairs }}{{ if eq .Name "description" }}{{ .Value }}{{ end }}{{ end }}{{ end }}
{{ define "__text_alert_runbook_url" }}{{ range .Annotations.SortedPairs }}{{ if eq .Name "runbook_url" }}
:bookmark_tabs: <{{ .Value }}|Playbook>{{ end }}{{ end }}{{ end }}
{{ define "__text_alert_firing_item" }}:bell: {{ template "__text_alert_name" . }}
{{ te
@K-Phoen
K-Phoen / data_transformer.php
Last active August 29, 2015 14:15
RulerZ, specifications and Symfony are in a boat
class SpecificationToStringTransformer implements DataTransformerInterface
{
private $specificationClass;
private $valuePath;
private $accessor;
public function __construct($specificationClass, $valuePath)
{
$this->specificationClass = $specificationClass;
$this->valuePath = $valuePath;
@K-Phoen
K-Phoen / keybase.md
Created February 10, 2015 23:12
keybase.md

Keybase proof

I hereby claim:

  • I am K-Phoen on github.
  • I am kphoen (https://keybase.io/kphoen) on keybase.
  • I have a public key whose fingerprint is 57A4 79D4 C383 6309 2BB4 0A21 2069 4939 A2EC 0900

To claim this, I am signing this object:

@K-Phoen
K-Phoen / criteria.php
Last active July 21, 2017 18:36
On Taming Repository Classes in Doctrine… Among other things.
interface Specification
{
public function getCriteria();
}
class FilterGroup implements Specification
{
private $group;
public function __construct($group)
@K-Phoen
K-Phoen / AcmeBlogExtension.php
Created October 14, 2013 11:55
How to split the validation.yml file
<?php
namespace Acme\BlogBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;
class AcmeBlogExtension extends Extension
@K-Phoen
K-Phoen / Replace.php
Created July 29, 2013 22:21
MySQL REPLACE() for Doctrine2
<?php
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
/**
* REPLACE(str, from_str, to_str)
@K-Phoen
K-Phoen / autoload_composer.json
Last active December 20, 2015 09:29
Introduction à Composer - Partie 2
{
"require": {
"propel/propel-service-provider": ">=0.0.1",
"propel/propel1": "1.6.*",
"silex/silex": "1.0.*",
"symfony/validator": "2.1.*",
"willdurand/hateoas": "0.0.*",
"symfony/property-access": "2.2.*",
"symfony/yaml": "2.2.*",
"jms/metadata": "1.2.*",
@K-Phoen
K-Phoen / RouterMatchCommand.php
Created June 13, 2013 12:20
Little improvement to the Symfony router:match command
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@K-Phoen
K-Phoen / AppKernel.php
Created January 9, 2013 15:38
Functional tests for standalone Symfony2 bundles
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
return array(
@K-Phoen
K-Phoen / config.yml
Created December 18, 2012 11:22
Storing Symfony2 sessions in memcached
imports:
# ....
- { resource: services/session.yml }
framework:
# ....
session:
handler_id: session.handler.memcached