Skip to content

Instantly share code, notes, and snippets.

View jmather's full-sized avatar

Jacob Mather jmather

View GitHub Profile
public static $types = array(
'a' => 'Option A',
'b' => 'Option B',
);
public static function getTypeChoices()
{
return self::$types;
}
@jmather
jmather / User.php
Created October 30, 2012 02:18
File Upload Setup
<?php
/**
* This file is part of the <name> project.
*
* (c) <yourname> <youremail>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@jmather
jmather / config.rb
Created October 29, 2012 15:06
Fun stuff w/ Capifony
before 'symfony:force_migrate', 'phpunit:run_tests'
before 'symfony:cache:warmup', 'symfony:force_migrate'
namespace :phpunit do
desc "Test before making live"
task :run_tests, :roles => :app do
capifony_pretty_print "--> Executing tests"
run "cd #{latest_release} && #{phpunit_bin} -c app/ src/"
capifony_puts_ok
end
@jmather
jmather / Vagrantfile
Created October 28, 2012 21:45
Vagrant setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.provision OnHostProvisioner
end
class OnHostProvisioner < Vagrant::Provisioners::Base
def provision!
env[:vm].channel.execute("/home/vagrant/provision.sh")
end
@jmather
jmather / MyControllerProvider.php
Created October 26, 2012 20:15
How to filter a set of urls by a constraint
<?php
namespace MyCode;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Response;
class MyControllerProvider implements ControllerProviderInterface

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 / install.sh
Created October 25, 2012 00:15
[WIP] simple server setup
#!/bin/sh
PACKAGES="nano apache"
mkdir /tmp/install
cd /tmp/install
wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm
wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/ius-release-1.0-10.ius.el6.noarch.rpm
yes | rpm -ivh epel-release-6-5.noarch.rpm
yes | rpm -ivh ius-release-1.0-10.ius.el6.noarch.rpm
@jmather
jmather / config_handlers.yml
Created October 23, 2012 14:42
Use multiple templates dependent on host name in SF1
modules/*/config/view.yml:
class: dcmsViewConfigHandler
@jmather
jmather / GalleryControllerProvider.php
Created October 15, 2012 19:22
Making thumbnails with Imagine
$transformation = new Imagine\Filter\Transformation();
$size = new Imagine\Image\Box($image_size['width'], $image_size['height']);
$transformation->thumbnail($size, $image_size['style']);
$image = $transformation->apply($image);
@jmather
jmather / DICService.php
Created October 9, 2012 02:59
Pimple singleton
<?php
class DICService {
/**
* @var \Pimple
*/
static $container = null;
public static function getContainer()
{