Skip to content

Instantly share code, notes, and snippets.

View jmather's full-sized avatar

Jacob Mather jmather

View GitHub Profile
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()
<?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;
<?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
{
<?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()

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.
@jmather
jmather / deploy.rb
Created September 5, 2012 15:03 — forked from ed-lea/gist:3637903
# deploy.rb
#
# Multistage Deployment
#
set :stages, %w(production staging)
set :default_stage, "staging"
set :stage_dir, "app/config"
require 'capistrano/ext/multistage'
<?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 {
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]
<?php
namespace Knowhow\UserBundle\Listeners;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
class LoginListener implements EventSubscriberInterface
{
protected $event = null;
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$this->event = $event;
$username = $this->getUsername();
$session = $this->getSession();
$this->setFlash($session, $username);
}
protected function getUsername()