Skip to content

Instantly share code, notes, and snippets.

View jenkins-setup-credentials.groovy
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
domain = Domain.global()
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
View MeetingBlock.php
<?php
namespace My\Bundle\BlockBundle\Block;
use Symfony\Component\HttpFoundation\Response;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Block\BaseBlockService;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
View gist:4321559
<?php
use Silex\WebTestCase;
use Silex\Application;
use Silex\Provider\SessionServiceProvider;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
class unitTest extends WebTestCase
{
View gist:4320569
<?php
use Silex\WebTestCase;
use Silex\Application;
use Silex\Provider\SessionServiceProvider;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
class unitTest extends WebTestCase
{
public function testUn()
View readme.md

You can enable strict_mode, where only the exact allowed locales will be matched. For example:

  • If your user has a browser locale with de_DE and de, and you only explicitly allow de, the locale de will be chosen.
  • If your user has a browser locale with de and you only explicitly allow de_DE, no locale will be detected.
View deploy.rb
# deploy.rb
#
# Multistage Deployment
#
set :stages, %w(production staging)
set :default_stage, "staging"
set :stage_dir, "app/config"
require 'capistrano/ext/multistage'
View gist:1968002
<?php
namespace DigitalKanban\BaseBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Doctrine\ORM\EntityRepository;
use DigitalKanban\BaseBundle\Entity\User;
class UserType extends AbstractType {
View gist:1854687
public function isEmpty()
{
$method = new \ReflectionMethod(
$this->_objectOrClassName,
$this->_methodName
);
list(,$path,) = explode(PHP_EOL, (string)$method);
preg_match('/(@@ )(.*\.php)( )(\d+)(\D*)(\d+)/', $path, $matches);
list ($path, $start, $end) = array(
$matches[2], $matches[4], $matches[6]
View LoginListener.php
<?php
namespace Knowhow\UserBundle\Listeners;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
class LoginListener implements EventSubscriberInterface
{
View LoginListener.php
protected $event = null;
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$this->event = $event;
$username = $this->getUsername();
$session = $this->getSession();
$this->setFlash($session, $username);
}
protected function getUsername()