Skip to content

Instantly share code, notes, and snippets.

View geerteltink's full-sized avatar
🏠
Home office

Geert Eltink geerteltink

🏠
Home office
View GitHub Profile
@geerteltink
geerteltink / base.html.twig
Created November 1, 2014 21:33
Symfony 2.4 flash messages
<ul class="list-unstyled container js-notifications">
{% if app.session and app.session.flashbag %}
{% for label, flashes in app.session.flashbag.all %}
{% for flash in flashes %}
<li class="alert alert-{{ label }} alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
{{ flash }}
</li>
{% endfor %}
{% endfor %}
@geerteltink
geerteltink / default.html
Created November 1, 2014 21:34
Jekyll Atom feed
<!doctype html>
<html lang="en">
<head>
<!-- Other head stuff here -->
<link rel="alternate" type="application/atom+xml" title="News Feed" href="{{ site.url }}/site/feed.xml" />
</head>
<body>
<!-- Content -->
</body>
</html>
@geerteltink
geerteltink / DynamicRouterController.php
Created November 1, 2014 21:36
Symfony 2 Dynamic Router
<?php
namespace Acme\ContentBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* Dynamic router controller
*
@geerteltink
geerteltink / ToastNotifier.php
Created November 8, 2014 15:23
Using sismo as your personal CI server on windows.
<?php
namespace Sismo\Contrib;
use Sismo\Commit;
use Sismo\Notifier\Notifier;
/**
* Notifies build status via toast notifications
*
@ECHO OFF
setlocal ENABLEDELAYEDEXPANSION
SET _START=%CD%
ECHO.
ECHO -------------------------------------------------------------
ECHO Checking git repos for uncommitted files and unpushed commits
ECHO -------------------------------------------------------------
ECHO.
@geerteltink
geerteltink / gulpfile.js
Created March 10, 2015 08:18
NPM scripts VS gulp.js
var gulp = require('gulp');
var cp = require('child_process');
var del = require('del');
var concat = require('gulp-concat');
var shell = require('gulp-shell');
var express = require('express');
var livereload = require('gulp-livereload');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var less = require('gulp-less');
@geerteltink
geerteltink / start-ssh-agent.cmd
Last active September 27, 2018 17:28
Start ssh-agent and add missing keys from your home path. The included script in git-for-windows didn't work for me and this one does.
@ECHO OFF
:: Enable extensions, the `verify` call is a trick from the setlocal help
VERIFY other 2>nul
SETLOCAL EnableDelayedExpansion
IF ERRORLEVEL 1 (
ECHO Unable to enable extensions
GOTO failure
)
@geerteltink
geerteltink / PHP Setter Method
Created April 12, 2015 09:41
PhpStorm file and code templates (Apache Velocity)
#set($typeHintText = "$TYPE_HINT ")
## First we check against a blacklist of primitive and other common types used in documentation.
#set($nonTypeHintableTypes = ["", "string", "int", "mixed", "number", "void", "object", "real", "double", "float", "resource", "null", "bool", "boolean"])
#foreach($nonTypeHintableType in $nonTypeHintableTypes)
#if ($nonTypeHintableType == $TYPE_HINT)
#set($typeHintText = "")
#end
#end
## Make sure the type hint actually looks like a legal php class name(permitting namespaces too) for future proofing reasons.
## This is important because PSR-5 is coming soon, and will allow documentation of types with syntax like SplStack<int>
@geerteltink
geerteltink / AppKernel.php
Created June 4, 2015 13:42
Symfony 2 - Load security configuration depending on parameter
<?php
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Yaml\Yaml;
class AppKernel extends Kernel
{
public function registerBundles()
@geerteltink
geerteltink / DoctrineDataFixturesLoadingTest.php
Created June 5, 2015 14:00
Symfony 2 loading Doctrine DataFixtures in PHPunit
<?php
namespace UserBundle\Tests\Service;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Loader as ORMLoader;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DependencyInjection\Container;