Skip to content

Instantly share code, notes, and snippets.

View smottt's full-sized avatar

Metod smottt

View GitHub Profile
<?php
function getName(array $result)
{
// resets the array pointer
// possibly be bad
// but let's say it isn't in this case
$firstEntry = reset($result);
if (is_array($firstEntry) && isset($firstEntry['name'])) {
<?php
$i = 0;
foreach ($result as $rt_val) {
if (!$i) {
echo $rt_val['name'];
}
$i++;
<?php $i=0; foreach($result as $rt_val) { if(!$i) echo $rt_val['name']; $i++; }
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
// ... set up the container
// might be helpful to check if the service is synthetic
var_dump($container->getDefinition('my.synthetic.service')->isSynthetic()); // true
{% if form.vars['errors'] is not empty %}
Magic errors display!
{% endif %}
configoptions="
--with-config-file-path=/etc/php54 \
--with-config-file-scan-dir=/etc/php54/php.d \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-cli \
--with-pear \
--with-openssl \
--with-iconv \
configoptions="
--with-config-file-path=/etc/php53 \
--with-config-file-scan-dir=/etc/php53/php.d \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-cli \
--with-pear \
--with-openssl=/usr \
--with-iconv \
@smottt
smottt / MyType.php
Created November 12, 2012 12:50
CallbackValidator example 2.1
<?php
namespace Acme\DemoBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\Event\DataEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
@smottt
smottt / MyType.php
Created November 12, 2012 12:46
CallbackValidator example
<?php
namespace Acme\DemoBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\CallbackValidator;
@smottt
smottt / ts3.php
Created September 9, 2012 09:52
Post msgs to Teamspeak3 instance
<?php
namespace Acme\Demo;
// some configuration
$all_channels = true;
$bot_name = 'TS3 BOT';
$msg = 'Hello World!';
$url = vsprintf('serverquery://username:[email protected]:10011/?server_port=9987&nickname=%s', array(