Skip to content

Instantly share code, notes, and snippets.

View jmather's full-sized avatar

Jacob Mather jmather

View GitHub Profile
@jmather
jmather / majaxMediaFFMpeg.class.php
Created March 18, 2011 09:08
This is before trying to make this code testable. This is one small piece of a larger class...
<?php
// ... snip ...
public function process(majaxMediaFileInfo $file_info, $new_width = null, $new_height = null, $crop_method = 'fit', $aspect_ratio = '16:9')
{
$name = $file_info->getName();
$sha1 = $file_info->getSha1();
$path = $this->path_builder->render($sha1);
$full_path = sfConfig::get('app_majax_media_cache_dir').DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$name;
if (!file_exists(sfConfig::get('app_majax_media_cache_dir').DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$name))
<?php
require_once dirname(__FILE__).'/../../../../../test/phpunit/bootstrap/unit.php';
class unit_majaxMediaFilenameBuilderTest extends sfPHPUnitBaseTestCase
{
protected $builder = null;
protected function setUp()
{
@jmather
jmather / sample.yml
Created March 19, 2011 14:01
How to do a double-ref
User:
columns:
name: { type: string(255), notnull: true }
Post:
columns:
content: { type: clob }
author_id: { type: integer }
editor_id: { type: integer }
relations:
@jmather
jmather / converter.php
Created March 30, 2011 14:34
Convert KJB to array
<?php
function processFile($file)
{
$file = file_get_contents($file);
$book = array();
list($junk, $cont) = explode('<hr>', $file, 2);
protected $event = null;
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$this->event = $event;
$username = $this->getUsername();
$session = $this->getSession();
$this->setFlash($session, $username);
}
protected function getUsername()
<?php
namespace Knowhow\UserBundle\Listeners;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
class LoginListener implements EventSubscriberInterface
{
<?php
class SomeForm
{
// ... snip ...
public function saveEmbeddedForms($con = null, $forms = null)
{
<?php
/**
* Photo filter form.
*
* @package cms
* @subpackage filter
* @author JMather
* @version SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
$script = "
<script type=\"text/javascript\">
(function() {
var id = '$id';
var augment_id = id+'_messages';
var url = '$splitter_url';
var callUpdateTimeout = null;
var updateFunction = function() {
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]