Skip to content

Instantly share code, notes, and snippets.

View digitalkaoz's full-sized avatar

Robert Schönthal digitalkaoz

View GitHub Profile
@digitalkaoz
digitalkaoz / gist:2771156
Created May 22, 2012 19:40
jquery ajax form rebind error
$(function () {
ajaxForm('.ajax-form');
})
var ajaxForm = function(query)
{
$(query).submit(function(event) {
event.preventDefault();
var $form = $(this);
@digitalkaoz
digitalkaoz / gist:3052236
Created July 5, 2012 08:14
form rendering bug
<!-- no extends -->
{% use 'form_div_layout.html.twig' with widget_attributes as base_widget_attributes %}
{% block widget_attributes %}
{% set full_name = name %}
{{ block('base_widget_attributes') }}
{% endblock widget_attributes %}
{% form_theme form _self %}
@digitalkaoz
digitalkaoz / gist:3839401
Created October 5, 2012 11:55
else if vs elseif sniff
<?php
/**
* Unity_Sniffs_Formatting_ElseIfSniff.
*
* Sniff:
* - else if instead of elseif
*/
class Unity_Sniffs_Formatting_ElseIfSniff implements PHP_CodeSniffer_Sniff
{
@digitalkaoz
digitalkaoz / BaseTestCase.php
Created November 24, 2012 14:03
PHPUnit Cache Clear beforeClass
<?php
namespace Lingwa\Bundle\CoreBundle\Test;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
abstract class BaseTestCase extends WebTestCase
{
static $cleared = false;
public static function setupBeforeClass()
@digitalkaoz
digitalkaoz / example.php
Last active December 21, 2015 06:19
custom injections for different uses of a service
<?php
// $container->get('service')
class Service
{
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
@digitalkaoz
digitalkaoz / es_index.json
Last active December 30, 2015 12:09
Elasticsearch Query Filtering...
[
{ "id" : 1, "type" : "Article", "title" : "A" },
{ "id" : 2, "type" : "Video", "title" : "B" },
{ "id" : 3, "type" : "Article", "title" : "C" },
{ "id" : 4, "type" : "Article", "title" : "D" },
{ "id" : 5, "type" : "Video", "title" : "E" },
{ "id" : 6, "type" : "Article", "title" : "F" },
{ "id" : 7, "type" : "Article", "title" : "G" },
{ "id" : 8, "type" : "Video", "title" : "H" },
{ "id" : 9, "type" : "Article", "title" : "I" },
@digitalkaoz
digitalkaoz / ModelTest.php
Last active August 29, 2015 13:57
prophecy - phpunit - yii - activerecord
<?php
class ActiveRecordTestCase extends ProphecyTestCase
{
protected $columns = [];
protected $class;
/**
* @var \CActiveRecord
@digitalkaoz
digitalkaoz / .bashrc
Created March 26, 2014 12:41
bashrc foo
#fetches a git branch from a repository
ps1_git_extra() {
branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ -z "$branch" ] ; then return ; fi
local timeout=1
echo "[$branch$statmark]"
}
git_dirty() {
# check if we're in a git repo
@digitalkaoz
digitalkaoz / File.php
Last active August 29, 2015 14:07
serializer for external classes
<?php
// My/Ns/File
namespace My\Ns;
class File
{
}
@digitalkaoz
digitalkaoz / default.vcl
Created October 14, 2014 13:47
sed problem
#backends should be injected here
director d1 round-robin {
}