Skip to content

Instantly share code, notes, and snippets.

Christoph Rosse gries

Block or report user

Report or block gries

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View simplify.js
// original
if ($scope.person.surname == '' || $scope.person.firstname == '') {
return true;
}
return false;
// simplifiziert
return !!($scope.person.surname == '' || $scope.person.firstname == '');
View gist:15ecf4627e77746d3b07
<?php
public function myPageAction(Request $request)
{
$locale = $request->getLocale();
}
View gist:eae95ade571e74fd7187
<?php
$elementalSystem = new NumberSystem(['earth', 'fire', 'air', 'water']);
$binarySystem = new NumberSystem(['0', '1']);
$number = new Number('fire-fire-earth-air', $elementalSystem, '-');
echo $number->asDecimalString(); // -> 214
$number->convert($binarySystem)->value() // -> 11010110
@gries
gries / script_in_yo_script.php
Created Jul 24, 2012
Brainfuck Javascript Interpreter parsed by PHP
View script_in_yo_script.php
<?php
/**
* Pijib
* PHP interprets Javascript interprets Brainfuck
*
* This is an awesome script that takes brainfuck-code that
* will be interpreted by Kit's JavaScript Brainfuck Interpeter that will be interpreted by PHP
*
* Yo dawg I heard you like to interpret script in the scripts of yo scripts
*/
@gries
gries / doctrine_getter_mock_right.php
Created Jan 11, 2012
mocking a doctrine getter the right way
View doctrine_getter_mock_right.php
<?php
class fooTest extends PHPUnit_Framework_TestCase
{
public function testBar()
{
$builder = $this->getMockBuilder('SomeDoctrineRecordClass')->disableOriginalConstructor();
$mockObject = $builder->getMock();
$mockObject->expects($this->any())
->method('__call')
@gries
gries / doctrine_getter_mock_wrong.php
Created Jan 11, 2012
mocking a doctrine getter the wrong way
View doctrine_getter_mock_wrong.php
<?php
class fooTest extends PHPUnit_Framework_TestCase
{
public function testBar()
{
$builder = $this->getMockBuilder('SomeDoctrineRecordClass')->disableOriginalConstructor();
$mockObject = $builder->getMock();
$mockObject->expects($this->any())
->method('getProperty')
@gries
gries / opensuse_phpunit_install.sh
Created Dec 13, 2011
Install phpunit on opensuse 11.4
View opensuse_phpunit_install.sh
#!/bin/bash
pear update-channels # updates channel definitions
pear upgrade --alldeps # upgrades all existing packages and pear
pear channel-discover components.ez.no # this is needed for PHPUnit
pear channel-discover pear.symfony-project.com # also needed by PHPUnit
pear channel-discover pear.phpunit.de # This IS phpunit
pear install --alldeps phpunit/PHPUnit # installs PHPUnit and all dependencies
phpunit --version # should display something above: 3.6.x
@gries
gries / gries_propel_blob_access
Created Oct 10, 2011
Propel-ORM BLOB access
View gries_propel_blob_access
<?php
$object = ObjectQuery::create()->findOneById(1);
// load blob content
$content = stream_get_content($object->getImage());
// content now holds the image data
var_dump($content);
You can’t perform that action at this time.